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

multiple interrupts Help ! #int_timer0 and #int_rda

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



Joined: 14 Jul 2008
Posts: 1

View user's profile Send private message

multiple interrupts Help ! #int_timer0 and #int_rda
PostPosted: Wed Jul 16, 2008 3:55 pm     Reply with quote

Hi;Embarassed

I try to use #int_timer0 and #int_rda in serial communication ,
I use #int_timer0 interrupt for flash the led it is work well, and serial communication work well but when I start to write string from PC, led is stop to flashing,

how can I use multiple interrupts #int_timer0 and #int_rda, the led can be flashing when #int_rda was working! Question
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 16, 2008 4:01 pm     Reply with quote

I suspect that you have copied some bad newbie code that you found
on this forum. In this typical newbie code, they use a for() loop or the
gets() function within the #int_rda routine. When they get the first
interrupt, they stay inside the interrupt routine for a long time. That's
not the correct way to do it. Just get one character during each
interrupt. See the CCS example file, Ex_sisr.c for an example of how
to get one character per interrupt, and save the characters in a circular
buffer.
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Thu Jul 17, 2008 3:45 pm     Reply with quote

Better still, make the timer your only interrupt. Set it up so that it occurs faster than characters can ever arrive on the serial port, and poll the character-waiting (RCIF) flag in the interrupt and read the port if necessary. If you want a slower clock rate to flash an LED, divide your fast clock down appropriately. That way, you've got a rock-solid timer running, which won't have deviations when characters come in on the serial port. Oh yeah, either plan on processing each character really fast, or buffer them and deal with the buffer in your main() routine, outside the interrupt. I do this all the time and I think it saves a lot of hassle.
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