Not applicable
Apr 11, 2018
04:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 11, 2018
04:47 AM
Hi
I'm using XMC4500 Relax Kit-V1. I am trying to connect through the spi with external flash memory (MICROCHIP SST26VF064B) and I have a problem. When I m trying read ID of memory I do not get what I should. Could anyone help me with this problem? In RHBUF always have 0x0000FFFF.
Best regards
Szymon
I'm using XMC4500 Relax Kit-V1. I am trying to connect through the spi with external flash memory (MICROCHIP SST26VF064B) and I have a problem. When I m trying read ID of memory I do not get what I should. Could anyone help me with this problem? In RHBUF always have 0x0000FFFF.
#include
#include
XMC_USIC_CH_t *spi_master_ch = XMC_SPI1_CH0;
XMC_SPI_CH_CONFIG_t spi_master =
{
.baudrate = 1000000,
.bus_mode = XMC_SPI_CH_BUS_MODE_MASTER,
.selo_inversion =XMC_SPI_CH_SLAVE_SEL_SAME_AS_MSLS,
.parity_mode = XMC_USIC_CH_PARITY_MODE_NONE
} ;
int main(void){
XMC_GPIO_SetMode(P0_5, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2);
XMC_GPIO_SetMode(P0_6, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2);
XMC_GPIO_SetMode(P0_11, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2);
XMC_GPIO_SetMode(P0_4, XMC_GPIO_MODE_INPUT_TRISTATE);
XMC_SPI_CH_EnableMasterClock(XMC_SPI1_CH0);
XMC_SPI_CH_Init(spi_master_ch, &spi_master);
XMC_SPI_CH_Start(spi_master_ch);
XMC_SPI_CH_SetInputSource(spi_master_ch,XMC_SPI_CH_INPUT_DIN0,USIC1_C0_DX0_P0_4);
XMC_SPI_CH_SetWordLength(spi_master_ch, 16);
while(1){
XMC_SPI_CH_EnableSlaveSelect(spi_master_ch, XMC_SPI_CH_SLAVE_SELECT_0);
XMC_SPI_CH_Transmit(spi_master_ch, 0x9F,XMC_SPI_CH_MODE_STANDARD);
while((XMC_SPI_CH_GetStatusFlag(spi_master_ch) &
XMC_SPI_CH_STATUS_FLAG_TRANSMIT_SHIFT_INDICATION) ==0U)
{
/* wait for ACK */
}
XMC_SPI_CH_ClearStatusFlag(spi_master_ch,XMC_SPI_CH_STATUS_FLAG_TRANSMIT_SHIFT_INDICATION);
XMC_SPI_CH_DisableSlaveSelect(spi_master_ch);
uint16_t received_data = XMC_SPI_CH_GetReceivedData(spi_master_ch);
}
}
Best regards
Szymon
1 Reply
Apr 16, 2018
05:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 16, 2018
05:21 AM
Hi Szymon,
I would suggest couple of things...
for the pin initialization I would use or prefer usage of configuration structure where you can also define a output level to be high state. Especially while slave select signal should be "1" initially. You can have define something like this for every pin and then call "XMC_GPIO_Init" function:
Additionally, you need to define Frame Length by calling "XMC_SPI_CH_SetFrameLength" function.
What would be also my suggestion is to create a empty DAVE CE project and add "SPI_MASTER" APP. Then define pins that you want to use and generate code. Generated code you can find in "spi_master_conf.c" file and then you can very easy see what is missing in your XMCLib implementation.
Best regards,
Deni
I would suggest couple of things...
for the pin initialization I would use or prefer usage of configuration structure where you can also define a output level to be high state. Especially while slave select signal should be "1" initially. You can have define something like this for every pin and then call "XMC_GPIO_Init" function:
{
const SPI_MASTER_GPIO_CONFIG_t SPI_MASTER_0_SS_0_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
},
.slave_select_ch = XMC_SPI_CH_SLAVE_SELECT_0
};
Additionally, you need to define Frame Length by calling "XMC_SPI_CH_SetFrameLength" function.
What would be also my suggestion is to create a empty DAVE CE project and add "SPI_MASTER" APP. Then define pins that you want to use and generate code. Generated code you can find in "spi_master_conf.c" file and then you can very easy see what is missing in your XMCLib implementation.
Best regards,
Deni