switching SPI clock frequency for two slaves

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

cross mob
NXTY_hayashi
Level 5
Level 5
Distributor - NEXTY (Japan)
25 solutions authored 50 replies posted 25 likes received
Dear,

our target design has one SPI master in XMC4500 connected to two SPI slaves. The frame length of one slave is 16bit, the other is 24bit.
I think that DAVE generator cannot support different frame length for one SPI master.
I'd like to implement it by user coding in application level without DAVE generator.
If you have recommended method, please let me know.

Regards,
Kazunari Hayashi
TOMEN Electronics Corp.
0 Likes
2 Replies
chismo
Employee
Employee
First like received
Hello Kazunari,

Since both 16-bit and 24-bit frames are multiples of an 8-bit word, one way is to:
- configure frame length in DAVE APP to infinite frame, i.e. 64; word length remains at 8
- disable frame end mode (this means that slave select is automatically deasserted when there is no more data received in the buffer for transmission)
- send 16-bit data to slave_0 by defining data count as 2
- switch slave select signal to slave_1 accordingly
- send 24-bit data to slave_1 by defining data count as 3

Another way is to insert a code to change the frame length, for example using XMC Lib (add #include "xmc_usic.h"):

XMC_USIC_CH_SetFrameLength(SPI_MASTER_0.channel, 24);


Of course if you would like to do away with DAVE generated code, this is also possible.

Regards,
Min Wei
0 Likes
NXTY_hayashi
Level 5
Level 5
Distributor - NEXTY (Japan)
25 solutions authored 50 replies posted 25 likes received
Min-san

the answer has been very helpful for me.
Please close this thread.

Thanks.
0 Likes