View previous topic :: View next topic |
Author |
Message |
dev39
Joined: 01 Jan 2010 Posts: 3
|
Stack under flow error when write timer ISR. |
Posted: Fri Jan 08, 2010 5:51 am |
|
|
I am trying to create ISR for timer0. But if I get uncomment the ISR it gives me following error
CORE-E0002: Stack under flow error occurred from instruction at 0x00009c
If I comment that part, the program runs fine. I am trying to run this program on MPLAB SIM. MPLAB version is 8.33. The ccsc compiler version is 4.31. The reason I want ISR is I was to check if 1 sec time is elapsed between some instructions. Let me if there is some other way to do that.
I am new to micro controller programming. Any help is appreciated.
Code: |
#include <18F46K20.h>
#use delay(clock=64M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,stream=DEV)
#INT_RTCC
clock_isr() {
int8 i=0;
}
void main() {
int16 i=0,j=0;
putc('r');
setup_timer_0( RTCC_INTERNAL | RTCC_DIV_256 );
set_timer0(0);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
for(i=0;i<6550;i++);
j=get_timer0();
while(1){
// delay_ms(100);
putc('h');
}
}
|
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Jan 08, 2010 9:29 am |
|
|
Quote: | The ccsc compiler version is 4.31 | This is an invalid version number. CCS version numbers always are in the format x.yyy
If your version number is 4.031 then this is the cause of your problems. The first releases of the v4 compiler were of bad quality and only for people willing to test the new features. Around version v4.070 the compiler because usable for the PIC18 again.
Revert to the older but stable v3.249 that was also available at time of your download, or upgrade to a newer version. |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Fri Jan 08, 2010 12:14 pm |
|
|
I have version 4.064 and the above compiled without errors. However, you are missing fuse settings and you have to check the datasheet to make sure the default internal clock will be able to support 64M clock rate. |
|
|
dev39
Joined: 01 Jan 2010 Posts: 3
|
the compiler version is 4.081 |
Posted: Fri Jan 08, 2010 8:13 pm |
|
|
the compiler version is 4.081 |
|
|
Ttelmah Guest
|
|
Posted: Sat Jan 09, 2010 11:11 am |
|
|
Post the fuses you are using.
It does compile and run OK, on 4.081, with the fuses set correctly.
One thing that sometimes generates a stack fault like this, would be having the XINST fuse set.
Best Wishes |
|
|
|