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 support@ccsinfo.com

external interrupt problem when receiving serial data

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







external interrupt problem when receiving serial data
PostPosted: Fri Feb 11, 2005 10:55 am     Reply with quote

#USE rs232(baud=9600, PARITY=N, bits=8, xmit=PIN_B0, rcv=PIN_B0, stream = PBUS, float_high)

...

#int_ext
void pbus_isr()
{
byte data;
if (kbhit(PBUS))
{
data=fgetc(PBUS);
SerLog[ser_next_in]=data;
ser_next_in = (ser_next_in + 1) % SerLogLength;
}
}

I am using the B0 port to transmit/receive serial data from another microprocessor. My ISR above just pulls bytes into a FIFO buffer that I deal with later on. It doesn't appear that the ISR is occuring quick enough because I get garbage data coming in, but if I add a while loop around the if kbhit() statement that keeps checking the port , then my data comes in fine. It seems that as soon as it leaves the ISR, it takes too long to get back in and bytes are missed.

Where can I view/control the data that gets stacked when the ISR routine kicks in ?

What is strange is that this never used to be a problem, but I can't remember which rev of compiler I was using when I last had it running. Also, I used to have much more in the int_ext routine that parsed the message as it came in, with no problems !

(using PIC18F252 and v3.212 of compiler, although I have tried later compiler versions with no luck)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 11, 2005 2:53 pm     Reply with quote

Quote:

It seems that as soon as it leaves the ISR, it takes too long to get back in
and bytes are missed.
Where can I view/control the data that gets stacked when the ISR routine kicks in ?

Look in the .LST file generated by the compiler. Look at address 0008
for the start of the interrupt dispatcher code.

Also, if you disable interrupts for any substantial period of time, you
could cause the problem that you're seeing.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 11, 2005 3:30 pm     Reply with quote

Since it is an 18 series pic, you can make the external int a high priority interrupt which will save you tons of time. I would recommend that you write you own interrupt handler.

Here is an example of writing your own int handler:
http://www.ccsinfo.com/forum/viewtopic.php?t=21092&postdays=0&postorder=asc&start=15
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Feb 11, 2005 5:10 pm     Reply with quote

NikkariB wrote:

Quote:

(using PIC18F252 and v3.212 of compiler, although I have tried later compiler versions with no luck)


FYI, I have projects that doesn´t run with V3.212. I´m still using V3.190

Humberto
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