Message Edited by eos33 on 06-05-2006 09:15 PM
Hello,
If you were assembly programming, there are instructions to do bit manipulations directly, however I assume you will be working in C where the situation is a little more complex.
Firstly, if you are referencing any of the defined I/O registers for the device, CW has already done the preparation (within the file MC9S08QG8.h), so the following would work -
#define LED6 PTBD_PTBD6
#define LED7 PTBD_PTBD7
LED6 = 1;
LED7 = 0;
if (LED6 == 1) {
}
etc.
If you are creating your own status register in RAM, you will need to do the setup yourself. The following example uses a similar method to the CW header file.
/* LDSTAT - LED Status register */
typedef union {
byte Byte;
struct {
byte :1;
byte :1;
byte :1;
byte :1;
byte :1;
byte :1;
byte LED6 :1;
byte LED7 :1;
} Bits;
} LDSTATSTR;
LDSTATSTR _LEDSTAT;
#define LDSTAT _LDSTAT.Byte
#define LED6 _LDSTAT.Bits.LED6
#define LED7 _LDSTAT.Bits.LED7
Regards,
Mac