half duplex SPI communication on XMC1400

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

cross mob
ziad-shaarawy
Level 1
Level 1
10 sign-ins 5 questions asked 5 sign-ins

I'm attempting to utilize half-duplex SPI communication with an XMC1400 acting as the master. I've configured the SPI pins as push-pull using DAVE apps, and here's the corresponding code:

XMC_GPIO_SetMode(MOSI_Port, MOSI_Pin, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT9); SPI_MASTER_Transmit(&SPI_MASTER_0, arr, sizeof(arr));
while (SPI_MASTER_IsTxBusy(&SPI_MASTER_0));
for(int i = 0; i < 20; i++);
XMC_GPIO_SetMode(MOSI_Port, MOSI_Pin, XMC_GPIO_MODE_INPUT_TRISTATE);
SPI_MASTER_Receive(&SPI_MASTER_0, &Read_Data, 1);
while (SPI_MASTER_IsRxBusy(&SPI_MASTER_0));



Although the data is transmitted correctly from the slave and seen on the data line using oscilloscope, the value returned by the SPI_MASTER_Receive function, Read_Data, always consists of all ones.
As a temporary workaround, I've configured the XMC1400 as full-duplex and connected the MOSI to the MISO pin together.

Now, the question is whether the SPI_MASTER_Receive function can function properly when the XMC1400 is configured as a half-duplex SPI master.




0 Likes
4 Replies
Pradeep_PN
Moderator
Moderator
Moderator
250 sign-ins 100 solutions authored 25 likes received

Hi @ziad-shaarawy ,

I am trying to create a small working code example on SPI Half Duplex, I am also facing some issues at my end, Please give me some time as i am working on it and will share it with you ass soon as possible.

Best Regards
Pradeep.

0 Likes
Pradeep_PN
Moderator
Moderator
Moderator
250 sign-ins 100 solutions authored 25 likes received

Hi @ziad-shaarawy .

Please use SPI_CONFIG APP.

In the APP Help of the SPI_CONFIG, in the usage section they have implemented a small example on SPI Half Duplex though it is on  XMC 4500 Relax KIT , It will help you.

Add the SPI_CONFIG APP -> Right click on the APP -> APP Help -> usage ->2nd example.

Best Regards
Pradeep.

0 Likes

Hi @Pradeep_PN 

Could you please explain the difference between SPI_CONFIG APP and SPI_MASTER APP? I'm interested in knowing which one would be appropriate for using the XMC kit as a master.

Also, I'm wondering if it's possible to configure the kit as full duplex using the SPI_CONFIG App and later switch it to half duplex during program execution.

0 Likes
Pradeep_PN
Moderator
Moderator
Moderator
250 sign-ins 100 solutions authored 25 likes received

Hi @ziad-shaarawy ,

SPI_MASTER APP : Configures a USIC channel to perform transfer & receive operations through SPI protocol in Master mode

SPI_CONFIG APP : Configures the USIC peripheral to work for the SPI protocol wither in Master mode or Slave mode it can be configured.

Apart of this there won't be much difference between this apps everything will be similar with some minor changes in available app parameters.

There is already an SPI Half Duplex example in the app usage of SPI_CONFIG app so i thought it would be helpful for you.

It is possible to change SPI_CONFIG APP from Full duplex to Half duplex but when it was change you need to initialize the app again.

Best Regards
Pradeep.

0 Likes