AnsweredAssumed Answered

xor operation in C for CW5.1

Question asked by michel qunica on May 18, 2007
Latest reply on May 23, 2007 by CompilerGuru
Hi,
 
I am trying to port ucos-ii to 908mcu with CW5.1. I use example from ucos-ii website which is tested.
But many errors appears while compling.
For instance:
 
 
it is on this line:
PORTA^=B6M
 
PORTA is defined in .h file like this:  
                                       volatile BIT_CHAR PORTA @0x00;
B6M is defined as such:
                                      #define B6M  0x40  
I search the HELP for CW5.1 and found this error relaated to "The expression was not of integral type. ",and suggestion is "The expression must be an integral type. "
 
You may know what I need to do: PORTA =PORTA xor B6M
How can I do this with CW5.1?
 
Here is the complete .h file where the BIT_CHAR, PORTA... are defined
 
Code:
/* DEFINICION DE IO PARA EL MC689HC08GP32 * Copyright (c) 2001 por JFIG TECHNOLOGIES */#ifndef __IO_H#define __IO_H#define uint unsigned int  //Definici髇 corta de un entero no     //signado#define uchar unsigned char  //Definici髇 corta de un char o byte no     //signado#define EI() _asm("cli\n")  //Habilita interrupciones#define DI() _asm("sei\n")  //Deshabilita interrupciones#define FALSE 0#define TRUE 1typedef struct { unsigned char b0:1; unsigned char b1:1; unsigned char b2:1; unsigned char b3:1; unsigned char b4:1; unsigned char b5:1; unsigned char b6:1; unsigned char b7:1; } BITS;/*Estructura cuyos miembros son campos de bits del tama駉 de un solo bit.Como estoy utilizando typedef, estoy definiendo otro tipo llamado BITS.Recordemos que typedef se utiliza para renombrar un tipo de dato espec韋ico,es decir, no se crea un nuevo tipo, se renombra.*/ typedef union { unsigned char byte; BITS b; }BIT_CHAR;//Con esta estructura, puedo definir un puerto de IO de la siguiente manera://////////////////////////////////////////////////////////////////////////////  PUERTOS O REGISTROS DE IO/////////////////////////////////////////////////////////////////////////////M罶CARAS:#define B7M  0x80#define B6M  0x40  #define B5M  0x20#define B4M  0x10#define B3M  0x08#define B2M  0x04#define B1M  0x02#define B0M  0x01/*Para referenciar una direcci髇 absoluta con el compilador de COSMICespecificamos la direcci髇 @0xXXXX; a esta direcci髇 le debemos asociar un nombre simb髄ico y un tipo*///////////////////////////////////////////////// PUERTO A////////////////////////////////////////////// volatile BIT_CHAR PORTA @0x00;  volatile BIT_CHAR DDRA @0x04;  volatile BIT_CHAR PTAPUE @0x0D; //////////////////////////////////////////////// PUERTO B////////////////////////////////////////////// volatile BIT_CHAR PORTB @0x01;  volatile BIT_CHAR DDRB @0x05;//////////////////////////////////// M罶CARAS//////////////////////////////////#define PTB0 B0M#define PTB1 B1M#define PTB2 B2M#define PTB3 B3M#define PTB4 B4M#define PTB5 B5M#define PTB6 B6M#define PTB7 B7M//////////////////////////////////////////////// PUERTO C////////////////////////////////////////////// volatile BIT_CHAR PORTC @0x02;  volatile BIT_CHAR DDRC @0x06; volatile BIT_CHAR PTCPUE @0x0E; //////////////////////////////////// M罶CARAS//////////////////////////////////#define PTC0 B0M#define PTC1 B1M#define PTC2 B2M#define PTC3 B3M#define PTC4 B4M#define PTC5 B5M#define PTC6 B6M#define PTC7 B7M//////////////////////////////////////////////// PUERTO D////////////////////////////////////////////// volatile BIT_CHAR PORTD @0x03;  volatile BIT_CHAR DDRD @0x07;  volatile BIT_CHAR PTDPUE @0x0F; //////////////////////////////////////////////// PUERTO E////////////////////////////////////////////// volatile BIT_CHAR PORTE @0x08;  volatile BIT_CHAR DDRE @0x0C;////////////////////////////////////////////////                     SPI////////////////////////////////////////////// volatile BIT_CHAR SPCR @0x0010; volatile BIT_CHAR SPSCR @0x0011;  volatile BIT_CHAR SPDR @0x0012;//////////////////////////////////////////////// M罶CARAS//////////////////////////////////////////////#define SPRIE 0x80#define DMAS 0x40#define SPMSTR 0x20#define CPOL 0x10#define CPHA 0x08#define SPWOM 0x04#define SPE  0x02#define SPTIE 0x01#define SPRF 0x80#define ERRIE 0x40#define OVRF 0x20#define MODF 0x10#define SPTE 0x08#define MODFEN 0x04#define SPR1 0x02#define SPR0 0x01//////////////////////////////////////////////// MACROS//////////////////////////////////////////////#define SpiIntRxEnable SPCR.b.b7 = 1#define SpiIntRxDisable SPCR.b.b7 = 0#define SpiMasterMode SPCR.b.b5 = 1#define SpiSlaveMode SPCR.b.b5 = 0#define SpiCpolSet SPCR.byte |= CPOL#define SpiCpolClear SPCR.byte &= ~CPOL#define SpiCphaSet SPCR.byte |= CPHA#define SpiCphaClear SPCR.byte &= ~CPHA#define SpiDisablePullups SPCR.b.b2 = 1#define SpiEnablePullups SPCR.b.b2 = 0#define SpiOn SPCR.b.b1 = 1 #define SpiOff SPCR.b.b1 = 0#define SpiIntTxEnable SPCR.b.b0 = 1#define SpiIntTxDisable SPCR.b.b0 = 0#define SpiReciveFull SPSCR.b.b7 == 1#define SpiIntErrEnable SPSCR.b.b6 = 1#define SpiIntErrDisable SPSCR.b.b6 = 0#define SpiOverflow SPSCR.b.b5 == 1#define SpiModeFault SPSCR.b.b4 == 1#define SpitransmitEmpty SPSCR.b.b3 == 1#define SpiModeFaultEnable SPSCR.b.b2 = 1#define SpiModeFaultDisable SPSCR.b.b2 = 0#define SpiFrec_DIV4 SPSCR.byte #define SpiFrec_DIV16 SPSCR.byte |= (SPR0)#define SpiFrec_DIV64 SPSCR.byte |= (SPR1)#define SpiFrec_DIV256 SPSCR.byte |= (SPR1 | SPR0)////////////////////////////////////////////////                   SCI///////////////////////////////////////////// volatile BIT_CHAR SCC1 @0x0013;  volatile BIT_CHAR SCC2 @0x0014;  volatile BIT_CHAR SCC3 @0x0015;  volatile BIT_CHAR SCS1 @0x0016;  volatile BIT_CHAR SCS2 @0x0017; volatile BIT_CHAR SCDR @0x0018;  volatile BIT_CHAR SCBR @0x0019; ////////////////////////////////////////////////                  KBI////////////////////////////////////////////// volatile BIT_CHAR INTKBSCR @0x001A;  volatile BIT_CHAR INTKBIER @0x001B; ///////////////////////////////////////////////      M罶CARAS/////////////////////////////////////////////#define KEYF 0x08#define ACKK 0x04#define IMASKK 0x02#define MODEK 0x01///////////////////////////////////////////////      MACROS/////////////////////////////////////////////#define KbiAck INTKBSCR.b.b2 = 1#define KbiMaskEnable INTKBSCR.b.b1 = 1#define KbiMaskDisable INTKBSCR.b.b1 = 0#define KbiFallingEdge INTKBSCR.b.b0 = 0#define KbiFallingLevel INTKBSCR.b.b0 = 1#define KbiA0Enable INTKBIER.b.b0 = 1 #define KbiA0Disable INTKBIER.b.b0 = 0#define KbiA1Enable INTKBIER.b.b1 = 1 #define KbiA1Disable INTKBIER.b.b1 = 0  #define KbiA2Enable INTKBIER.b.b2 = 1 #define KbiA2Disable INTKBIER.b.b2 = 0 #define KbiA3Enable INTKBIER.b.b3 = 1 #define KbiA3Disable INTKBIER.b.b3 = 0 #define KbiA4Enable INTKBIER.b.b4 = 1 #define KbiA4Disable INTKBIER.b.b4 = 0 #define KbiA5Enable INTKBIER.b.b5 = 1 #define KbiA5Disable INTKBIER.b.b5 = 0 #define KbiA6Enable INTKBIER.b.b6 = 1 #define KbiA6Disable INTKBIER.b.b6 = 0 #define KbiA7Enable INTKBIER.b.b7= 1 #define KbiA7Disable INTKBIER.b.b7= 0 #define KbiPortaEnable PORTA.byte = 0xFF#define KbiPortaDisable PORTA.byte = 0x00////////////////////////////////////////////////                  TBM////////////////////////////////////////////// volatile BIT_CHAR TBCR @0x001C;////////////////////////////////////// M罶CARAS////////////////////////////////////#define TBIF    0x80#define TBR2 0x40#define TBR1 0x20#define TBR0    0x10#define TACK    0x08#define TBIE    0x04#define TBON    0x02#define TBTST   0x01////////////////////////////////////// MACROS////////////////////////////////////#define TbmIntPending TBCR.b.b7 == 1#define TbmFrec_1Hz #define TbmFrec_16Hz TBCR.byte |= TBR1#define TbmFrec_1024Hz TBCR.byte |= TBR0 | TBR2#define TbmFrec_256Hz TBCR.byte |= TBR0 | TBR1#define TbmFrec_512Hz TBCR.byte |= TBR2#define TbmFrec_2048Hz TBCR.byte |= TBR2 | TBR1#define TbmAck TBCR.b.b3 = 1#define TbmIntEnable TBCR.b.b2 = 1#define TbmOn TBCR.b.b1 = 1#define TbmOff TBCR.b.b1 = 0  ////////////////////////////////////////////////       IRQ////////////////////////////////////////////// volatile BIT_CHAR INTSCR @0x1D; //IRQ Status and Control Register///////////////////////////////////////////////           CONFIG///////////////////////////////////////////// volatile BIT_CHAR CONFIG1 @0x1F; volatile BIT_CHAR CONFIG2 @0x1E;///////////////////////////////////////////////         TIMER1///////////////////////////////////////////// volatile BIT_CHAR T1SC @0x20; volatile char T1CNTH @0x21;  volatile char T1CNTL @0x22;  volatile uint T1CNT  @0x21; volatile char T1MODH @0x23;  volatile char T1MODL @0x24;  volatile uint T1MOD  @0x23;  volatile BIT_CHAR T1SC0 @0x25; volatile char T1CH0H @0x26;  volatile char T1CH0L @0x27;  volatile uint T1CH0  @0x26;  volatile BIT_CHAR T1SC1 @0x28;  volatile char T1CH1H @0x29;  volatile char T1CH1L @0x2A;  volatile uint T1CH1  @0x29;///////////////////////////////////////////////// M罶CARAS///////////////////////////////////////////////#define TOF B7M#define TOIE B6M#define TSTOP B5M#define TRST B4M#define PS2 B2M#define PS1 B1M#define PS0 B0M#define CHF B7M#define CHIE B6M#define MSB B5M#define MSA B4M#define ELSB B3M#define ELSA B2M#define TOV B1M#define CHMAX B0M  ///////////////////////////////////// MACROS///////////////////////////////////#define Tim1Overflow T1SC.b.b7 == 1#define Tim1OverIntEnable T1SC.b.b6 = 1#define Tim1OverIntDisable T1SC.b.b6 = 0#define Tim1Stop T1SC.b.b5 = 1#define Tim1Run T1SC.b.b5 = 0#define Tim1Reset T1SC.b.b4 = 1#define Tim1ClkBusDiv1 #define Tim1ClkBusDiv2 T1SC.byte |= PS0#define Tim1ClkBusDiv4 T1SC.byte |= PS1#define Tim1ClkBusDiv8 T1SC.byte |= PS0 | PS1#define Tim1ClkBusDiv16 T1SC.byte |= PS2#define Tim1ClkBusDiv32 T1SC.byte |= PS2 | PS0#define Tim1ClkBusDiv64 T1SC.byte |= PS2 | PS1#define Tim1Ch0IntRequest T1SC0.b.b7 == 1#define Tim1Ch0IntEnable T1SC0.b.b6 = 1 #define Tim1Ch0IntDisable T1SC0.b.b6 = 0#define Tim1Ch0InputcRising T1SC0.byte |= ELSA#define Tim1Ch0InputcFalling T1SC0.byte |= ELSB#define Tim1Ch0InputcBoth T1SC0.byte |= ELSB | ELSA#define Tim1Ch1IntRequest T1SC1.b.b7 == 1#define Tim1Ch1IntEnable T1SC1.b.b6 = 1 #define Tim1Ch1InputcRising T1SC1.byte |= ELSA#define Tim1Ch1InputcFolling T1SC1.byte |= ELSB#define Tim1Ch0IntAck T1SC0.byte; T1SC0.b.b7 = 0 #define Tim1Ch1IntAck T1SC1.byte; T1SC1.b.b7 = 0///////////////////////////////////////////////           TIMER2///////////////////////////////////////////// volatile BIT_CHAR T2SC @0x2B;  volatile char T2CNTH @0x2C;  volatile char T2CNTL @0x2D;  volatile uint T2CNT  @0x2C; volatile char T2MODH @0x2E;  volatile char T2MODL @0x2F;  volatile uint T2MOD  @0x2E;  volatile BIT_CHAR T2SC0 @0x30; volatile char T2CH0H @0x31;  volatile char T2CH0L @0x32;  volatile uint T2CH0  @0x31;  volatile BIT_CHAR T2SC1 @0x33; volatile char T2CH1H @0x34; volatile char T2CH1L @0x35; volatile uint T2CH1  @0x34;///////////////////////////////////////////////    PLL///////////////////////////////////////////// volatile BIT_CHAR PCTL @0x36;////////////////////////////////////// M罶CARAS////////////////////////////////////#define PLLIE   0x80#define PLLF 0x40#define PLLON 0x20#define BCS     0x10#define PRE1    0x08#define PRE0    0x04#define VPR1    0x02#define VPR0    0x01    volatile BIT_CHAR PBWC @0x37; ////////////////////////////////////// M罶CARAS///////////////////////////////////#define AUTO    0x80#define LOCK 0x40#define ACQ   0x20 volatile BIT_CHAR PMSH @0x38;  volatile BIT_CHAR PMSL @0x39;  volatile BIT_CHAR PMRS @0x3A;////////////////////////////////////// M罶CARAS////////////////////////////////////#define VRS7    0x80#define VRS6 0x40#define VRS5 0x20#define VRS4 0x10#define VRS3    0x08#define VRS2    0x04#define VRS1    0x02#define VRS0    0x01  volatile BIT_CHAR PMDS @0x3B; ////////////////////////////////////// M罶CARAS////////////////////////////////////#define RDS3    0x08#define RDS2    0x04#define RDS1    0x02#define RDS0    0x01///////////////////////////////////// MACROS ///////////////////////////////////#define Fbus_8M PCTL.byte = VPR1; PMSL.byte = 0xD1; PMSH.byte = 0x03;PMRS.byte = (VRS7 | VRS6 | VRS4); PMDS.byte = RDS0#define PLLIntEnable PCTL.b.b7 = 1#define PLLOn PCTL.b.b5 = 1 #define PLLOff PCTL.b.b5 = 0#define PLLAuto PBWC.byte = AUTO#define PLL_Locked PBWC.b.b6 == 1#define VCO_CLOCK PCTL.b.b4 = 1///////////////////////////////////////////////   ADC///////////////////////////////////////////// volatile BIT_CHAR ADSCR @0x3C; volatile BIT_CHAR ADR @0x3D; volatile BIT_CHAR ADCLK @0x3E; ///////////////////////////////////////////////   SIM///////////////////////////////////////////// volatile BIT_CHAR SBSR   @0xfe00; volatile BIT_CHAR SRSR   @0xfe01;  volatile char SUBAR      @0xfe02; volatile BIT_CHAR SBFCR  @0xfe03;  volatile BIT_CHAR INT1   @0xfe04;  volatile BIT_CHAR INT2   @0xfe05;  volatile BIT_CHAR INT3   @0xfe06;///////////////////////////////////////////////  FLASH///////////////////////////////////////////// volatile BIT_CHAR FLCR   @0xfe08;   volatile BIT_CHAR FLBPR   @0xFF7E;///////////////////////////////////////////////  BREAK///////////////////////////////////////////// volatile uint BRK        @0xfe09;  volatile char BRKH       @0xfe09;  volatile char BRKL       @0xfe0A;  volatile BIT_CHAR BRKSCR @0xfe0B; ///////////////////////////////////////////////  LVI///////////////////////////////////////////// volatile BIT_CHAR LVISR  @0xFE0C; ////////////////////////////////////////////////  COP////////////////////////////////////////////// volatile char COPCTL @0xffff; #endif

 

Outcomes