infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 5 of 5

Thread: XMC4200 hexagon kit UART with XMClib

  1. #1
    Beginner Beginner reyntjensm is on a distinguished road
    Join Date
    Feb 2018
    Location
    Belgium
    Posts
    6
    Points
    60

    XMC4200 hexagon kit UART with XMClib

    Hello everyone,

    I'm still struggling with the UART(printf() style debugging).
    I want to setup an UART connection using the XMClib( NO Dave APPS)
    I found an UART example for the XMC1200 kit(UART_XMC_Lib_XMC12), i tried to adapt the example to the XMC4200 series but still there is no output.
    Will i be able to see the output in dave or do i need another program(TeraTerm) to see the output?
    In the example, the TX pin is configured as XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7. i'm unable to use ALT7 so i used ALT4, does this makes any difference?
    Code:
    /* SFR declarations of the selected device */
    #include <XMC4200.h>
    #include "GPIO.h"
    #include <xmc_uart.h>
    #include <xmc_gpio.h>
    
    
    #define UART_RX P1_4
    #define UART_TX P1_5
    #define LED1 P2_1
    #define KNOP1 P14_7
    #define TICKS_PER_SECOND 10000
    #define TICKS_WAIT 1000
    const uint8_t message[] = "hello world\n";
    
    
    
    /*UART CONFIG*/
    const XMC_UART_CH_CONFIG_t uart_config =
    {
    		.data_bits = 8U,
    		.stop_bits = 1U,
    		.baudrate = 115200
    };
    
    
    unsigned long timingdelay, adc_result;
    
    void ADC0_Init(void);
    void Delay100US (unsigned long time);
    void SysTick_Handler(void);
    
    int main(void) {
    
    	/* Setup the system timer to tick every 100us */
    	SysTick_Config(SystemCoreClock / TICKS_PER_SECOND);
    
    	/*conf uart channel */
    	XMC_UART_CH_Init(XMC_UART0_CH0, &uart_config);
    	XMC_UART_CH_SetInputSource(XMC_UART0_CH0, XMC_UART_CH_INPUT_RXD, USIC0_C0_DX0_P1_4);
    
    	/*start uart channel*/
    	XMC_UART_CH_Start(XMC_UART0_CH0);
    
    	/*config pins */
    
    	XMC_GPIO_CONFIG_t configTX;
    	configTX.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4;/*must be ALT7?????*/
    	XMC_GPIO_Init(UART_TX, &configTX);
    
    	XMC_GPIO_CONFIG_t configRX;
    	configRX.mode = XMC_GPIO_MODE_INPUT_TRISTATE;
    	XMC_GPIO_Init(UART_RX, &configRX);
    
    	/*XMC_GPIO_SetMode(UART_TX,XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4); must be alt7???*/
    	/*XMC_GPIO_SetMode(UART_RX,XMC_GPIO_MODE_INPUT_TRISTATE );*/
    	/*XMC_GPIO_SetMode(LED1, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);*/
    	/*XMC_GPIO_SetMode(P14_7,XMC_GPIO_MODE_INPUT_TRISTATE);*/ /*doesn't work for pushbutton?*/
    
    	XMC_GPIO_CONFIG_t configOUTPUT;
    	configOUTPUT.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL;
    	configOUTPUT.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH;
    	configOUTPUT.output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM;
    	XMC_GPIO_Init(LED1,&configOUTPUT);
    
    	XMC_GPIO_CONFIG_t configINPUT;
    	configINPUT.mode = XMC_GPIO_MODE_INPUT_TRISTATE;
    	XMC_GPIO_Init(KNOP1, &configINPUT);
    
    	while(1)
    	{
    		/*loop*/
    
    		if(XMC_GPIO_GetInput(KNOP1)==0)
    		{
    			XMC_GPIO_ToggleOutput(LED1);
    			Delay100US(5000);
    		}
    	}
    
    }
    
    
    /*
    */
    /**
     * @brief Inserts a delay time based on system timer configuration\n
     *
     * @param[in]   Time  Specifies the delay time length, in 100 micro seconds multiples\n
     * @return none\n
     *
     * <b>Reentrancy:  no</b><BR>
     *
     */
    void Delay100US (unsigned long time)
    {
    	timingdelay =  time;
    	while (timingdelay != 0);             //timingdelay is modified upon a system timer overflow in SysTick_Handler routine
    }
    
    /**
     * @brief SysTick_Handler is called after every System Timer overflow \n
     *
     * @param[in] none\n
     * @return none\n
     *
     * <b>Reentrancy:  no</b><BR>
     *
     */
    void SysTick_Handler (void)             // SysTick Interrupt Handler
    {
    	uint32_t index;
    	static uint32_t ticks = 0;
    	ticks++;
    
    	if(ticks == TICKS_WAIT)
    	{
    		for(index = 0; index < sizeof(message) - 1; index++)
    		{
    			XMC_UART_CH_Transmit(XMC_UART0_CH0, message[index]);
    		}
    		ticks = 0;
    	}
    
    	if(timingdelay != 0x00){
    		timingdelay--;                    //Decrease the time counter timingdelay
        }
    
    }
    Could somebody please help me solve this issue, i'm now already struggling for 3 weeks with this issue...
    Thanks to everyone

  2. #2

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

    Have a look at the examples included in the XMCLib, http://dave.infineon.com/Libraries/XMCLib/XMC_Peripheral_Library_v2.1.16.zip

    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.

  3. #3
    Beginner Beginner reyntjensm is on a distinguished road
    Join Date
    Feb 2018
    Location
    Belgium
    Posts
    6
    Points
    60
    Hello everyone,

    after 3 weeks, i was able to resolve this issue by myself.
    The alternative pin function had to be 2 instead of 4...
    So this line of code had to be changed:
    Code:
    configTX.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2;
    There is little information about this...
    The help from the infineon team isn't worth it at all.
    Since they only say: have a look at the examples.
    Since there was no UART example for the XMC4200, i started with the UART example from the XMC4500.
    My error was hardware related and took me a lot of time to find out in the datasheets.
    After all i did learn a lot from this error.
    Thanks to everyone.

  4. #4
    Beginner Beginner zmjafri is on a distinguished road
    Join Date
    Sep 2018
    Posts
    10
    Points
    140
    Hey, can you guys please give guidance as how to configure the XMC 4200 for UART communication? The examples and documentation for seem to be for micro controllers other than the XMC 4200, how did you get this to run?

    I am using the distance2go board with the XMC 4200 Microcontroller. When I tried this myself, upon compilation, i receive the error "J-Link GDB Server failed: Could not listen no the tcp port." Clearly some port definitions are wrong?

    Appreciate any help!

    Zain
    Last edited by zmjafri; Oct 4th, 2018 at 10:11 AM.

  5. #5
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    DRubeša will become famous soon enough
    Join Date
    Jul 2016
    Location
    München
    Posts
    191
    Points
    2882.5
    I´ve provided the answer to another thread you opened (I´ve made the example for the XMC4200 CPU board so you may need to change pin layout). The issue that you see with the J-Link is not caused by the UART example but by the J-Link itself so a cause can be more than one thing but I would suggest to see if you have installed SEGGER J-link driver at the first place and how does your debug configuration window looks like...it should be something like this below:

    Click image for larger version

Name:	debugConfigWindow.PNG
Views:	0
Size:	77.5 KB
ID:	3635

    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.