|
![]() Oscillators/PCA/Timers/SMBus/UART/SPI
![]() uart c8051f005
|
| next newest topic | next oldest topic |
| Author | Topic: uart c8051f005 |
|
massart New Member |
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 |
Hi, I must say I use printf to transmit my data on UART. Is there an incompatibility with interrupt gestion of UART ? 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 |
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 |
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 |
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 ! //===================================================================== IP: Logged |
|
erikm Member |
EA = 0x00; WHY?????????? Erik IP: Logged |
|
massart New Member |
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 |
// if (TI) THE PROBLEM !!! // TI=0; can't be if (TI) in umpteen projects Erik IP: Logged |
|
vanmierlo Member |
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 |
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 |
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 |
![]() |
|
Have you seen our MCU Knowledge Base?