One SPI module and two UARTs ...

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

One SPI module and two UARTs ...

Jump to solution
525 Views
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

Labels (1)
0 Kudos
1 Solution
346 Views
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

View solution in original post

0 Kudos
2 Replies
347 Views
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 Kudos
346 Views
peterfurey
Contributor IV

Thank you Alice!

0 Kudos