Hello,
While programming the FRDM-KV31F board with the MKV31f512vll12 controller using MCUXPRESSO
I need to check if the OSCINIT0 bit in the MCG_S (i.e. Multiplex Clock Generation Status) reg is set. Now I am trying to use the and bitwise operator for the same is there any way I can directly access this bit? I know I can access the Status register via a dot operator as it is a member of the MCG structure, but still is there any way I can directly access the specified bit?
Regards,
Apurv.
已解决! 转到解答。
Hi Apurv,
KV31 hardware doesn't support bit access. You can simulate this function by software. For example,
struct GPIO_BITS {
uint32_t IO0:1;
uint32_t IO1:1;
uint32_t IO2:1;
uint32_t IO3:1;
uint32_t IO4:1;
uint32_t IO5:1;
uint32_t IO6:1;
uint32_t IO7:1;
uint32_t RSVD:8; // 31:8 Reserved
};
union GPIO_MASK_REG {
uint32_t all;
struct GPIO_BITS bit;
};
typedef struct
{
__IO union GPIO_MASK_REG MASK;
....
}GPIO_TypeDef;
#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE )
Thus you can access a bit by
GPIOA->MASK.bit.IO7 = 1;
Regards,
Jing
Hi Apurv,
KV31 hardware doesn't support bit access. You can simulate this function by software. For example,
struct GPIO_BITS {
uint32_t IO0:1;
uint32_t IO1:1;
uint32_t IO2:1;
uint32_t IO3:1;
uint32_t IO4:1;
uint32_t IO5:1;
uint32_t IO6:1;
uint32_t IO7:1;
uint32_t RSVD:8; // 31:8 Reserved
};
union GPIO_MASK_REG {
uint32_t all;
struct GPIO_BITS bit;
};
typedef struct
{
__IO union GPIO_MASK_REG MASK;
....
}GPIO_TypeDef;
#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE )
Thus you can access a bit by
GPIOA->MASK.bit.IO7 = 1;
Regards,
Jing