CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RS232 and Timer0 interrupt

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jack
Guest







RS232 and Timer0 interrupt
PostPosted: Fri Jan 06, 2006 9:33 am     Reply with quote

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







PostPosted: Fri Jan 06, 2006 9:47 am     Reply with quote

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







PostPosted: Fri Jan 06, 2006 10:58 am     Reply with quote

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: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Jan 06, 2006 9:35 pm     Reply with quote

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








PostPosted: Fri Jan 06, 2006 10:57 pm     Reply with quote

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: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Jan 06, 2006 11:58 pm     Reply with quote

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







PostPosted: Sat Jan 07, 2006 6:43 am     Reply with quote

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!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group