Hi, I found the problem myself. SDCC uses interrupt 1 to high priority and interrupt 2 to low priority. I was based on wrong examples found at internet.
cheers, Alan 2007/10/13, Alan Carvalho de Assis <[EMAIL PROTECTED]>: > Hi, > I'm found two approaches to implements an interrupt handler on sdcc, > but none is working here. > > The first one is this: > > void timer_intr() interrupt 0 { > LED_PIN ^= 1; > INTCONbits.T0IF = 0; > } > > But when compiling I get this error: > > sdcc -mpic16 -p18f2680 -V -Wl-c -I/home/alan/pic/inte/ -ointe.hex inte.o > message: using default linker script "/usr/share/gputils/lkr/18f2680.lkr" > error: multiple sections using address 0 > > So looking at inte.asm file we see: > > ;-------------------------------------------------------- > ; interrupt vector > ;-------------------------------------------------------- > > ;-------------------------------------------------------- > ; global & static initialisations > ;-------------------------------------------------------- > ; ; Starting pCode block for absolute section > ; ;----------------------------------------- > S_inte_ivec_0x0_timer_intr code 0X000000 > ivec_0x0_timer_intr: > GOTO _timer_intr > > ; I code from now on! > ; ; Starting pCode block > S_inte__main code > _main: > ; .line 82; inte.c RCONbits.IPEN = 1; > BSF _RCONbits, 7 > ; .line 85; inte.c INTCONbits.GIEH = 1; > BSF _INTCONbits, 7 > ; .line 88; inte.c INTCONbits.T0IE = 1; > BSF _INTCONbits, 5 > > Really the _timer_intr is not placed at 0x000008 but 0X000000. > > > The second approach is this: > > DEF_INTHIGH(high_int) > DEF_HANDLER(SIG_TMR0, _tmr0_handler) > END_DEF > > SIGHANDLER(_tmr0_handler) > { > LED_PIN ^= 1; > INTCONbits.T0IF = 0; > } > > Now the compilation goes fine and the interrupt handle address is > placed at 0x000008. > > But the timer0 is not generating interruptions for me. I'm sending my > file below. > > What is the right solution to fix this problem? > > Cheers, > > Alan > > #include <pic18f2680.h> > #include <signal.h> // for interrupt > > // ------------------------------------------------ > // change these if you're wiring the LED to other pin > > #ifndef LED_TRIS > #define LED_TRIS TRISAbits.TRISA0 > #endif > > #ifndef LED_PIN > #define LED_PIN PORTAbits.RA0 > #endif > > // ------------------------------------------------ > // configuration for PIC18F2680 > // xtal based, PLL enabled (for xtal to max 10 MHz, for higher xtal > freqencies use _OSC_HS_1H ) > code char at __CONFIG1H _conf1 = _OSC_HS_1H & //_OSC_HSPLL_1H & > _IESO_OFF_1H & > _FCMEN_ON_1H; > > code char at __CONFIG2L _conf2 = _BOREN_BOHW_2L & > _BORV_1_2L; // 4.3 V > > code char at __CONFIG2H _conf3 = _WDTPS_1_2H & > _WDT_OFF_2H; > > code char at __CONFIG3H _conf4 = _MCLRE_ON_3H & > _LPT1OSC_OFF_3H & > _PBADEN_OFF_3H; > > code char at __CONFIG4L _conf5 = _LVP_ON_4L & > _XINST_OFF_4L & // extended instruction set > off => if enabled, > your sdcc compiled programm will not work properly! > _STVREN_OFF_4L; > > code char at __CONFIG5L _conf6 = _CP0_OFF_5L & > _CP1_OFF_5L & > _CP2_OFF_5L & > _CP3_OFF_5L; > > code char at __CONFIG5H _conf7 = _CPB_OFF_5H & > _CPD_OFF_5H; > > code char at __CONFIG6L _conf8 = _WRT0_OFF_6L & > _WRT1_OFF_6L & > _WRT2_OFF_6L & > _WRT3_OFF_6L; > > code char at __CONFIG6H _conf9 = _WRTB_OFF_6H & > _WRTC_OFF_6H & > _WRTD_OFF_6H; > > code char at __CONFIG7L _conf10 = _EBTR0_OFF_7L & > _EBTR1_OFF_7L & > _EBTR2_OFF_7L & > _EBTR3_OFF_7L; > > code char at __CONFIG7H _conf11 = _EBTRB_OFF_7H; > > > DEF_INTHIGH(high_int) > DEF_HANDLER(SIG_TMR0, _tmr0_handler) > END_DEF > > SIGHANDLER(_tmr0_handler) > { > LED_PIN ^= 1; > > // Clear interrupt flag; > INTCONbits.T0IF = 0; > } > > void main() { > // Enables priority levels on interrupts > RCONbits.IPEN = 1; > > // Enables high priority interrupts > INTCONbits.GIEH = 1; > > // Enables the TMR0 overflow interrupt > INTCONbits.T0IE = 1; > > //set timer overflow > TMR0H = 10; > TMR0L = 0; > > //clear T0CON > T0CON = 0; > //set prescaler to 1:256 > T0CONbits.T0PS0 = 1; > T0CONbits.T0PS1 = 1; > T0CONbits.T0PS2 = 1; > > //wait until bit clear > while(INTCONbits.T0IF) > INTCONbits.T0IF = 0; > > //timer on > T0CONbits.TMR0ON = 1; > > // set pin to output > LED_TRIS = 0; > > //turn led on > LED_PIN = 1; > > while(1) { > > } > } > ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user