SPI Slaves Need Different Configurations

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User22005
Level 1
Level 1
5 replies posted 5 questions asked First reply posted
I have a case where each SPI Slave needs a different configuration. E.g. MSB vs. LSB shifted out first, word and frame length different. I am using the SPI_MASTER APP.

I have tried using the code below to reconfigure the SPI Master on the fly before I send out data each time. It seems to have no effect however. The original configuration I set using the APP configuration UI seems to still being used. I have tried it with and without SPI_MASTER_Init and XMC_SPI_CH_Start.

How is the case of differing Slaves supposed to be handled?


SPI_MASTER_Init (&SPI_MASTER_DISPLAY);
XMC_SPI_CH_SetBitOrderMsbFirst (&SPI_MASTER_DISPLAY);
XMC_SPI_CH_SetWordLength (&SPI_MASTER_DISPLAY, (uint8_t) 8);
XMC_SPI_CH_SetFrameLength (&SPI_MASTER_DISPLAY, (uint8_t) 8);

XMC_SPI_CH_Start (&SPI_MASTER_DISPLAY); // needed for new config to have effect ??


SPI_MASTER_DisableSlaveSelectSignal (&SPI_MASTER_DISPLAY); // high for RTC
SPI_MASTER_SS_SIGNAL_0); // low for display

const uint16_t writeSeconds = 0x45;
const uint16_t readSeconds = 0x00;

uint8_t SendDataWrite [2] = {0 | 0x80, writeSeconds};

if (SPI_MASTER_Transmit (&SPI_MASTER_DISPLAY, SendDataWrite, 2) == SPI_MASTER_STATUS_SUCCESS)
{
while (SPI_MASTER_DISPLAY.runtime->tx_busy)
{
}
}
0 Likes
1 Solution
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted
Hi @ZacharyInDallas,

Did you get a chance to look at the XMC Lib Implementation for full duplex SPI section(Page No 41) in the application note on USIC module here: https://www.infineon.com/dgdl/Infineon-USIC-XMC1000_XMC4000-AP32303-AN-v01_00-EN.pdf?fileId=5546d462... ?
Here you can check the code implementation to take it as a reference, to ensure that the flow of your program is correct. You can also check the code example "SPI-TRANSMIT" under XMC lib for this.

As per my understanding, if you change the configuration each time for SPI slave, you need to configure the SPI channel and start it again for newer configuration. Meanwhile, if you need to switch
between the connection for different spi-slaves, you need to enable the slave select(SS) line by changing it to high for that slave connection.

Please let us know if this helps or in case of any further query.

Best Regards,
Aashita

View solution in original post

0 Likes
1 Reply
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted
Hi @ZacharyInDallas,

Did you get a chance to look at the XMC Lib Implementation for full duplex SPI section(Page No 41) in the application note on USIC module here: https://www.infineon.com/dgdl/Infineon-USIC-XMC1000_XMC4000-AP32303-AN-v01_00-EN.pdf?fileId=5546d462... ?
Here you can check the code implementation to take it as a reference, to ensure that the flow of your program is correct. You can also check the code example "SPI-TRANSMIT" under XMC lib for this.

As per my understanding, if you change the configuration each time for SPI slave, you need to configure the SPI channel and start it again for newer configuration. Meanwhile, if you need to switch
between the connection for different spi-slaves, you need to enable the slave select(SS) line by changing it to high for that slave connection.

Please let us know if this helps or in case of any further query.

Best Regards,
Aashita
0 Likes