From: Vangelis R. <vr...@ot...> - 2004-04-19 19:09:25
|
----- Original Message ----- From: "D Hawkins" <ill...@sl...> To: <sdc...@li...> Sent: Monday, April 12, 2004 9:33 AM Subject: [Sdcc-user] PIC "SBIT" error in assembly code > I'm a new SDCC user, hoping to use it to convert some of my PICC 14-bit > code to 16-bit devices (18FXXXx). I've encountered a problem with the > definitions of the bits in the SFR's: like GIE (bit 7 of the INTCON > register). > > Am I doing it incorrectly? I used the 'inc2h.pl' perl script to > generate the proper header file, then inserted the appropriate lines for > the definition (the resultant .h file has all sorts of other definition > problems). The use of headers generated from the inc2h.pl script in pic15 port is obsolete since February (I think). I have decided to use a new set of header files included via the generic include file pic18fregs.h (it is placed in the device/headers/pic16 directory). Currently bits in SFRs are not supported in the existing versions of the include files. But you can access an SFR via its name, i.e. INTCON. So you can change the 7th bit by a command like, INTCON |= 1<<7; to set set, INTCON &= ~(1<<7) to clear The plan is to use structure bitfields to access the individual bits, like: INTCONbits.GIE = 1; The way to implement this was opened after a request to Erik Epetrich to support anonymous structures in unions. (Erik responded immediately to the request), but in the mean while I've suspended for a while the pic16 development due to lack of time. I hope that I'll be able to be back to development soon. In the mean while you can define something like the following to simplify the bit manipulation: typedef struct { unsigned: 6; // added here the reset of the bit names if you need them unsigned GIE: 1; } INTCONbits_t; INTCONbits_t at 0xff2 INTCONbits; The you can modify the GIE by, INTCONbits.GIE > So from my limited understanding of SDCC, it would seem that the > computations are correct for the GIE bit access and the code is correct, > but there's something missing to connect the '0x7F97' with '_GIE' in the > assembly file. Does that make sense? Can anyone help, or point me in > the right direction with the source? Ths kind of representation is a bit broken in the current version of pic16 port. It even breaks compatibility with Microchip C18 compiler. I think the correct way to address a single bit is to use the above way. Soon these structures will be standardized in the pic16 header files. Good luck, Vangelis Rokas |