3.3 Bit access

The CC-RL does not support bit access (specifying the bit position after a period for an SFR or the saddr variable) of the CA78K0R. In the CcnvCA78K0R, bit access for SFRs and the saddr variable are replaced with a type declaration of a bit field and a macro.

 

-

The type declaration and macro are output at the beginning of the file and changed to a macro call at an access point.

-

In bit access, a bit field of 8 or 16 bits is created according to the bit position. If the bit position includes 8 to 15, a bit field with b8 to b15 added is separately created for 16 bits.

 

[Examples]

-

Bit position is only 0 to 7

Before conversion

void func(void)
{
  i = var.3;
  var.5 = 0;
}

After conversion

#ifndef __BIT8
  typedef struct {
  unsigned int b0:1;
  unsigned int b1:1;
  unsigned int b2:1;
  unsigned int b3:1;
  unsigned int b4:1;
  unsigned int b5:1;
  unsigned int b6:1;
  unsigned int b7:1;
} __Bits8;
#define __BIT8(name,bit) (((volatile __near __Bits8*)&name)->b##bit)
#endif
 
void func(void)
{
  i = __BIT8(var,3);
  __BIT8(var,5) = 0;
}

 

-

Bit position includes 8 to 15

Before conversion

i = var2.10;
var2.12 = 0;

After conversion

#ifndef __BIT16
  typedef struct {
  unsigned int b0:1;
  unsigned int b1:1;
  unsigned int b2:1;
  unsigned int b3:1;
  unsigned int b4:1;
  unsigned int b5:1;
  unsigned int b6:1;
  unsigned int b7:1;
  unsigned int b8:1;
  unsigned int b9:1;
  unsigned int b10:1;
  unsigned int b11:1;
  unsigned int b12:1;
  unsigned int b13:1;
  unsigned int b14:1;
  unsigned int b15:1;
} __Bits16;
#define __BIT16(name,bit) (((volatile __near __Bits16*)&name)->b##bit)
#endif
 
void func(void)
{
  i = __BIT16(var2,10);
  __BIT16(var2,12) = 0;
}