Dear sdcc users and developers, At the past I used sdcc for 14 bit pic devices with success.Now I'd like to use sdcc for a 16 bit pic microcontroller, but I have a problem just at the beginning. I tried to use timer interrupt, but my program was not able to run. After some investigation, I found a misterious problem: Just defining an interrupt routine, but not using it (disabled interrupts) makes the program unable to run.
At this point I cannot understand why? Just defining a never called routine can make the program broken? This is my example: This works: #include "pic18f46k22.h" #pragma config XINST = OFF #pragma config FOSC = HSHP #pragma config WDTEN = OFF #pragma config MCLRE = EXTMCLR #pragma config CP0 = ON #pragma config CP1 = ON #pragma config CP2 = ON #pragma config CP3 = ON #pragma config CPB = ON #define PORTC_OUTPUT_LED1 (0b00010000) #define PORTD_OUTPUT_LED2 (0b00001000) // No iterrupt routine defined void main(void) { TRISC = 0; TRISD = 0; LATC = PORTC_OUTPUT_LED1; // Leds should be switched on as the program starts run. LATD = PORTD_OUTPUT_LED2; while(1) { } } This one does not work: (The similar program with an interrupt routine defined, but interrupts were not enabled at all.) #include "pic18f46k22.h" #pragma config XINST = OFF #pragma config FOSC = HSHP #pragma config WDTEN = OFF #pragma config MCLRE = EXTMCLR #pragma config CP0 = ON #pragma config CP1 = ON #pragma config CP2 = ON #pragma config CP3 = ON #pragma config CPB = ON #define PORTC_OUTPUT_LED1 (0b00010000) #define PORTD_OUTPUT_LED2 (0b00001000) // Interrupt routine defined, but never used before interrupts are disabled by default. // This makes the code actually unable to run! sdcc bug? gputils bug? void interruptHigh (void) __interrupt 1 { if(INTCONbits.TMR0IF) { // Timer0 overflow interrupt INTCONbits.TMR0IF = 0; // ACK } } void main(void) { TRISC = 0; TRISD = 0; LATC = PORTC_OUTPUT_LED1; // Leds should be switched on as the program starts run. LATD = PORTD_OUTPUT_LED2; while(1) { } } The program has an interrupt routine but the interrupts were not enabled (after reset, interrupts are disabled by default.) After programming it into the pic, the two leds swould be switched on soon. But it does not occur.When I delete the unused interrupt routine from the source and compile and reprogram the pic, it works. The two led switched on. Did I miss something? It is not lear to me when and how should use extended instruction set or it is necessary? I use PIC18F46K22 sdcc version:SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.2.1 #8437 (Feb 22 2013) (MINGW32) gputils version:gpasm-1.0.0 #925 (Dec 23 2012) compiling and linking: sdcc -S -mpic16 -p18f46k22 -I. test.c gpasm -c test.asm gplink -s 18f46k22_g.lkr test.o libdev18f46k22.lib Thanks in advance, Tamas ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user