+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 19 of 19

Thread: XMC1100 boot kit and uart

  1. #11
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    DRubeša will become famous soon enough
    Join Date
    Jul 2016
    Location
    München
    Posts
    193
    Points
    775.625
    Exactly,

    you need to use the mentioned two functions. If you want to learn how to do it without APPs, I suggest you take a look at the generated file of DAVE APP . I know, I know...without DAVE APPs, but bear with me for a moment. You already have working example with DAVE APPs I suppose. Take a look at "uart_conf.c" and "uart.c". These files are generated by the DAVE´s code engine and they are placed under "DAVE -> Generated -> UART" inside your project. From there you can see which XMClib functions (output of the DAVE APPs is always a XMClib function) should be used to achieve your goal. Then you can try step by step to "mimic" the DAVE code engine and in no time you´ll have your own program written exclusively with XMClibs.

    Try it for yourself

    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.

  2. #12
    Beginner Beginner Cyb3rn0id is on a distinguished road
    Join Date
    Oct 2016
    Posts
    13
    Points
    67.5
    Sorry but I don't have a Dave app example working.
    I've tried to setup interrupt as you say. I've put a "ISR_uart_rx" as callback of end receive, pressed "Generate code", rebuilded and uploaded but nothing happens



    #include <DAVE.h> //Declarations from DAVE Code Generation (includes SFR declaration)

    int main(void)
    {
    DAVE_Init(); /* Initialization of DAVE APPs */

    while(1U)
    {
    }
    return 0;
    }

    void ISR_uart_rx (void)
    {
    uint8_t read_data = 0x0;
    /* Read the data */
    UART_Receive(&UART_0, &read_data,1);
    if(read_data != 0x00)
    {
    /* Transmit the message */
    UART_Transmit(&UART_0, &read_data, 1);
    read_data = 0x0;
    }

    }

  3. #13
    Beginner Beginner Cyb3rn0id is on a distinguished road
    Join Date
    Oct 2016
    Posts
    13
    Points
    67.5
    Sorry but Interrupt example as you said doesn't work

    in generated files there is:

    /*Receive ISR*/
    void UART_0_RX_HANDLER()
    {
    UART_lReceiveHandler(&UART_0);
    }

    but nothing in the code call this function (UART_0_RX_HANDLER)
    only in the configuration there is a refer to my own interrupt function (ISR_uart_rx) but this config is never used in the code!:

    /*UART APP configuration structure*/
    const UART_CONFIG_t UART_0_config =
    {
    .channel_config = &UART_0_channel_config,


    .fptr_uart_config = UART_0_init,
    .tx_cbhandler = NULL,
    .rx_cbhandler = ISR_uart_rx,
    .sync_error_cbhandler = NULL,
    .rx_noise_error_cbhandler = NULL,
    .format_error_bit0_cbhandler = NULL,
    .format_error_bit1_cbhandler = NULL,
    .collision_error_cbhandler = NULL,
    .tx_pin_config = &UART_0_tx_pin,
    .mode = UART_MODE_FULLDUPLEX,
    .transmit_mode = UART_TRANSFER_MODE_INTERRUPT,
    .receive_mode = UART_TRANSFER_MODE_INTERRUPT,
    .tx_fifo_size = XMC_USIC_CH_FIFO_DISABLED,
    .rx_fifo_size = XMC_USIC_CH_FIFO_DISABLED,
    .tx_sr = 0x1U,
    };

    Even if i substitute ISR_uart_rx in the UART_0_RX_HANDLER() nothing happens.

  4. #14
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    DRubeša will become famous soon enough
    Join Date
    Jul 2016
    Location
    München
    Posts
    193
    Points
    775.625
    Quote Originally Posted by Cyb3rn0id View Post
    Sorry but I don't have a Dave app example working.
    I've tried to setup interrupt as you say. I've put a "ISR_uart_rx" as callback of end receive, pressed "Generate code", rebuilded and uploaded but nothing happens



    #include <DAVE.h> //Declarations from DAVE Code Generation (includes SFR declaration)

    int main(void)
    {
    DAVE_Init(); /* Initialization of DAVE APPs */

    while(1U)
    {
    }
    return 0;
    }

    void ISR_uart_rx (void)
    {
    uint8_t read_data = 0x0;
    /* Read the data */
    UART_Receive(&UART_0, &read_data,1);
    if(read_data != 0x00)
    {
    /* Transmit the message */
    UART_Transmit(&UART_0, &read_data, 1);
    read_data = 0x0;
    }

    }
    Compare this code section with the code section I posted some posts before which is working and see how much code you have change. It´s a pretty big difference, not very iterative approach I must admit.

    Dave_Init() function will initialize service requests:

    Click image for larger version

Name:	service_routine.PNG
Views:	8
Size:	14.5 KB
ID:	2641

    Now let´s take a look who calls the receive callback function. Under "uart.c" (folder "DAVE -> Generated -> UART" in you active project) search for "UART_lReceiveHandler". This function calls the receive callback function if you defined it in the DAVE APP:

    Click image for larger version

Name:	callback_handler.PNG
Views:	0
Size:	3.5 KB
ID:	2642

    OK, so now you know that DAVE_init initializes service requests, and that function "UART_lReceiveHandler" calls callback function. Where does the function "UART_lReceiveHandler" come from? File "uart_conf.c" (folder "DAVE -> Generated -> UART" in you active project):

    Click image for larger version

Name:	receive_isr.PNG
Views:	0
Size:	2.8 KB
ID:	2643

    A OK....this is interrupt handler routine. So you need to have receive interrupt to trigger this function that will later on call receive callback function. I told you already that you need two things to trigger interrupt...you need to initialize service request (this is already done by Dave_Init()) and you need to define events on which the interrupt will occur. Remember this one: XMC_USIC_CH_EVENT_STANDARD_RECEIVE? Now search inside "uart.c" file for this keyword. This should caught your attention:

    Click image for larger version

Name:	interrupt_event.PNG
Views:	6
Size:	4.2 KB
ID:	2644

    Exactly, what we need. Which function is enabling interrupt events for us? Scroll a little bit up and you find this name "UART_StartReceiveIRQ". Still doesn´t ring a bell I guess. Well let´s search that function name...aaaa this look now familiar.

    Click image for larger version

Name:	uart_receive.PNG
Views:	1
Size:	20.3 KB
ID:	2645

    It´s the "UART_Receive" function that enables the receive events.I hope you understand what is the issue with your code...you don´t try to receive anything from the terminal. It won´t happen just be using DAVE_init and having infinite "while" loop expecting something will happen. Add "UART_Receive" to the "while" loop and try then to receive a character from terminal.

    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.

  5. #15
    Beginner Beginner Cyb3rn0id is on a distinguished road
    Join Date
    Oct 2016
    Posts
    13
    Points
    67.5
    Quote Originally Posted by DRubeša View Post

    Dave_Init() function will initialize service requests:

    Attachment 2641
    My Dave_init is very different from yours:

    Click image for larger version

Name:	dave_init.png
Views:	0
Size:	16.5 KB
ID:	2646

    My Uart configuration is:

    Click image for larger version

Name:	uart_cf1.png
Views:	0
Size:	18.6 KB
ID:	2647
    Click image for larger version

Name:	uart_cf2.png
Views:	0
Size:	14.2 KB
ID:	2648
    Click image for larger version

Name:	uart_cf3.png
Views:	0
Size:	26.7 KB
ID:	2649

    Quote Originally Posted by DRubeša View Post
    It´s the "UART_Receive" function that enables the receive events.I hope you understand what is the issue with your code...you don´t try to receive anything from the terminal. It won´t happen just be using DAVE_init and having infinite "while" loop expecting something will happen. Add "UART_Receive" to the "while" loop and try then to receive a character from terminal.
    It's a very strange approach for me.
    I work with other microcontrollers (such as microchip picmicro and AVRs): If I have an UART interrupt, after settings (in the main, outside the main loop) I must put nothing in the main loop to receive data: interrupt will do all the job regardless the main.
    I don't understand the need of put an "uart_receive" in the loop if I've enabled an Uart-receive-interrupt with his own function. It's very strange to me.

    Can you attach your project since the example you're writing are very different to my generated code?
    I'm using DAVE 4.3 and latest libraries.
    Thank you for your patience.

  6. #16
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    DRubeša will become famous soon enough
    Join Date
    Jul 2016
    Location
    München
    Posts
    193
    Points
    775.625
    Hi,

    sorry, I wasn´t totally explicit. Dave_init will call Uart_init that will set the service requests. When you try to debug the code by single-stepping you´ll notice exactly the things I mentioned. Your other DAVE APP settings look good.

    I know that this approach is different from the things you may encounter before but that is what it is the thing is that here we use Interrupt mode as a Protocol Handling. I guess the Direct mode would be something that is more familiar to your previous experience. In Direct mode you need to take care of enabling interrupt and defining which events should cause an interrupt. In Interrupt mode APP does it for you, so there is less work on your side. But I can understand that is slightly different from the things you´re used.

    I can do an example tomorrow that will support my previous post. Today I need to excuse myself, while I´m on a sick leave and I don´t have XMC1100 Boot kit at home. But try to incorporate UART_Receive function in your code...it´s seams you really close to the correct solution.

    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.

  7. #17
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    DRubeša will become famous soon enough
    Join Date
    Jul 2016
    Location
    München
    Posts
    193
    Points
    775.625
    Hi,

    me again. So as I promised...example using Interrupt mode as as Protocol Handling:
    Click image for larger version

Name:	uart_general_settings.PNG
Views:	1
Size:	8.9 KB
ID:	2651
    Click image for larger version

Name:	uart_advanced_settings.PNG
Views:	0
Size:	13.0 KB
ID:	2652
    Click image for larger version

Name:	uart_interrupt_settings.PNG
Views:	0
Size:	16.1 KB
ID:	2653
    Click image for larger version

Name:	uart_pin_allocation.PNG
Views:	0
Size:	4.8 KB
ID:	2655

    My "main.c" code:
    Code:
    #include <DAVE.h>                 //Declarations from DAVE Code Generation (includes SFR declaration)
    
    uint8_t read_data = 0x0;
    
    int main(void)
    {
    
      DAVE_Init(); /* Initialization of DAVE APPs */
    
      while(1U)
      {
        /* Read the data */
        UART_Receive(&UART_0, &read_data,1);
      }
    
      return 0;
    }
    
    void ISR_uart_rx (void)
    {
      if(read_data != 0x00)  /* this condition is not even necessary, while we only enter "ISR_uart_rx" routine after we received some 
                                data and stored it into "read_data" variable */
      {
        /* Transmit the message */
        UART_Transmit(&UART_0, &read_data, 1);
      }
    }
    And finally, result on the HTerm window (you can see that every character that I receive FROM the terminal is transmitted BACK to the terminal). As you can see, echo functionality is achieved.
    Click image for larger version

Name:	uart_hterm_window.PNG
Views:	5
Size:	63.0 KB
ID:	2654

    I can maybe even prepare a short example using Direct mode or even using XMClibs only but don´t take me for my word, I have also another tasks to do

    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.

  8. #18
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    DRubeša will become famous soon enough
    Join Date
    Jul 2016
    Location
    München
    Posts
    193
    Points
    775.625
    Hi

    so, I had some time and I done the Direct mode as I said but to be honest it´s not very useful example and I think you would prefer something that uses XMClibs....so I built exactly that. UART echo functionality using only XMClibs and interrupt handler like you probably used it in your previous projects with other architectures/vendors.

    Code:
    #include <xmc_gpio.h>
    #include <xmc_uart.h>
    
    #define UART_TX_HANDLER  IRQ_Hdlr_10
    #define UART_RX_HANDLER  IRQ_Hdlr_9
    
    typedef struct GPIO_PIN
    {
      XMC_GPIO_PORT_t *const port;            /**< Pointer to the GPIO port base address */
      const uint8_t pin;                      /**< Pin number in the port*/
      const XMC_GPIO_CONFIG_t *const config;  /**< Pin configuration structure */
    } GPIO_PIN_t;
    
    /*USIC channel configuration*/
    const XMC_UART_CH_CONFIG_t UART_channel_config =
    {
      .baudrate      = 19200U,
      .data_bits     = 8U,
      .frame_length  = 8U,
      .stop_bits     = 1U,
      .oversampling  = 16U,
      .parity_mode   = XMC_USIC_CH_PARITY_MODE_NONE
    };
    
    /*Transmit pin configuration*/
    const XMC_GPIO_CONFIG_t UART_tx_pin_config   =
    {
      .mode             = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7,
      .output_level     = XMC_GPIO_OUTPUT_LEVEL_HIGH
    };
    
    /*Transmit pin configuration used for initializing*/
    const GPIO_PIN_t UART_tx_pin =
    {
      .port = (XMC_GPIO_PORT_t *)PORT1_BASE,
      .config = &UART_tx_pin_config,
      .pin = 2U
    };
    
    /*Receive pin configuration*/
    const XMC_GPIO_CONFIG_t UART_rx_pin_config   = {
      .mode             = XMC_GPIO_MODE_INPUT_TRISTATE,
      .output_level     = XMC_GPIO_OUTPUT_LEVEL_HIGH,
      .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD
    };
    
    /*Receive pin configuration used for initializing*/
    const GPIO_PIN_t UART_rx_pin =
    {
      .port = (XMC_GPIO_PORT_t *)PORT1_BASE,
      .config = &UART_rx_pin_config,
      .pin = 3U
    };
    
    int main(void)
    {
    
      /* Initialize UART RX pin */
      XMC_GPIO_Init(UART_rx_pin.port, UART_rx_pin.pin, UART_rx_pin.config);
    
      /* Initialize USIC channel in UART mode*/
      XMC_UART_CH_Init(XMC_UART0_CH1, &UART_channel_config);
    
      /*Set input source path*/
      XMC_USIC_CH_SetInputSource(XMC_UART0_CH1, XMC_USIC_CH_INPUT_DX0, USIC0_C1_DX0_P1_3);
    
      /* Start UART */
      XMC_UART_CH_Start(XMC_UART0_CH1);
    
      /* Initialize UART TX pin */
      XMC_GPIO_Init(UART_tx_pin.port, UART_tx_pin.pin, UART_tx_pin.config);
    
      /*Set service request for transmit interrupt */
      XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH1, XMC_USIC_CH_INTERRUPT_NODE_POINTER_TRANSMIT_BUFFER, 1U);
    
      /*Set service request for receive interrupt and enable receive interrupt events */
      XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH1, XMC_USIC_CH_INTERRUPT_NODE_POINTER_RECEIVE, 0U);
      XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH1, XMC_USIC_CH_INTERRUPT_NODE_POINTER_ALTERNATE_RECEIVE, 0U);
      XMC_USIC_CH_EnableEvent(XMC_UART0_CH1, (uint32_t)((uint32_t)XMC_USIC_CH_EVENT_STANDARD_RECEIVE | (uint32_t)XMC_USIC_CH_EVENT_ALTERNATIVE_RECEIVE));
    
      /*Set priority and enable NVIC node for transmit interrupt*/
      NVIC_SetPriority((IRQn_Type)10, 3U);
      NVIC_EnableIRQ((IRQn_Type)10);
    
      /*Set priority and enable NVIC node for receive interrupt*/
      NVIC_SetPriority((IRQn_Type)9, 3U);
      NVIC_EnableIRQ((IRQn_Type)9);
    
      /* Placeholder for user application code. The while loop below can be replaced with user application code. */
      while(1U)
      {
    
      }
    }
    
    void UART_RX_HANDLER(void){
      uint8_t read_data = 0x0;
    
      /*Disable both standard receive and alternative receive FIFO events */
      XMC_USIC_CH_DisableEvent(XMC_UART0_CH1, (uint32_t)((uint32_t)XMC_USIC_CH_EVENT_ALTERNATIVE_RECEIVE | (uint32_t)XMC_USIC_CH_EVENT_STANDARD_RECEIVE));
    
      /*Enable transmit buffer interrupt */
      XMC_USIC_CH_EnableEvent(XMC_UART0_CH1, (uint32_t)XMC_USIC_CH_EVENT_TRANSMIT_BUFFER);
    
      /*Read received data */
      read_data = XMC_UART_CH_GetReceivedData(XMC_UART0_CH1);
    
      /*Transmit data back to the terminal (echo functionality) */
      XMC_UART_CH_Transmit(XMC_UART0_CH1, read_data);
    }
    
    void UART_TX_HANDLER(void){
    
      /*Disable transmit buffer interrupt */
      XMC_USIC_CH_DisableEvent(XMC_UART0_CH1, (uint32_t)XMC_USIC_CH_EVENT_TRANSMIT_BUFFER);
    
      /*Enable receive interrupt events */
      XMC_USIC_CH_EnableEvent(XMC_UART0_CH1, (uint32_t)((uint32_t)XMC_USIC_CH_EVENT_STANDARD_RECEIVE | (uint32_t)XMC_USIC_CH_EVENT_ALTERNATIVE_RECEIVE));
    
    }
    I know...not the coolest code ever but it should suit your needs understanding how UART on XMC can be used.
    If you have additional question, feel free to ask.

    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.

  9. #19
    New Member New Member Jamal is on a distinguished road
    Join Date
    Jun 2017
    Posts
    2
    Points
    35
    Hello deni
    I was reading this post and I have an issue which is somewhat related to this thread.
    I am trying to read the received data from pc using UART. But the problem is that transmission is running just fine but no reception.
    Every time I send the data from terminal to xmc1300 boot kit, it doesn't read anything. I have tried almost everything. Could you please have a look at my code and see where i am doing wrong. The application is basically used to control the color of LEDs using commands sent through uart.
    Code:
     */
    #include <XMC1300.h>
    #include "xmc_gpio.h"
    #include "xmc_uart.h"
    #include <xmc1_gpio.h>
    #include <xmc_bccu.h>
    #include <xmc_scu.h>
    #include <xmc1_scu.h>
    // BCCU Channels for PDM outputs to Ports
    #define R_LED1_CH BCCU0_CH0
    #define G_LED1_CH BCCU0_CH7
    #define B_LED1_CH BCCU0_CH8
    
    // Port Pins for PDM outputs to LED drivers (BCR321)
    #define R_LED1_PIN P0_4
    #define G_LED1_PIN P0_11
    #define B_LED1_PIN P0_1
    
    // Port Pins for unused LEDs
    #define R_LED2_PIN P0_5
    #define G_LED2_PIN P0_6
    #define B_LED2_PIN P0_7
    #define R_LED3_PIN P0_8
    #define G_LED3_PIN P0_9
    #define B_LED3_PIN P0_10
    /*********************************************************************************************************************
     * CONFIGURATION
     *********************************************************************************************************************/
    
    /* Clock configuration */
    XMC_SCU_CLOCK_CONFIG_t clock_config =
    {
      .pclk_src = XMC_SCU_CLOCK_PCLKSRC_DOUBLE_MCLK,
      .fdiv = 0,
      .idiv = 1
    };
    
    /* BCCU configuration */
    XMC_BCCU_GLOBAL_CONFIG_t bccu_global_config =
    {
      .fclk_ps = 0x50, //800kHz @PCLK=64MHz
      .dclk_ps = 0xdb, //292.237KHz @PCLK=64MHz
      .bclk_sel = XMC_BCCU_BCLK_MODE_NORMAL //200KHz @PCLK=64MHz
    };
    XMC_BCCU_CH_CONFIG_t r_pdm_config =
    {
      .dim_sel = XMC_BCCU_CH_DIMMING_SOURCE_DE0 // DE0
    };
    XMC_BCCU_CH_CONFIG_t g_pdm_config =
    {
      .dim_sel = XMC_BCCU_CH_DIMMING_SOURCE_DE0 // DE0
    };
    XMC_BCCU_CH_CONFIG_t b_pdm_config =
    {
      .dim_sel = XMC_BCCU_CH_DIMMING_SOURCE_DE0 // DE0
    };
    XMC_BCCU_DIM_CONFIG_t bccu_dim_config =
    {
      .dim_div = 0x0 // immediate dimming
    };
    
    
    XMC_GPIO_CONFIG_t led1_config;
    XMC_GPIO_CONFIG_t rx_pin_config;
    XMC_GPIO_CONFIG_t tx_pin_config;
    XMC_UART_CH_CONFIG_t uart_config;
    int main(void)
    {
    
    	 //----CLOCK-SETUP-----------------------------------------------------------------------------------
    	  XMC_SCU_CLOCK_Init(&clock_config);
    	  //--------------------------------------------------------------------------------------------------
    
    	  /* init unused LED output pins so that they will not light up */
    	  XMC_GPIO_SetMode(R_LED2_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
    	  XMC_GPIO_SetMode(G_LED2_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
    	  XMC_GPIO_SetMode(B_LED2_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
    	  XMC_GPIO_SetMode(R_LED3_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
    	  XMC_GPIO_SetMode(G_LED3_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
    	  XMC_GPIO_SetMode(B_LED3_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
    
    	  /* init PDM output pins */
    	  XMC_GPIO_SetMode(R_LED1_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1);
    	  XMC_GPIO_SetMode(G_LED1_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1);
    	  XMC_GPIO_SetMode(B_LED1_PIN, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6);
    
    	  /* BCCU Global Initialization */
    	  XMC_BCCU_GlobalInit(BCCU0, &bccu_global_config);
    
    	  //----DIMMING&COLOR-----------------------------------------------------------------------------------------
    	  /* init dimming engine */
    	  XMC_BCCU_DIM_Init(BCCU0_DE0, &bccu_dim_config);
    	  /* enable dimming engine */
    	  XMC_BCCU_EnableDimmingEngine(BCCU0, XMC_BCCU_CH_DIMMING_SOURCE_DE0);
    	  /* set target dimming level to max */
    	  XMC_BCCU_DIM_SetTargetDimmingLevel(BCCU0_DE0, 4095);
    	  /* effect the change in dimming level */
    	  XMC_BCCU_StartDimming(BCCU0, XMC_BCCU_CH_DIMMING_SOURCE_DE0);
    
    	  /* init channels */
    	  XMC_BCCU_CH_Init(R_LED1_CH, &r_pdm_config);
    	  XMC_BCCU_CH_Init(G_LED1_CH, &g_pdm_config);
    	  XMC_BCCU_CH_Init(B_LED1_CH, &b_pdm_config);
    
    	  /* Enable PDM channels*/
    	  XMC_BCCU_ConcurrentEnableChannels(BCCU0, 0x181);
    	  /* set initial color to white */
    	  XMC_BCCU_CH_SetTargetIntensity(R_LED1_CH, 0x555);
    	  XMC_BCCU_CH_SetTargetIntensity(G_LED1_CH, 0x555);
    	  XMC_BCCU_CH_SetTargetIntensity(B_LED1_CH, 0x555);
    	  /* Start linear walk */
    	  XMC_BCCU_ConcurrentStartLinearWalk(BCCU0, 0x181);
      /* UART configuration */
      uart_config.data_bits = 8U;
      uart_config.stop_bits = 1U;
      uart_config.baudrate = 115200;
      uart_config.oversampling=16U;
      uart_config.parity_mode=XMC_USIC_CH_PARITY_MODE_NONE;
    
      /* Configure TX pin */
      tx_pin_config.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7;
      XMC_GPIO_Init(XMC_GPIO_PORT1,2, &tx_pin_config);
    
      /* Configure RX pin */
      rx_pin_config.mode = XMC_GPIO_MODE_INPUT_INVERTED_TRISTATE;
      rx_pin_config.output_level=XMC_GPIO_OUTPUT_LEVEL_HIGH;
      rx_pin_config.input_hysteresis=XMC_GPIO_INPUT_HYSTERESIS_STANDARD;
    
      XMC_GPIO_Init(XMC_GPIO_PORT1,3, &rx_pin_config);
    
      XMC_UART_CH_SetInputSource(XMC_UART0_CH1,XMC_UART_CH_INPUT_RXD,USIC0_C1_DX0_P1_3);
    
    
      /* Configure UART channel */
      XMC_UART_CH_Init(XMC_UART0_CH1, &uart_config);
    
      /* Start UART channel */
      XMC_UART_CH_Start(XMC_UART0_CH1);
    
      /*Set service request for transmit interrupt */
      XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH1, XMC_USIC_CH_INTERRUPT_NODE_POINTER_TRANSMIT_BUFFER , 1U);
    
      /*Set service request for receive interrupt and enable receive interrupt events */
      XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH1, XMC_USIC_CH_INTERRUPT_NODE_POINTER_RECEIVE, 0U);
      XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH1, XMC_USIC_CH_INTERRUPT_NODE_POINTER_ALTERNATE_RECEIVE, 0U);
      XMC_USIC_CH_EnableEvent(XMC_UART0_CH1, (uint32_t)((uint32_t)XMC_USIC_CH_EVENT_STANDARD_RECEIVE | (uint32_t)XMC_USIC_CH_EVENT_ALTERNATIVE_RECEIVE));
    
      /*Set priority and enable NVIC node for transmit interrupt*/
      NVIC_SetPriority((IRQn_Type)10, 3U);
      NVIC_EnableIRQ((IRQn_Type)10);
    
      /*Set priority and enable NVIC node for receive interrupt*/
      NVIC_SetPriority((IRQn_Type)9, 3U);
      NVIC_EnableIRQ((IRQn_Type)9);
     uint32_t read_data = 0x0000;
      /*Disable both standard receive and alternative receive FIFO events */
     XMC_USIC_CH_DisableEvent(XMC_UART0_CH1, (uint32_t)((uint32_t)XMC_USIC_CH_EVENT_ALTERNATIVE_RECEIVE | (uint32_t)XMC_USIC_CH_EVENT_STANDARD_RECEIVE));
    
    /*  if (XMC_UART_CH_GetStatusFlag (XMC_UART0_CH1) & XMC_UART_CH_STATUS_FLAG_RECEIVER_START_INDICATION)
      {
        read_data = XMC_UART_CH_GetReceivedData (XMC_UART0_CH1);
        while (!XMC_UART_CH_STATUS_FLAG_RECEIVE_FRAME_FINISHED);
        XMC_UART_CH_ClearStatusFlag (XMC_UART0_CH1, XMC_UART_CH_STATUS_FLAG_RECEIVER_START_INDICATION);
      }*/
    
     /*Read received data */
      read_data = XMC_UART_CH_GetReceivedData(XMC_UART0_CH1);
    
      /*Enable transmit buffer interrupt */
      XMC_USIC_CH_EnableEvent(XMC_UART0_CH1, (uint32_t)XMC_USIC_CH_EVENT_TRANSMIT_BUFFER);
     // receiving commands from pc and change colors according to colors//
    
    if   (read_data==0x40)
    {       //load the parameters for color red
    	    XMC_BCCU_CH_SetTargetIntensity(R_LED1_CH, 0xFFF);
    	    XMC_BCCU_CH_SetTargetIntensity(G_LED1_CH, 0x000);
    	    XMC_BCCU_CH_SetTargetIntensity(B_LED1_CH, 0x000);
    	    //activate  color red
    	    XMC_BCCU_ConcurrentStartLinearWalk(BCCU0, 0x181);
    }
    
    else if (XMC_UART_CH_GetReceivedData(XMC_UART0_CH1) == 0x50)
    {
            //load the parameters for color green
    	    XMC_BCCU_CH_SetTargetIntensity(R_LED1_CH, 0x000);
    	    XMC_BCCU_CH_SetTargetIntensity(G_LED1_CH, 0xFFF);
    	    XMC_BCCU_CH_SetTargetIntensity(B_LED1_CH, 0x000);
    	    //activate color green
    	    XMC_BCCU_ConcurrentStartLinearWalk(BCCU0, 0x181);
    }
    else if (XMC_UART_CH_GetReceivedData(XMC_UART0_CH1) == 0x50)
    {
             //load the parameters for color blue
    	     XMC_BCCU_CH_SetTargetIntensity(R_LED1_CH, 0x000);
    	     XMC_BCCU_CH_SetTargetIntensity(G_LED1_CH, 0x000);
    	     XMC_BCCU_CH_SetTargetIntensity(B_LED1_CH, 0xFFF);
    	     //activate blue color
    	     XMC_BCCU_ConcurrentStartLinearWalk(BCCU0, 0x181);
    }
    
    
    
      /* Send a message via UART periodically */
      SysTick_Config(SystemCoreClock / TICKS_PER_SECOND);
    
      while(1)
      {
    	/* Infinite loop */
      }
    }
    Best Regards

+ 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.