Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#966 PIC16: Clash between bits in signal.h and pic18fXXXX.h

closed-accepted
5
2013-05-25
2005-08-06
Peter Onion
No

It is impossible to write code to clear TMR2IF in the
TMR2 signal handler due to multiple use of the name
"TMR2IF". It is defined as a bit in the PIR1 structure
in (for example) pic18f458.h

extern __sfr __at (0xf9e) PIR1;
typedef union {
struct {
unsigned TMR1IF:1;
unsigned TMR2IF:1;
unsigned CCP1IF:1;
unsigned SSPIF:1;
unsigned TXIF:1;
unsigned RCIF:1;
unsigned ADIF:1;
unsigned PSPIF:1;
};
} __PIR1bits_t;

extern volatile __PIR1bits_t __at (0xf9e) PIR1bits;

AND it is defined in signal.h

#define TMR1IF 0x0
#define TMR2IF 0x1
#define CCP1IF 0x2
#define SSPIF 0x3
#define TXIF 0x4
#define RCIF 0x5
#define ADIF 0x6
#define PSPIF 0x7

The preprocessor gets there first and so when you write

SIGHANDLER(_TMR2_handler)
{
PIR1bits.TMR2IF = 0;
}

the compiler gets
PIR1bits.0x1 = 0;
and gives the error
: syntax error: token -> '0x1' ; column 11

My solution is to prefix the symbols in signal.h with SIG_

Peter.

Discussion

  • Raphael Neider
    Raphael Neider
    2005-08-07

    • labels: --> pic16 target
    • milestone: --> fixed
    • assigned_to: nobody --> tecodev
    • status: open --> closed-accepted
     
  • Raphael Neider
    Raphael Neider
    2005-08-07

    Logged In: YES
    user_id=1115835

    Fixed in SDCC 2.5.2 #1083.