Julien Gingras

Code writing question

Discussion created by Julien Gingras on Aug 20, 2011
Latest reply on Aug 21, 2011 by Julien Gingras


Im working with cw 6.3 and a JM60 mcu


Im asking myself how to write a part of my app

I have 10 pin used as output

I will use them depending on the communication with the pc (setting or resetting them)

hey are on different port


I wish to have an array that let me change only one 1 something like

Output[4] = 0   //Reset output 4

using it the same way as PTBD_PTBD6 = 0;


And I do have this in the header file:

/*** PTBD - Port B Data Register; 0x00000002 ***/
typedef union {
  byte Byte;
  struct {
    byte PTBD0       :1;                                       /* Port B Data Register Bit 0 */
    byte PTBD1       :1;                                       /* Port B Data Register Bit 1 */
    byte PTBD2       :1;                                       /* Port B Data Register Bit 2 */
    byte PTBD3       :1;                                       /* Port B Data Register Bit 3 */
    byte PTBD4       :1;                                       /* Port B Data Register Bit 4 */
    byte PTBD5       :1;                                       /* Port B Data Register Bit 5 */
    byte PTBD6       :1;                                       /* Port B Data Register Bit 6 */
    byte PTBD7       :1;                                       /* Port B Data Register Bit 7 */
  } Bits;
extern volatile PTBDSTR _PTBD @0x00000002;
#define PTBD                            _PTBD.Byte
#define PTBD_PTBD0                      _PTBD.Bits.PTBD0
#define PTBD_PTBD1                      _PTBD.Bits.PTBD1
#define PTBD_PTBD2                      _PTBD.Bits.PTBD2
#define PTBD_PTBD3                      _PTBD.Bits.PTBD3
#define PTBD_PTBD4                      _PTBD.Bits.PTBD4
#define PTBD_PTBD5                      _PTBD.Bits.PTBD5
#define PTBD_PTBD6                      _PTBD.Bits.PTBD6
#define PTBD_PTBD7                      _PTBD.Bits.PTBD7


is there a way to create an arrawy from _PTBD.Bits.PTBD3???? what type should it be?



this question is probably more related to C than to codewarrior itself but I have no idea on how to do it