One SPI module and two UARTs ...

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

One SPI module and two UARTs ...

跳至解决方案
774 次查看
peterfurey
Contributor IV

Hi,

I'm using a FRDM-K64F board with a few custom extension boards for my development platform. Currently, I'm trying to configure one DSPI module (master only configuration) to interface with two serial devices using Processor Expert. I have two chip select configurations, PCS0 and PCS1, both of which have "active low" polarity. The DSPI module is initially configured to use PCS0, which goes high after the DSPI_DRV_MasterInit() call. However, I don't see a mechanism to initialize the PCS1 pin to go high as well within the PE interface, or by any of the DSPI_DRV_xxx() or DSPI_HAL_xxx() functions. The only workaround I see is to temporarily change the PCS1 pin to a GPIO pin and pull it high. Since PCS0 and PCS1 are both "active low" they both need to be high in the inactive state for this interface to work. What am I missing? I strongly suspect there is a better way to do this.

Thanks for any suggestions.

Peter

标签 (1)
0 项奖励
回复
1 解答
595 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Peter,


Does the function of "DSPI_HAL_SetPcsPolarityMode()" can meet your requirement  ?

/*FUNCTION**********************************************************************

*

* Function Name : DSPI_HAL_SetPcsPolarityMode

* Description  : Configure DSPI peripheral chip select polarity.

* This function will take in the desired peripheral chip select (PCS) and it's

* corresponding desired polarity and will configure the PCS signal to operate with the

* desired characteristic.

*

*END**************************************************************************/

void DSPI_HAL_SetPcsPolarityMode(SPI_Type * base, dspi_which_pcs_config_t pcs,

                                 dspi_pcs_polarity_config_t activeLowOrHigh)

{

    uint32_t temp;

    temp = SPI_RD_MCR_PCSIS(base);

    if (activeLowOrHigh == kDspiPcs_ActiveLow)

    {

        temp |= pcs;

    }

    else  /* kDspiPcsPolarity_ActiveHigh */

    {

        temp &= ~(unsigned)pcs;

    }

    SPI_BWR_MCR_PCSIS(base, temp);

}

Hope it helps

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

Have a great day,
Alice Yang

在原帖中查看解决方案

0 项奖励
回复
2 回复数
596 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Peter,


Does the function of "DSPI_HAL_SetPcsPolarityMode()" can meet your requirement  ?

/*FUNCTION**********************************************************************

*

* Function Name : DSPI_HAL_SetPcsPolarityMode

* Description  : Configure DSPI peripheral chip select polarity.

* This function will take in the desired peripheral chip select (PCS) and it's

* corresponding desired polarity and will configure the PCS signal to operate with the

* desired characteristic.

*

*END**************************************************************************/

void DSPI_HAL_SetPcsPolarityMode(SPI_Type * base, dspi_which_pcs_config_t pcs,

                                 dspi_pcs_polarity_config_t activeLowOrHigh)

{

    uint32_t temp;

    temp = SPI_RD_MCR_PCSIS(base);

    if (activeLowOrHigh == kDspiPcs_ActiveLow)

    {

        temp |= pcs;

    }

    else  /* kDspiPcsPolarity_ActiveHigh */

    {

        temp &= ~(unsigned)pcs;

    }

    SPI_BWR_MCR_PCSIS(base, temp);

}

Hope it helps

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

Have a great day,
Alice Yang

0 项奖励
回复
595 次查看
peterfurey
Contributor IV

Thank you Alice!

0 项奖励
回复