AnsweredAssumed Answered

SPI configuration master/slave  S32K148

Question asked by Michael Kirches on Mar 28, 2019
Latest reply on Apr 2, 2019 by Michael Kirches

Hello,

 

I am trying to configure LPSPI on S32K148 both for master and slave mode. For master I use LPSPI0, slave will be LPSPI1.

 

This is my master configuration:

void SPI_master_init()
{
   // LLSPI0

   PCC->PCCn[PCC_LPSPI0_INDEX] = 0;
   // SPLLDIV2
   PCC->PCCn[PCC_LPSPI0_INDEX] = PCC_PCCn_PR(1) | PCC_PCCn_CGC(1) | PCC_PCCn_PCS(0b110);


   LPSPI0->CR = 0;
   LPSPI0->IER = 0;
   LPSPI0->DER = 0;
   LPSPI0->CFGR0 = 0;

   LPSPI0->CFGR1 = LPSPI_CFGR1_MASTER(1);
   LPSPI0->TCR = LPSPI_TCR_CPHA_MASK | LPSPI_TCR_PRESCALE(2) | LPSPI_TCR_PCS(3) |    LPSPI_TCR_FRAMESZ(15);
   LPSPI0->CCR = LPSPI_CCR_SCKPCS(4) | LPSPI_CCR_PCSSCK (9) | LPSPI_CCR_DBT(8) |    LPSPI_CCR_SCKDIV(8);
   LPSPI0->FCR = LPSPI_FCR_TXWATER(3) | LPSPI_FCR_RXWATER(0);
   LPSPI0->CR = LPSPI_CR_DBGEN(1) | LPSPI_CR_MEN(1);

}

 

This is my slave configuration

void SPI_slave_init()
{
   // LLSPI1

   PCC->PCCn[PCC_LPSPI1_INDEX] = 0;
   // SPLLDIV2
   PCC->PCCn[PCC_LPSPI1_INDEX] = PCC_PCCn_PR(1) | PCC_PCCn_CGC(1) | PCC_PCCn_PCS(0b110);


   LPSPI1->CR = 0;
   LPSPI1->IER = 0;
   LPSPI1->DER = 0;
   LPSPI1->CFGR0 = 0;

   LPSPI1->CFGR1 = LPSPI_CFGR1_MASTER(0) | LPSPI_CFGR1_AUTOPCS(1);
   LPSPI1->TCR = LPSPI_TCR_CPHA(1) | LPSPI_TCR_PRESCALE(2) | LPSPI_TCR_PCS(3) |    LPSPI_TCR_FRAMESZ(15);
   LPSPI1->FCR = LPSPI_FCR_TXWATER(3) | LPSPI_FCR_RXWATER(0);
   LPSPI1->CR = LPSPI_CR_DBGEN(1) | LPSPI_CR_MEN(1);
}

 

During debugging, I cannot see that register TCR is changing, but I can see, that data words are being transmitted to FIFOs. To be more precise on 'TCR is not changing', I had a look in the resigters view of S32 Design Studio and never saw any other value but the reset value for that register. Things are the same both for master and slave configuration.

 

My question is: How can I check, that TCR is set correctly?

 

As you can see from my code, I do not use the S32 SDK by purpose.

 

Any help resolving that issue would be appriciated.

 

Kind Regards,

 

Michael

Outcomes