Is there a GPIO component wider than 1 bit?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there a GPIO component wider than 1 bit?

412 Views
kena1
Contributor II

I want to write several bits at once.

Example:

void modifyLower5Bits(uint32_t value)

{

    GPIOA_PDOR = (GPIOA_PDOR & ~0x1f) | (value & 0x1f);

}

 

This seems like such a basic function and I cannot find a component in Processor Export that can handle more than one bit at a time.

Is the solution to simply do direct port access as shown above, or is there a component method?

I would rather not write:

 

void modifyLower5Bits(uint32_t value)

{

    GPIO_DRV_WritePinOutput(Port_A0, value & 1);

    value >>= 1;

    GPIO_DRV_WritePinOutput(Port_A1, value & 1);

    value >>= 1;

    GPIO_DRV_WritePinOutput(Port_A2, value & 1);

    value >>= 1;

    GPIO_DRV_WritePinOutput(Port_A3, value & 1);

    value >>= 1;

    GPIO_DRV_WritePinOutput(Port_A4, value & 1);

}

 

 

Is this forum the correct forum to ask this question?

Labels (1)
0 Kudos
1 Reply

318 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Ken,

In SDK, there isn't the function can set more than one bit . I recommend you directly use the method you mentioned .

And in the initialization , if you want configure some gpio, you can configure here :

pastedImage_0.png

then after generate code , you can see the code here :

pastedImage_1.png

Hope it helps

Alice

0 Kudos