K64F GPIO API

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

K64F GPIO API

1,348 Views
shauldorf
Contributor V

I'm trying to migrate my old project implemented in KDS3.2 (with PE) to MCUXpresso.

Using Bits1_PutVal(Bits1_Ptr…… instructions I have delayed "Low" sequence between four Outputs.

As a test case I prepared small direct register access program which is working well

While(1)

{

GPIOD->PDOR = 0x1;

DELAY;

GPIOD->PDOR = 0x2;

DELAY;

GPIOD->PDOR = 0x4;

DELAY;

GPIOD->PDOR = 0x8;

DELAY;

}

 

When I tried to implement the above using API the only solution that I found is adding additional GPIO_ClearPinsOutput() which clears all outputs

While(1)

{

GPIO_SetPinsOutput(GPIOD, 0x1);

DELAY;

GPIO_ClearPinsOutput(GPIOD, 0x1);

GPIO_SetPinsOutput(GPIOD, 0x2);

DELAY;

GPIO_ClearPinsOutput(GPIOD, 0x2);

GPIO_SetPinsOutput(GPIOD, 0x4);

DELAY;

GPIO_ClearPinsOutput(GPIOD, 0x4);

GPIO_SetPinsOutput(GPIOD, 0x8);

DELAY;

GPIO_ClearPinsOutput(GPIOD, 0x8);

}

 

GPIO_ClearPinsOutput clears all outputs for about 0.5 usec which is not acceptable.

 

The question is if I missed something in fsl_gpio.h   API?

Thanks

Shaul

0 Kudos
5 Replies

1,119 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Shaul,

- Sorry I can't understand your problem clearly, I checked your code ,

set one pin to 1, after delay , then clear it to 0,  is this what you want ?

- About "GPIO_ClearPinsOutput clears all outputs for about 0.5 usec ",  so , what do you  think is right ?

BR

Alice

0 Kudos

1,119 Views
shauldorf
Contributor V

Hello Alice

Using Xpresso I have tested two alternatives

1. Direct register access (no SDK API)

In this case I have a sequence of GPIOD->PDOR instructions.

Using logic analyzer the resulted waveforms looks O.K there is no "low" gap in transition between the states.

2. Using API (fsl_gpio.h and fsl_gpio.c)

In my solution I am using a sequence of GPIO_SetPinsOutput(), DELAY and GPIO_ClearPinsOutput().

Here using GPIO_ClearPinsOutput() generates a gap of 0.5 usec between transmission from one state to another and in my case is unaceptable.

I my original old project I used KDS3.2 + KSDK 1.3 (with PE).

In that case I used Bits1_PutVal(Bits1_Ptr……) API instructions.

I checked and I didn't fined something equivalent in MCUXpresso SDK API.

And for this reason I'm using direct register access.

The question is if I missed something in a new API when I tried to use GPIO_WritePinOutput() or GPIO_PinWrite() thinking that they are equivalent to Bits1_PutVal( ).

Thanks

Shaul

0 Kudos

1,119 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello shaul,

Thanks for your description, I check the code , there is no difference between the two functions,

all configure the two regsiters "PCOR" and "PSOR"

In Processor Expert of KDS:

pastedImage_1.png

In SDK:

pastedImage_2.png

BR

Alice

0 Kudos

1,119 Views
shauldorf
Contributor V

Hello Alice

I have slightly different "Bits1_PutVal()" version

Based on my version, I prepared my function equivalent to Bits1_PutVal().

while(1)

{

Bits1_PutVal(Data[k % 8]);

k++;

DELAY

}

/***************************************************************

  • Functions Code ****************************************************************/

void Bits1_PutVal(uint32_t Val){

RawVal = Val & Bits1_PORT_VALID_VALUE_MASK; /* Mask output value */

// PDI_Val = GPIO_PinRead(GPIOD, 0);

PDI_Val = GPIOD->PDIR;

TogVal = PDI_Val ^ RawVal;

GPIO_PortToggle(GPIOD, TogVal);

}

The concept is working fine, but I have a problem with the "GPIO_PinRead()" function.

Probably the reason is that I don't know how to use it case case that I want to read the whole port and not a single pin.

I bypassed this with "GPIO->PDIR".

Can you please provide a solution how to use "GPIO_PinRead()" instead of GPIO->PDIR

Thanks

Shaul

0 Kudos

1,119 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Shaul ,

Sorry there isn't a SDK API to read whole port , you can directly read register GPIO->PDIR .

BR

Alice

0 Kudos