infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 2 of 2

Thread: Xmc4500 spi

  1. #1
    New Member New Member Szymon.Sobczak is on a distinguished road
    Join Date
    Nov 2017
    Posts
    12
    Points
    47.5

    Xmc4500 spi

    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.

    Code:
    #include <xmc_gpio.h>
    #include <xmc_spi.h>
    
    
    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

  2. #2
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    DRubeša will become famous soon enough
    Join Date
    Jul 2016
    Location
    München
    Posts
    186
    Points
    2782.5
    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:

    Code:
    {
    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
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.