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

PCH functions setjmp and longjmp

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



Joined: 28 Nov 2003
Posts: 39
Location: Essex UK

View user's profile Send private message

PCH functions setjmp and longjmp
PostPosted: Mon Mar 22, 2004 12:04 pm     Reply with quote

I have used these functions successfully with a PIC16F876 but when using them with a PIC18F452 the programme crashes and resets via the watchdog when I execute the longjmp. Crying or Very sad

Code:
#include <setjmp.h>

jmp_buf myenv;

// in main

  do
     {
     restart_WDT();
     setjmp(myenv);  // Back to here


// in a function

   do
      {
      key = fetch_key();  // wait for key press
      if (key == 'C')  // abort key ?
         {
         err = 0;
         longjmp(myenv,1);  // should jump to main but crashes
         }
      }
   while (key != 'E');


Compiler version 3.184

Anyone got these to work on a PIC18Fxxx ?

Thanks
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Tue Mar 23, 2004 12:33 am     Reply with quote

Are you kicking the watchdog in the fetch_key() function? If not, that may cause the program to reset.
It's hard to say what the problem is. Post your full code (incluing the setjmp.h file) so we can take a look at it.
Kieran



Joined: 28 Nov 2003
Posts: 39
Location: Essex UK

View user's profile Send private message

PostPosted: Tue Mar 23, 2004 9:29 am     Reply with quote

The fetch_key() function includes a delay_ms function with watchdog.
The code for the full project is long, I am trying a stripped down version (which works!). So I will try to reintroduce the bug then post it.
Kieran



Joined: 28 Nov 2003
Posts: 39
Location: Essex UK

View user's profile Send private message

PostPosted: Wed Mar 24, 2004 5:08 am     Reply with quote

After further testing I have given up with the longjmp approach. It worked sometimes, no time to debug further.
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