|
|
View previous topic :: View next topic |
Author |
Message |
malcolmst
Joined: 25 Oct 2004 Posts: 2
|
Error with ERRORS |
Posted: Mon Oct 25, 2004 12:16 am |
|
|
Hello,
I am using the compiler with a PIC18F8720, and I'm having a problem when I use the ERRORS directive with USE RS232.
My application uses a WDT, since it has a wireless modem which will sometimes drop out, requiring a reset. Without the ERRORS directive, this will reset fine when necessary (but it will often not read the RS232 data). When I add the ERRORS directive, the data is fine, but it somehow prevents a WDT reset. If it hangs when waiting for data, it will never reset.
Can someone please explain to me exactly what ERRORS does, and if you have any ideas why it might be preventing a WDT reset (how I can make WDT still work)?
Thanks so much!
--Malcolm |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Oct 25, 2004 6:19 am |
|
|
Post your #use RS232 statement. Did you by chance include "RESTART_WDT". If you call getc() it will wait there forever until a char comes in. |
|
|
Guest
|
|
Posted: Mon Oct 25, 2004 5:30 pm |
|
|
Hi Mark,
Here is the delay statement and RS232:
Code: |
#use delay(clock=20000000, restart_wdt)
....
#use i2c(master,sda=PIN_C4,scl=PIN_C3,fast)
#use rs232(baud=4800, xmit=PIN_J0, rcv=PIN_J1, stream=gps)
#use rs232(baud=115200, xmit=PIN_G1, rcv=PIN_G2, stream=mainunit)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, ERRORS, stream=modem) // This is the RS232 line with the issue
|
I am using getc() and fgetc(<stream>) to get the serial data.
Avatar kindly pointed out to me that it could possibly be in the delay statement. With the restart_wdt there, I think that is quite likely - I didn't notice it before . I will try it without that and see what happens.
Thanks!
--Malcolm |
|
|
malcolmst
Joined: 25 Oct 2004 Posts: 2
|
|
Posted: Tue Oct 26, 2004 2:06 am |
|
|
Hi Everyone,
Unfortunately, this does not solve the problem. I have tried many things, even dealing with the overrun manually. It still does not properly receive data. I also tried using RTS as a hardware flow control, but the overrun still happens. When the restart_wdt is removed from the #use delay, and ERRORS is kept in the #use rs232, it will still not reset when needed.
Any other ideas would be greatly appreciated.
Thanks!
--Malcolm |
|
|
Ttelmah Guest
|
|
Posted: Tue Oct 26, 2004 2:36 am |
|
|
malcolmst wrote: | Hi Everyone,
Unfortunately, this does not solve the problem. I have tried many things, even dealing with the overrun manually. It still does not properly receive data. I also tried using RTS as a hardware flow control, but the overrun still happens. When the restart_wdt is removed from the #use delay, and ERRORS is kept in the #use rs232, it will still not reset when needed.
Any other ideas would be greatly appreciated.
Thanks!
--Malcolm |
How are you dealing with the overrun manually?. This should work. Are you clearing the framing error as well (this is supposed to be reset when you read the character, but I have had problems in the past with this not being cleared on the chips).
I'd suggest posting your RS232 receive code. What you are describing, suggests that there is a delay being called in the RS232 routine somewhere (perhaps not explicitly by you), which then results in the watchdog being reset, so long as RS232 data is being seen. My thought would be that if when the second unit fails, the RS232 line gets pulled permanently low (break condition), then this triggers continuous reads, with probably the _framing error_ set, and keeps the watchdog from resetting. Without 'errors', the error bit(s) gets set, killing the UART, which then stops receiving, and the watchdog occurs.
Best Wishes |
|
|
Guest
|
|
Posted: Tue Oct 26, 2004 6:06 pm |
|
|
Thanks for your help everyone!
It turns out that in a certain point in the code, when a WDT occured, somehow it would cause a stack underflow, and start running some of the code generated by ERRORS.... So the errors option didn't directly cause the problem, but the problem only occured when the errors option was there.
I removed some code at that point which wasn't necessary, and it works fine now!
--Malcolm |
|
|
|
|
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
|