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

XMC™ Forum Discussions

User18007
Level 1
Level 1
First reply posted First question asked
I'm trying to interface external flash via SPI communication with XMC4800,.
I'm using U1C1
P0_12_CE, P0_13_SCLK, P3_15_MOSI, P3_15_MISO.

Doing just simple full duplex communication as SPI master. and trying to write & read data on external flash(SST26VF064B).
Few days ago I received a code but that was quard SPI and also PIN was different. I did some changes accordingly but it's not working clock is not coming. Please help me and do the changes in main.c (attachment) file according to the given data and reply.

In case of any problem please reply.

Plaese reply @ infineon
0 Likes
5 Replies
User18007
Level 1
Level 1
First reply posted First question asked
@Infineon Please support me in solving this problem.
0 Likes
User18007
Level 1
Level 1
First reply posted First question asked
@Infineon I have done some changes in main.c file (which you have send ) but the issue is i thing there is some error in configuring the SPI PINs. Please update the given main fine according to he pin descriptions.

Some changes I did in the file you gave me according to my hardware, please very this (I guess there is doubt is in MISO):
void SPI_init(){

XMC_SPI_CH_Init(XMC_SPI1_CH1, &spi_config);
XMC_SPI_CH_SetInputSource(XMC_SPI1_CH1, XMC_SPI_CH_INPUT_DIN0, USIC1_C1_DX0_DOUT0);
XMC_SPI_CH_SetInputSource(XMC_SPI1_CH1, XMC_SPI_CH_INPUT_DIN1, USIC1_C1_DX3_DOUT1);
XMC_SPI_CH_SetInputSource(XMC_SPI1_CH1, XMC_SPI_CH_INPUT_DIN2, USIC1_C1_DX4_DOUT2);
XMC_SPI_CH_SetInputSource(XMC_SPI1_CH1, XMC_SPI_CH_INPUT_DIN3, USIC1_C1_DX5_DOUT3);

XMC_GPIO_SetOutputStrength(SPI_SIO0, XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE);
XMC_GPIO_SetOutputStrength(SPI_SCLK, XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE);
XMC_GPIO_SetOutputStrength(SPI_CE, XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE);

XMC_GPIO_SetHardwareControl(SPI_SIO0, P3_15_HWCTRL_U1C1_DOUT0);
XMC_GPIO_SetHardwareControl(SPI_SOO0, P3_14_HWCTRL_U1C1_DOUT1);

XMC_SPI_CH_SetBitOrderMsbFirst(XMC_SPI1_CH1);
XMC_SPI_CH_SetWordLength(XMC_SPI1_CH1, 8);
XMC_SPI_CH_SetFrameLength(XMC_SPI1_CH1, 64);
XMC_SPI_CH_ConfigureShiftClockOutput(XMC_SPI1_CH1, XMC_SPI_CH_BRG_SHIFT_CLOCK_PASSIVE_LEVEL_1_DELAY_DISABLED, XMC_SPI_CH_BRG_SHIFT_CLOCK_OUTPUT_SCLK);
XMC_SPI_CH_Start(XMC_SPI1_CH1);
XMC_SPI_CH_EnableMasterClock(XMC_SPI1_CH1);

XMC_GPIO_SetHardwareControl(SPI_SCLK, XMC_GPIO_HWCTRL_DISABLED);
XMC_GPIO_SetMode(SPI_SCLK, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2 | P0_13_AF_U1C1_SCLKOUT);
XMC_GPIO_SetMode(SPI_SIO0, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2 | P3_15_AF_U1C1_DOUT0);

XMC_GPIO_SetOutputLow(SPI_CE);
XMC_GPIO_SetMode(SPI_CE, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
}
Thanks
0 Likes
User18007
Level 1
Level 1
First reply posted First question asked
First of thanks for replying.

After trying with that main.c file only I asked you for little change in the code according to my pin configuration and SPI full duplex mode(U1C1). Reason why I have attached the SPI_init() function just tell me that MOSI and MISO pin configuration is correct or not, if not then what would be correct on.

Thanks
0 Likes
User13960
Level 3
Level 3
First like received
Hi,

I don't know if it is relevant to your problem but I discovered a bug in the Infineon SPI001 library function 'SPI001_Configure()' which incorrectly changes I/O pin configurations and can prevent the SPI from working. I wrote my own version of the 'SPI001_Configure()' function as a work-around.

Best regards
0 Likes