+ Reply to Thread
Results 1 to 2 of 2

Thread: XMC1400 SPI Problem: Slave select and transmit interrupt

  1. #1
    New Member New Member ipek is on a distinguished road
    Join Date
    May 2019
    Location
    Turkey, Ankara
    Posts
    9
    Points
    72.5

    XMC1400 SPI Problem: Slave select and transmit interrupt

    I have the simplest goal which is to send one little message to a DAC module.*To do this, what i need from chip select signal is to become low before transmit and then high when transmit ends.
    I managed to do this with 2 different pin sets(test pins). But I failed to do this with the original pins(the ones that are connected in the PCB). Slave select signal stays at high all the time..
    Then I tried to enable and disable it manually. To do this: I enable the transmit interrupt, I set Slave select IO to HIGH in the transmit interrupt(after all data bits are transferred) and LOW before transmit. But this method doesn't work either because
    transmit interrupt is never received..
    I want to remark that when I try this with other two pin sets, transmit interrupt works just fine.. I only change pins and stuff about them. I am adding my code..
    Note: The pins that I am having trouble with can be seen above. The pin set that is totally OK is also there but commented.

    Code:
    #include "xmc_spi.h"
    #include "GPIO.h"
    #include "InterruptHandlerMap.h"
    
    uint16_t DataReceived = 0;
    void SPIReceive(void);
    void SPITransmit(void);
    
    // good pins
    //#define PIN_MOSI P1_0
    //#define PIN_SCLK P0_7
    //#define PIN_SS P0_0
    //XMC_USIC_CH_t* channel = XMC_SPI0_CH0;
    //XMC_GPIO_MODE_t MOSIMode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7;
    //XMC_GPIO_MODE_t SSMode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6;
    //XMC_GPIO_MODE_t CLKMode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6;
    
    // also good pins
    //#define PIN_MOSI P1_2
    //#define PIN_SCLK P1_4
    //#define PIN_SS P1_1
    //XMC_USIC_CH_t* channel = XMC_SPI0_CH1;
    //XMC_GPIO_MODE_t MOSIMode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7;
    //XMC_GPIO_MODE_t SSMode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7;
    //XMC_GPIO_MODE_t CLKMode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2;
    
    
    //bad pins
    #define PIN_MOSI P2_13
    #define PIN_SCLK P2_12
    #define PIN_SS P4_0
    XMC_USIC_CH_t* channel = XMC_SPI1_CH1;
    XMC_GPIO_MODE_t MOSIMode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7;
    XMC_GPIO_MODE_t SSMode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7;
    XMC_GPIO_MODE_t CLKMode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4;
    int main(void)
    {
    
    	XMC_SPI_CH_CONFIG_t spi_config = 	{ .baudrate = 10000,
    										  .bus_mode = XMC_SPI_CH_BUS_MODE_MASTER,
    										  .selo_inversion = XMC_SPI_CH_SLAVE_SEL_INV_TO_MSLS,
    										  .parity_mode = XMC_USIC_CH_PARITY_MODE_ODD
    										};
    
    	XMC_SPI_CH_Init(channel, &spi_config);
    
    	XMC_SPI_CH_SetWordLength(channel, 16);
    	XMC_SPI_CH_SetFrameLength(channel, 16);
    	XMC_SPI_CH_SetBitOrderMsbFirst(channel);
    
    	//configureGPIO: calls XMC_GPIO_Init(..) inside
    	configureGPIO(PIN_MOSI, MOSIMode, GPIO_HIGH);
    	configureGPIO(PIN_SS, SSMode, GPIO_HIGH);
    	configureGPIO(PIN_SCLK, CLKMode, GPIO_HIGH);
    	XMC_USIC_CH_TXFIFO_Configure(channel, 0, XMC_USIC_CH_FIFO_SIZE_32WORDS, 0);
    
    	XMC_SPI_CH_EnableEvent(channel, XMC_SPI_CH_EVENT_TRANSMIT_SHIFT);
    	XMC_SPI_CH_SelectInterruptNodePointer(channel, XMC_SPI_CH_INTERRUPT_NODE_POINTER_TRANSMIT_SHIFT, 1);
    	XMC_SPI_CH_EnableSlaveSelect(channel, XMC_SPI_CH_SLAVE_SELECT_0);
    	XMC_SPI_CH_Start(channel);
    
    
    	registerIRQHandler(10, SPITransmit); // used to call SPITrasmit function in IRQ10_Handler()
    
    	NVIC_SetPriority(IRQ10_IRQn, 1U);
    	NVIC_EnableIRQ(IRQ10_IRQn);
    
    	/* Trigger manually the first interrupt */
    	SysTick_Config(SystemCoreClock / 1000);
    	while (1)
    	{
    		/* Infinite loop */
    	}
    }
    void SPITransmit(void)
    {
    //placed breakpoint in here but never hit with bad pin set
    }
    
    void SysTick_Handler()
    {
    	static uint32_t tick = 0;
    	tick++;
    	if(500 == tick)
    	{
    		XMC_SPI_CH_Transmit(channel,1023, XMC_SPI_CH_MODE_STANDARD);
    
    		tick = 0;
    	}
    }

  2. #2

    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    716
    Hi,

    The P2.12 and P2.13 belongs to the analog port P2. You need to enable explicitly the digital pad function using the PDISC register or XMC_GPIO_EnableDigitalInput(). Check also the XMC_GPIO_Init() function.

    Regards,
    Jesus
    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.