View previous topic :: View next topic |
Author |
Message |
jack Guest
|
RS232 and Timer0 interrupt |
Posted: Fri Jan 06, 2006 9:33 am |
|
|
Hi, I have a question about....RS232 and Timer0 interrupt...
I'm sending data over rs232 at 2400baud...at the same time timer0 overflow interrupt @ 64.5msec occurs through out, will the data be recieved safely??
Thanks |
|
|
Ttelmah Guest
|
|
Posted: Fri Jan 06, 2006 9:47 am |
|
|
Not enough data to answer.
With the software UART, if you disable interrupts during the character receive time, and ensure the interrupt handler takes no longer than about perhaps 1/10000th second, it may just be possible to receive correctly.
With the hardware UART, If the duration of the timer interrupt, exceeds about 8mSec, then data loss may occur.
Best Wishes |
|
|
jack Guest
|
|
Posted: Fri Jan 06, 2006 10:58 am |
|
|
Thanks....Ttelmah, I'm using software UART. Here is my ISR code....will it take 1/10000th second, is it ok??? I'll be running 16f628 @ 4Mhz....please help....
Code: |
#int_timer0
timer0_isr() // Timer0(8 bit) Overflow interrput function
{
if(s==1)
timer1_overflow--;
if(timer1_overflow==0)
{
output_low(PIN_A2)
}
output_b(ten);
output_high(PIN_A0);
output_b(one);
output_high(PIN_A1);
}
|
|
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Jan 06, 2006 9:35 pm |
|
|
jack wrote: | Thanks....Ttelmah, I'm using software UART. Here is my ISR code....will it take 1/10000th second, is it ok??? I'll be running 16f628 @ 4Mhz....please help.... |
Look ok from the little bit of information provided but..
How are the types of the variables s and timer_overflow?
Where is the variable s modified?
Does timer_overflow ever get set to a value? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Guest
|
|
Posted: Fri Jan 06, 2006 10:57 pm |
|
|
asmallri wrote: | jack wrote: | Thanks....Ttelmah, I'm using software UART. Here is my ISR code....will it take 1/10000th second, is it ok??? I'll be running 16f628 @ 4Mhz....please help.... |
Look ok from the little bit of information provided but..
How are the types of the variables s and timer_overflow?
Where is the variable s modified?
Does timer_overflow ever get set to a value? |
int16 timer1_overflow=2700; //I need time dealy of about 3min
int1 s=0;
s will be modified by external RB0/INT pin.....which will occur rarely!!
Actaully timer1_overflow in my case is for fault prevention.....I will always refill its value will 2700 every minute....so it should rarely reach 0.
Thanks a lot |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Jan 06, 2006 11:58 pm |
|
|
Should be ok however, when you reload timer_overflow make sure you disable timer interrupts before you modify the value. Otherwise a timer interrupt could trash the value you are writing.
Similarly, if you a reading the value of timer_overflow outside the interrupt handler, make sure you disable interrupts first. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
jack Guest
|
|
Posted: Sat Jan 07, 2006 6:43 am |
|
|
asmallri wrote: | Should be ok however, when you reload timer_overflow make sure you disable timer interrupts before you modify the value. Otherwise a timer interrupt could trash the value you are writing.
Similarly, if you a reading the value of timer_overflow outside the interrupt handler, make sure you disable interrupts first. |
Thank you very much....I was really skipping this crucial step!!! |
|
|
|