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

Reset and UART Problem.

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



Joined: 16 Oct 2003
Posts: 3
Location: La Porte, TX

View user's profile Send private message

Reset and UART Problem.
PostPosted: Thu Oct 28, 2004 12:44 pm     Reply with quote

When one of my 18F452 systems reset while there is activity on the RS485 bus, the system does not bootup properly.

I am creating a Stack Underflow Reset and my program reboots normally unless there is activity on the Rx line during the bootup time.

Has anyone got a fix for this problem?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 28, 2004 1:13 pm     Reply with quote

I would get rid of the Stack Underflow problem. That's the underlying
problem. So how do you get an underflow ? You could do it by
executing a Return instruction (RETURN, RETLW or a RETFIE) without
first having done a CALL or RCALL instruction, or an interrupt.
So the question would be, why are you doing this ?
Glennk



Joined: 16 Oct 2003
Posts: 3
Location: La Porte, TX

View user's profile Send private message

PostPosted: Thu Oct 28, 2004 1:49 pm     Reply with quote

Thanks for your reply.

The situation is that I have controllers in the field and one is going down and doesn't reset itself properly. I am trying to simulate the situation in the lab to see what can cause the controller to fail to reset.

Since there is serial communication much of the time and I cannot control when a reset may occur in the noisy environment of a compressor room, I'm trying to make the bootup process reliable.

The problem appears to be related to an overflow or a framing error in the UART. I have tried to clear those errors before the enable_interrupt() command but has not worked yet.

Any other thoughts you may have would be appreciated.

Glen
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 28, 2004 2:00 pm     Reply with quote

The 'Reset on Stack Underflow' capability of the 18F452 has nothing
to do with a UART overrun or framing error.

What you need to do, is to detect and clear any overrun errors
that occur in the UART. You can do this by adding the ERRORS
parameter to your #use rs232() statement, as shown in bold, below:

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

This only works with the hardware UART.
PicFan



Joined: 01 Jan 2004
Posts: 11
Location: Indianapolis (Go Colts!)

View user's profile Send private message

PostPosted: Thu Oct 28, 2004 4:58 pm     Reply with quote

How sure are you that the actual source of the reset is a "stack underflow"?

Are you testing the register or using the built-in function restart_cause() to allow you an opportunity to react to differing start-up conditions?

As PCM Programmer indicated, you won't experience a stack underflow as a response to communications activity during bootup.

Maybe set the receive pin (PIN_C7) as digital and wait for an idle state before enabling the USART to assure no comm activity?

Best Regards
asmallri



Joined: 12 Aug 2004
Posts: 1636
Location: Perth, Australia

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

PostPosted: Thu Oct 28, 2004 6:40 pm     Reply with quote

One possibility is that you may be enabling interrupts too early during your initialization

Last edited by asmallri on Thu Oct 28, 2004 9:32 pm; edited 1 time in total
Mark



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

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

PostPosted: Thu Oct 28, 2004 8:35 pm     Reply with quote

I hope that you are not enabling interrupts inside the handler. You should only do this in main() or some function called from main. The ints are automatically enabled on return from the handler. If you enable them during the interrupt routine, you are bound to have problems.
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