infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 4 of 4

Thread: Xmc 4200 uart

  1. #1
    Beginner Beginner zmjafri is on a distinguished road
    Join Date
    Sep 2018
    Posts
    10
    Points
    140

    Xmc 4200 uart

    Does anyone have a working UART project using the XMC 4200 ? The Dave sample projects do not seem to have this version as a sample project.

    Thanks.

  2. #2
    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
    HI...
    here is the basic UART project that transmits the message on the terminal. Would also like to highlight that this example is exactly the same as one provided inside of XMCLib package under XMC4500 series/UART/UART_TRANSMIT example. I´ve just changed the LED define while it´s connected to different pin.

    Code:
    #include <xmc_gpio.h>
    #include <xmc_uart.h>
    
    #define TICKS_PER_SECOND 1000
    #define TICKS_WAIT 1000
    
    const uint8_t message[] = "Hello world!!\n";
    
    #define LED1    P2_1
    #define UART_TX P1_5
    #define UART_RX P1_4
    
    XMC_GPIO_CONFIG_t uart_tx =
    {
      .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2,
      .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM
    };
    
    XMC_GPIO_CONFIG_t uart_rx =
    {
      .mode = XMC_GPIO_MODE_INPUT_TRISTATE
    };
    
    XMC_GPIO_CONFIG_t led =
    {
      .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
      .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM
    };
    
    XMC_UART_CH_CONFIG_t uart_config =
    {
      .data_bits = 8U,
      .stop_bits = 1U,
      .baudrate = 115200U
    };
    
    void SysTick_Handler(void)
    {
      static uint32_t ticks = 0;
      uint32_t index;
    
      ticks++;
      if (ticks == TICKS_WAIT)
      {
    	  XMC_GPIO_ToggleOutput(LED1);
    
    	  for (index = 0; index < sizeof(message) - 1; index++)
    	  {
    	    XMC_UART_CH_Transmit(XMC_UART0_CH0, message[index]);
    	  }
    	  ticks = 0;
      }
    }
    
    int main(void)
    {
      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);
      XMC_UART_CH_Start(XMC_UART0_CH0);
      XMC_GPIO_Init(UART_TX,&uart_tx);
      XMC_GPIO_Init(UART_RX,&uart_rx);
      XMC_GPIO_Init(LED1,&led);
    
      /* Send a message via UART periodically */
      SysTick_Config(SystemCoreClock / TICKS_PER_SECOND);
    
      while(1)
      {
    	/* Infinite loop */
      }
    }
    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.

  3. #3
    Beginner Beginner zmjafri is on a distinguished road
    Join Date
    Sep 2018
    Posts
    10
    Points
    140
    Hello,

    Thanks for your reply. So I have indeed been playing around with the XMC 4500's UART examples and changing the pin configurations. While I can get the code to build and compile, I don't see anything on my serial communication terminal. The way that I have configured the pins is by looking at the Distance2Go radar (device I am using) and XMC 4200 microcontroller data sheets. I have used Pins 0_0 as the UART RX and P0_1 as the UART TX. Any further ideas?

    #include <xmc_gpio.h>
    #include <xmc_uart.h>

    const uint8_t message[] = "Hello world!!\n";

    #define UART_TX P0_1
    #define UART_RX P0_0

    XMC_GPIO_CONFIG_t uart_tx =
    {
    .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2,
    .output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM
    };

    XMC_GPIO_CONFIG_t uart_rx =
    {
    .mode = XMC_GPIO_MODE_INPUT_TRISTATE
    };

    XMC_UART_CH_CONFIG_t uart_config =
    {
    .data_bits = 8U,
    .stop_bits = 1U,
    .baudrate = 115200U
    };


    int main(void)
    {
    XMC_UART_CH_Init(XMC_UART0_CH0, &uart_config);
    XMC_UART_CH_SetInputSource(XMC_UART1_CH1, XMC_UART_CH_INPUT_RXD, USIC1_C1_DX0_P0_0);
    XMC_UART_CH_Start(XMC_UART0_CH0);
    XMC_GPIO_Init(UART_TX,&uart_tx);
    XMC_GPIO_Init(UART_RX,&uart_rx);
    uint32_t index;


    /* Send a message via UART periodically */
    for (index = 0; index < sizeof(message) - 1; index++)
    {
    XMC_UART_CH_Transmit(XMC_UART1_CH1, message[index]);
    }

    }

  4. #4
    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
    Hi,

    have a look at the XMC4100/4200 Data sheet and check the Port I/O Function Table where you can find connection of each pin with the peripherals...it looks like this for the selected pins:

    Click image for larger version

Name:	portPeriph.PNG
Views:	1
Size:	38.8 KB
ID:	3638

    And here you can see that pins P0.0 and P0.1 are connected to a USIC module 1 channel 1 (USIC1C1). So inside of the main function you should initialize and start different channel.

    Fix that and see how it goes...other configuration looks fine.

    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.