XMC4800 Relax Kit SPI SCLK configuration

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

cross mob
User11779
Level 1
Level 1
Hi all,

I'm using an XMC4800 relax kit as a "midware" which on one hand reads from a sensor via SPI, on the other hand sends out the data through EtherCAT.

Problem here is, with EtherCAT taking up a lot of pins, theoretically I can only use the following two SPI modules:

2363.attach

The rest are either used by EtherCAT or not populated.

While P3.7-P3.9 worked perfectly, P0.13 did not seem to produce any clock signal when probed in oscilloscope. It's worth noting that I had to probe P0.13 through Arduino pins since it's not populated in X1 and X2.

From XMC4700_XMC4800_Relax_Kit_Series_UM_v01_00_EN.pdf page 12, (shown below) I saw that P0.13 shared the same Arduino pin with P14.5, and is marked with I2C_SCL. So is it that this pin can only be used as an I2C SCL, or some other config is needed to prob P0.13 on this pin?
2362.attach


Any help would be appreciated!
0 Likes
4 Replies
DRubeša
Employee
Employee
First solution authored First like received
Hi,

I took a quick look by making DAVE CE project using the pins that you mention and observing the code which is generated by the DAVE. I don´t know are you using DAVE APPs, XMCLib or direct register access, however you should be able to decipher how you need to set the GPIO pins to suit your need.

MISO pin as 3.14 is defined as:

const SPI_MASTER_GPIO_t SPI_MASTER_0_MISO = 
{
.port = (XMC_GPIO_PORT_t *)PORT3_BASE,
.pin = (uint8_t)14
};

SPI_MASTER_GPIO_CONFIG_t SPI_MASTER_0_MISO_Config =
{
.port_config =
{
.mode = XMC_GPIO_MODE_INPUT_TRISTATE,
},
};


and then in the initalization function you also need to initialize the GPIO pin as SPI MISO by:
XMC_GPIO_Init((XMC_GPIO_PORT_t *)PORT3_BASE, (uint8_t)14, &SPI_MASTER_0_MISO_Config.port_config);


also be sure to add the configuration of the input data line:
  
/* Configure the data input line selected */
XMC_SPI_CH_SetInputSource(XMC_SPI1_CH1, XMC_SPI_CH_INPUT_DIN0, (uint8_t)SPI_MASTER_INPUT_B);


Similar, you define the MOSI pin as 3.15 as:
/* Data Transmit pin from SPI_MASTER */
const SPI_MASTER_GPIO_t SPI_MASTER_0_MOSI =
{
.port = (XMC_GPIO_PORT_t *)PORT3_BASE,
.pin = (uint8_t)15
};

SPI_MASTER_GPIO_CONFIG_t SPI_MASTER_0_MOSI_Config =
{
.port_config =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2,
.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH,
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE
},
.hw_control = XMC_GPIO_HWCTRL_DISABLED
};


and then in the initialization code:
  
/* Configure the output pin properties */
XMC_GPIO_Init((XMC_GPIO_PORT_t *)PORT3_BASE, (uint8_t)15, &SPI_MASTER_0_MOSI_Config.port_config);


Finally, pin 0.13 is defined as SCKL by:

const SPI_MASTER_GPIO_t SPI_MASTER_0_SCLKOUT = 
{
.port = (XMC_GPIO_PORT_t *)PORT0_BASE,
.pin = (uint8_t)13
};

const SPI_MASTER_GPIO_CONFIG_t SPI_MASTER_0_SCLKOUT_Config =
{
.port_config =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2,
.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH,
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE
}
};


and then you initialize the pin by calling:

  
/* Initialize SPI SCLK out pin */
XMC_GPIO_Init((XMC_GPIO_PORT_t *)PORT0_BASE, (uint8_t)13, &SPI_MASTER_0_SCLKOUT_Config.port_config);


This is exact code copied from the generated output of the SPI_MASTER APP build for the XMC4800 microcontroller. Take a look and see if it´s working as intended while I don´t see any issue while it should work as you intended.

Let me know if you need additional support and best regards,
Deni
0 Likes
User14803
Level 1
Level 1
lichuanzheng wrote:
Hi all,

I'm using an XMC4800 relax kit as a "midware" which on one hand reads from a sensor via SPI, on the other hand sends out the data through EtherCAT.

Problem here is, with EtherCAT taking up a lot of pins, theoretically I can only use the following two SPI modules:

1072.attach

The rest are either used by EtherCAT or not populated.

While P3.7-P3.9 worked perfectly, P0.13 did not seem to produce any clock signal when probed in oscilloscope. It's worth noting that I had to probe P0.13 through Arduino pins since it's not populated in X1 and X2.

From XMC4700_XMC4800_Relax_Kit_Series_UM_v01_00_EN.pdf page 12, (shown below) I saw that P0.13 shared the same Arduino pin with P14.5, and is marked with I2C_SCL. So is it that this pin can only be used as an I2C SCL, or some other config is needed to prob P0.13 on this pin?
2362.attach


Any help would be appreciated!


Hi,
I add the spi slave app,but it doesn't have the pin p3.14 p3.13 p3.7 p3.8. Of course these pins are not occupied, but I can't choose from the spi slave app, I want to know if you have a spi app?
0 Likes
DRubeša
Employee
Employee
First solution authored First like received
Hi,

I don´t know which XMC device are you using, but this works in general:
Right click on the SPI_SLAVE APP and select "Manual Pin Allocator". Now you will get the list of all available pins for each SPI function for your device.

Best regards,
Deni
0 Likes
User14803
Level 1
Level 1
DRube�a wrote:
Hi,

I don�t know which XMC device are you using, but this works in general:
Right click on the SPI_SLAVE APP and select "Manual Pin Allocator". Now you will get the list of all available pins for each SPI function for your device.

Best regards,
Deni


Hi Deni,
Thanks for ypur reply!
Now,I want to use a xmc4800 (EtherCAT + SPI SLAVE) as a transit device to receive data from another xmc4800 (spi master) and send the data through Ethercat.
But I have a problem with receiving data from spi slave.
Any help will be appreciated!
0 Likes