Pot. problem in KSDK, fsl_gpio_driver.c, GPIO_DRV_OutputPinInit()

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

Pot. problem in KSDK, fsl_gpio_driver.c, GPIO_DRV_OutputPinInit()

1,382件の閲覧回数
jum
Contributor I

Hi, found a problem in

 

/*FUNCTION**********************************************************************
*
* Function Name : GPIO_DRV_OutputPinInit
* Description   : Initialize one GPIO output pin used by board.
*
*END**************************************************************************/
void GPIO_DRV_OutputPinInit(const gpio_output_pin_user_config_t *outputPin)
{
    /* Get actual port and pin number.*/
    uint32_t port = GPIO_EXTRACT_PORT(outputPin->pinName);
    uint32_t pin = GPIO_EXTRACT_PIN(outputPin->pinName);
    GPIO_Type * gpioBase = g_gpioBase[port];
    PORT_Type * portBase = g_portBase[port];

    /* Un-gate port clock*/
    CLOCK_SYS_EnablePortClock(port);

    /* Set current pin as gpio.*/
    PORT_HAL_SetMuxMode(portBase, pin, kPortMuxAsGpio);

    //--- changed sequence (WritePinOutput->SetPinDir) by JM 2015.10.15
    GPIO_HAL_WritePinOutput(gpioBase, pin, outputPin->config.outputLogic);

//**** This will set output to "0" and therefore cause a glicth if configured to "1" ****//
//****   
//****    /* Set current pin as digital output.*/
//****    GPIO_HAL_SetPinDir(gpioBase, pin, kGpioDigitalOutput);

    /* Configure GPIO output features. */
    GPIO_HAL_WritePinOutput(gpioBase, pin, outputPin->config.outputLogic);

    #if FSL_FEATURE_PORT_HAS_SLEW_RATE
    PORT_HAL_SetSlewRateMode(portBase, pin, outputPin->config.slewRate);
    #endif
    #if FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH
    PORT_HAL_SetDriveStrengthMode(portBase, pin, outputPin->config.driveStrength);
    #endif
    #if FSL_FEATURE_PORT_HAS_OPEN_DRAIN
    PORT_HAL_SetOpenDrainCmd(portBase, pin, outputPin->config.isOpenDrainEnabled);
    #endif

    //**** This will finally set output pin - with programmed characteristics - to configured value ****//
    //
    GPIO_HAL_SetPinDir(gpioBase, pin, kGpioDigitalOutput);

}

 

Setting pin direction to output too early will cause a glitch to "0" if pin was configured to "1".
Also will set output not with programmed characteristics.
So, setting direction to output should be done at the end of this function, I think?
Best regards
Juergen

ラベル(1)
0 件の賞賛
返信
1 返信

1,066件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi Juergen,

Good observation and I think re-ordering the configuration could eliminate the glitch.

I have submitted this post to our KSDK development team for review.

Thank you for posting.

Regards,

David

Reference:

Issue KPSDK-7318 - fls_gpio_driver.c output pin enabling has glitch on pin has been successfully created.

0 件の賞賛
返信