Oscillators/PCA/Timers/SMBus/UART/SPI
  uart c8051f005

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   uart c8051f005
massart
New Member
posted March 11, 2010 08:06 AM     Click Here to See the Profile for massart   Click Here to Email massart     Edit/Delete Message
Hello
I use a 8051F005 and have a problem with UART when using it under interrupt mode.
All seems to work perfectly, but I lose receiving data from time to time .
I analysed the problem with monitoring a port (P3.2) level with an oscilloscope. This port is programmed to change its level each time the program enters the interrupt 4 service routine.
And I see that, even I dont emit or receive any data, this interrupt routine is accessed every 5 microsecond !
The only way I find to avoid that is to inhibit all IRQ with EA=0 ! but, of course, I cannot receive my data from serial line !
If I leave these frequent accesses to IRQ routine, all my timing in software loops or other time dependent operations are false.
Is ther a mean to ensure good data reception based on IRQ gestion of UART, without those "parasitic" IRQ access ???
I must say I use printf to transmit my data on UART. Is there an incompatibility with interrupt gestion of UART ?
Thanks a lot for your answer.

------------------

IP: Logged

Scotty
Member
posted March 11, 2010 08:43 AM     Click Here to See the Profile for Scotty     Edit/Delete Message
Hi,

I must say I use printf to transmit my data on UART. Is there an incompatibility with interrupt gestion of UART ?
Depending on the compiler you use - yes, there is incompatibility. For example, on Keil C51, printf uses putchar() (and scanf uses getchar()). If you don't have a own version of it, the default versions are used - and they work by polling, not interrupt driven! So you've to write your own putchar() function.

Do you use Keil? If yes, copy the PUTCHAR.C file from the KEIL\C51\LIB folder to your project folder, include it in your build process and modify it to interrupt driven mode.

Regards,

Scotty

IP: Logged

massart
New Member
posted March 11, 2010 10:43 AM     Click Here to See the Profile for massart   Click Here to Email massart     Edit/Delete Message
Thanks a lot for your so quick answer !
Its'fine
What you tell me is the conclusion I have arrived to.
I will rewrite my own subroutines, it's the easiest way.
I don't understand anyway where do the perpetuous acces to ISR come from....

IP: Logged

erikm
Member
posted March 11, 2010 03:31 PM     Click Here to See the Profile for erikm   Click Here to Email erikm     Edit/Delete Message
I don't understand anyway where do the perpetuous acces to ISR come from....

a 99.9% guess:

you do not clear TI and RI in the ISR

Erik

IP: Logged

massart
New Member
posted March 13, 2010 11:49 AM     Click Here to See the Profile for massart   Click Here to Email massart     Edit/Delete Message
Hi, erik
Yes, it was the first thing I think.
But, if I put a TI=0, the problem of ISR accese is solved..... but nothing works more on the UART !
I copy the beginning of my ISR routine : if I use the TI=0, as written in comment at the beginning of the ISR, no more access to UART, even for receiving !

//=====================================================================
//interruption UART
//=======================================================================
void SerieISR (void) interrupt 4
{
clock=~clock; //to monitor ISR access with an oscilloscope on a port pin
// if (TI) THE PROBLEM !!!
// TI=0;
if (RI) //teste si IRQ vient de reception sur l'UART

{
//
EA = 0x00;
NbCarRX=0;
RI = 0; //acquittement IRQ
CarRecu = SBUF;

IP: Logged

erikm
Member
posted March 13, 2010 12:16 PM     Click Here to See the Profile for erikm   Click Here to Email erikm     Edit/Delete Message
EA = 0x00;

WHY??????????

Erik

IP: Logged

massart
New Member
posted March 13, 2010 06:24 PM     Click Here to See the Profile for massart   Click Here to Email massart     Edit/Delete Message
Hi, Erik
First, thank you for your help, because it's very comfortable to know there is someone who hears you and try to help you !
Oh, sorry for that small mistake : It was originally a EIE2=0x00 which becomes EA=...
I dont think it's a problem ?
In any case, I have no upper IRQ priority than UART, so this instruction doesnt play....

second : sorry for my poor english !!! you certainly saw it's not my mother's language !!!

TI is the problem, and I don't see what to do.

IP: Logged

erikm
Member
posted March 14, 2010 06:27 AM     Click Here to See the Profile for erikm   Click Here to Email erikm     Edit/Delete Message
// if (TI) THE PROBLEM !!!
// TI=0;

can't be
I have

if (TI)
{
TI = 0;
SBUF = data; // of course not this simple
}

in umpteen projects

Erik

IP: Logged

vanmierlo
Member
posted March 15, 2010 04:09 AM     Click Here to See the Profile for vanmierlo   Click Here to Email vanmierlo     Edit/Delete Message
You don't need to disable the interrupts in an ISR. All interrupts of same priority are already disabled when entering the ISR. And if you want to give this one a higher priority than other interrupts then set the priority bit.

If you check and clear TI0 you'll have to use other means to communicate with putchar(). Either use an extra flag that you set when TI is cleared so you can check it in putchar or use a (ring-)buffer with pointers.

You cannot mix using RI in the ISR and poll TI in the main loop. You must choose.

IP: Logged

pathipatijyothi
New Member
posted September 10, 2010 04:41 AM     Click Here to See the Profile for pathipatijyothi     Edit/Delete Message
I want programming code for gpio interrupt using 8051 micro controller.I want to make enable an interrupt 1 out of 4 dip switches with out using external interrupts.

IP: Logged

erikm
Member
posted September 10, 2010 07:32 AM     Click Here to See the Profile for erikm   Click Here to Email erikm     Edit/Delete Message
I want programming code for gpio interrupt using 8051 micro controller.I want to make enable an interrupt 1 out of 4 dip switches with out using external interrupts

if you want to find someone to help you cheat, go elsewhere.

I wish that everyone that help a 'student' cheat will end up with someone that has copied his/her way to a diploma as an assistant.

Erik

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | MCU User Forum

Have you seen our MCU Knowledge Base?


Ultimate Bulletin Board 5.47b