EmbeddedRelated.com
Forums

Strange behaviour in PIC18 interrupt

Started by R. Wilcock January 13, 2005
>Subject: Re: Strange behaviour in PIC18 interrupt >From: Jim Granville no.spam@designtools.co.nz >Date: 15/01/2005 02:27 GMT Standard Time >Message-id: <41e87f51$1@clear.net.nz> > >R. Wilcock wrote: > >> I am using a PIC18F4320 and have been trying to solve a very strange >> problem..
>> I have configured an interrupt using Timer1 which fires every 1ms. In >> that interrupt an ascii character gets sent, and is incremented, every >> time. Also, every 79 interrupts another section of the code gets >> executed, which just sends a '%' and resets the ascii code to '1'.
I saw this post before but due to a glitch it got wiped before I had a chance to reply. If I remeber right you were losing characters and your code had no handshaking protocal.You might at first think that a high speed uart with a fifo and a 3Ghz processor could keep up with a little PIC, sadly not. You must implement some handshaking, xon/xoff is best as it needs less harware but cts/rts is easier on the software.
"CBarn24050" <cbarn24050@aol.com> wrote in message
news:20050115110218.02088.00000022@mb-m14.aol.com...
> >Subject: Re: Strange behaviour in PIC18 interrupt > >From: Jim Granville no.spam@designtools.co.nz > >Date: 15/01/2005 02:27 GMT Standard Time > >Message-id: <41e87f51$1@clear.net.nz> > > > >R. Wilcock wrote: > > > >> I am using a PIC18F4320 and have been trying to solve a very
strange
> >> problem.. > > >> I have configured an interrupt using Timer1 which fires every 1ms.
In
> >> that interrupt an ascii character gets sent, and is incremented,
every
> >> time. Also, every 79 interrupts another section of the code gets > >> executed, which just sends a '%' and resets the ascii code to '1'. > > I saw this post before but due to a glitch it got wiped before I had a
chance
> to reply. If I remeber right you were losing characters and your code
had no
> handshaking protocal.You might at first think that a high speed uart
with a
> fifo and a 3Ghz processor could keep up with a little PIC, sadly not.
You must
> implement some handshaking, xon/xoff is best as it needs less harware
but
> cts/rts is easier on the software.
I'm inclined to agree with this. Even at only one character per mS, if windows zones out for 16mS you have lost data. It doesn't sound sensible, but I could easily see windows being out to lunch and not servicing interrupts for the 100mS needed to cause your data loss. In fact I've seen a PC freeze intermittently (due to a brain dead VXD device driver) so badly that the clock lost hours per day because of all the lost timer ticks (these only occur every 50 something mS). If you use OE for email and have large numbers of records in your folders, win98 will freeze the machine (mouse even stops moving) while rifling thru the database and toss timer ticks out. It's really kinda sad. I'd trust a DOS terminal program or even another PIC long before believing anything hyperterm showed me.
Yes well I eventually found the problem, by making another PIC read the
first one, and a few of you were right - the PC was at fault. It was
just dropping characters for no reason.

Thanks for all the help! I have doubled the interrupt period and it
doesnt happen any more, but still, pretty pathetic if you ask me that a
2Gig PC cannot keep up with a PIC!

Reuben

reubenwilcock@hotmail.com wrote:
> > Yes well I eventually found the problem, by making another PIC > read the first one, and a few of you were right - the PC was at > fault. It was just dropping characters for no reason. > > Thanks for all the help! I have doubled the interrupt period and > it doesnt happen any more, but still, pretty pathetic if you ask > me that a 2Gig PC cannot keep up with a PIC!
Of course we were right. We have dealt with Micro$loth OSs before. It's not the PC, its the alleged programming of it. -- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson