REGISTER ACCESS IN MCUXPRESSO

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

REGISTER ACCESS IN MCUXPRESSO

ソリューションへジャンプ
2,233件の閲覧回数
maratheapurv
Contributor III

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.

0 件の賞賛
返信
1 解決策
2,087件の閲覧回数
jingpan
NXP TechSupport
NXP TechSupport

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

元の投稿で解決策を見る

1 返信
2,088件の閲覧回数
jingpan
NXP TechSupport
NXP TechSupport

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