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

PIC24 NOSTVREN equivalent?

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



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PIC24 NOSTVREN equivalent?
PostPosted: Thu Jan 10, 2013 8:35 am     Reply with quote

COMPILER: 4.132
DEVICE: PIC24HJ128GP306

Hi all,

I am having a problem which is very hard to find. To make a long story short, I am receiving serial characters on one of the UARTS on the PIC.

The UART is tied to a cell modem with the UART configured as multiplexer mode therefore the incoming and outgoing data is framed with special characters. So, as I receive the characters from the modem, I must figure-out what part of the frame it is. Once I determine what the character is, I store it in a string. Once the string is full (after the last framing byte is received), I pass the string into an event queue for manipulation later.

Then, on occasion and at random, my PIC will reboot. I am sure this is caused by the characters being received. I think that somehow the character string overflows its length then writes in memory somewhere and reboots.

Is there an equivalent of the NOSTVREN fuse to prevent the PIC from rebooting?

Or is there anything I can do to NOT reboot the PIC? This is causing me lots of grief and I've been on this problem for a while now and I just can't figure-out what's going on.

I noticed also that there are two interruptions #int_ADDRERR and #int_STACKERR but I've never used them. If I activate those two interrupts and I run into a memory error, will the interrupts be generated instead of rebooting the PIC?

Any information will help.

Thanks!

Ben
Ttelmah



Joined: 11 Mar 2010
Posts: 19349

View user's profile Send private message

PostPosted: Thu Jan 10, 2013 9:29 am     Reply with quote

The first thing to do is increase the stack size.
#build STACK=xxxxx

The default stack _is_ too small if your code does anything complex with arithmetic, or significant printf handling.

The address error and stack error cannot be disabled. They are always on. What happens is that if there is not a handler present, they cause a reset. Add a handler, and this will be called instead, but you you then need to work out what you are going to do, since returning from the handler (for the stack error), will result in the code going somewhere it shouldn't. For the address error, corrupted memory values.

If the buffer is overflowing, you need to write your code to properly limit where it can write.

Best Wishes
benoitstjean



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Thu Jan 10, 2013 9:40 am     Reply with quote

So how big would you recommend? This command is new to me so i don't have the slightest clue what to put.

Thanks
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