View previous topic :: View next topic |
Author |
Message |
ahc
Joined: 02 Feb 2012 Posts: 4
|
Reset_cause() return value 3Dh and 35h |
Posted: Thu Feb 02, 2012 2:20 pm |
|
|
Hi
I am using a PIC16F1938. I am having problems with unknown resets.
I added the Reset_cause() function and are getting unknown codes.
3Dh and 35h that is not listed in the header file.
Does anyone know what the meaning of these codes are?
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 02, 2012 2:25 pm |
|
|
The restart_cause() function must be the first thing you call at the start
of main(). It should be placed just after the variable declarations in main().
Is that how you did it ?
Also, what is your compiler version ? |
|
|
ahc
Joined: 02 Feb 2012 Posts: 4
|
|
Posted: Thu Feb 02, 2012 2:44 pm |
|
|
It is the second command if the setup statements are excluded.
If I do a power cycle then I get the correct command back.
I will move the reset_cause() to be the first command to see if it makes a difference in the code received.
Will only be possible to post answer tomorrow at earliest
I am using the ver 4.120
Thanks for reply |
|
|
ahc
Joined: 02 Feb 2012 Posts: 4
|
|
Posted: Mon Feb 06, 2012 2:04 pm |
|
|
I have moved the reset_cause() statement to be the first command in Main(). Still get a lot of 3Dh values as answer.
Did make a change on the MCLR pin to improve the pullup and added some capacitance to GND. Made some improvement to the reset problem but did not solve it completely. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Mon Feb 06, 2012 3:50 pm |
|
|
Are you sure you are using the header from the same compiler?.
0x3D, is a perfectly legal code, and listed in the headers after about V4.110. It is the code for a normal power on reset....
It should be in the 4.120 header.
Your behaviour has all the symptoms of having done a compiler upgrade, and not changed the project to use the new header files.
Best Wishes |
|
|
ahc
Joined: 02 Feb 2012 Posts: 4
|
|
Posted: Tue Feb 07, 2012 1:43 pm |
|
|
I have had a look. The header files that I have does not include 3D but does include more than what was in the previous version files.
The latest files that was part of the 4.120 installation only contains the following for the PIC16F1938
Code: | ////////////////////////////////////////////////////////////////// Control
// Control Functions: RESET_CPU(), SLEEP(), RESTART_CAUSE()
// Constants returned from RESTART_CAUSE() are:
#define NORMAL_POWER_UP 0x3C
#define BROWNOUT_RESTART 0x3E
#define MCLR_FROM_SLEEP 0x27
#define WDT_TIMEOUT 0x1F
#define WDT_FROM_SLEEP 0x0F
#define INTERRUPT_FROM_SLEEP 0x2F
#define MCLR_FROM_RUN 0x37
#define RESET_INSTRUCTION 0x3B
#define STACK_OVERFLOW 0xBF
#define STACK_UNDERFLOW 0x7F |
If the answer for 3D is that it is from a normal start then I have some fault finding to do. Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|