could SPI in S32K144 use PCS[0-3] simultaneously?

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

could SPI in S32K144 use PCS[0-3] simultaneously?

1,157 Views
jinhui_wu
Contributor III

when I use spi module driver one slaver,it works,the configuration as below:

#define SPI0_0 0

const lpspi_master_config_t lpspiCom1_MasterConfig0 = {

  .bitsPerSec = 500000U,

  .whichPcs = LPSPI_PCS0,

  .pcsPolarity = LPSPI_ACTIVE_LOW,

  .isPcsContinuous = true,

  .bitcount = 8U,

  .lpspiSrcClk = 8000000U,

  .clkPhase = LPSPI_CLOCK_PHASE_2ND_EDGE,

  .clkPolarity = LPSPI_SCK_ACTIVE_LOW,

  .lsbFirst = false,

  .transferType = LPSPI_USING_INTERRUPTS,

  .rxDMAChannel = 255,

  .txDMAChannel = 255,

};

then i call it in the main(),transfer is ok. 

int main(void)

{

      lpspi_state_t masterState;

     

CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);

      CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);

 

      PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

      LPSPI_DRV_MasterInit(SPI0_0, &masterState, &lpspiCom1_MasterConfig0); 

while(1)

      {

           delay(100);

           LPSPI_DRV_MasterTransferBlocking(SPI0_0,DataSend,DataRece,1, TIMEOUT); 

      }

}

 

 however,now,I want use one SPI module to drive three slavers,the configuration as below:

const lpspi_master_config_t lpspiCom3_MasterConfig0 = {

  .bitsPerSec = 500000U,

  .whichPcs = LPSPI_PCS0,

  .pcsPolarity = LPSPI_ACTIVE_LOW,

  .isPcsContinuous = true,

  .bitcount = 8U,

  .lpspiSrcClk = 8000000U,

  .clkPhase = LPSPI_CLOCK_PHASE_2ND_EDGE,

  .clkPolarity = LPSPI_SCK_ACTIVE_LOW,

  .lsbFirst = false,

  .transferType = LPSPI_USING_INTERRUPTS,

  .rxDMAChannel = 255,

  .txDMAChannel = 255,

};

 

const lpspi_master_config_t lpspiCom3_MasterConfig1 = {

  .bitsPerSec = 500000U,

  .whichPcs = LPSPI_PCS1,

  .pcsPolarity = LPSPI_ACTIVE_LOW,

  .isPcsContinuous = true,

  .bitcount = 8U,

  .lpspiSrcClk = 8000000U,

  .clkPhase = LPSPI_CLOCK_PHASE_2ND_EDGE,

  .clkPolarity = LPSPI_SCK_ACTIVE_LOW,

  .lsbFirst = false,

  .transferType = LPSPI_USING_INTERRUPTS,

  .rxDMAChannel = 255,

  .txDMAChannel = 255,

};

 

const lpspi_master_config_t lpspiCom3_MasterConfig2 = {

  .bitsPerSec = 500000U,

  .whichPcs = LPSPI_PCS2,

  .pcsPolarity = LPSPI_ACTIVE_LOW,

  .isPcsContinuous = true,

  .bitcount = 8U,

  .lpspiSrcClk = 8000000U,

  .clkPhase = LPSPI_CLOCK_PHASE_2ND_EDGE,

  .clkPolarity = LPSPI_SCK_ACTIVE_LOW,

  .lsbFirst = false,

  .transferType = LPSPI_USING_INTERRUPTS,

  .rxDMAChannel = 255,

  .txDMAChannel = 255,

};

then,in main();call init and trasfer function,the result is that SPI transfer doesn't work.

int main(void)

{

      lpspi_state_t masterState;

     

CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);

      CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);

 

      PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

     

LPSPI_DRV_MasterInit(SPI2_0, &masterState, &lpspiCom3_MasterConfig0);

      LPSPI_DRV_MasterInit(SPI2_1, &masterState, &lpspiCom3_MasterConfig1); 

      LPSPI_DRV_MasterInit(SPI2_2, &masterState, &lpspiCom3_MasterConfig2); 

while(1)

      {

           delay(100);

           LPSPI_DRV_MasterTransferBlocking(SPI2_0,DataSend,DataRece,1, TIMEOUT);

           LPSPI_DRV_MasterTransferBlocking(SPI2_1,DataSend,DataRece,1, TIMEOUT); 

           LPSPI_DRV_MasterTransferBlocking(SPI2_2,DataSend,DataRece,1, TIMEOUT); 

      }

}

is my yellow code right?

Labels (1)
Tags (1)
0 Kudos
1 Reply

765 Views
PetrS
NXP TechSupport
NXP TechSupport