Quantcast
Channel: Forum - Recent Threads
Viewing all articles
Browse latest Browse all 5781

S7G2 Uart Baudrate Change at Runtime

$
0
0

Hello,

I'm working at a Synergy S7G2 with SSP 1.3.0

I'm using the communications framework above the Uart driver

and I have to change the baudrate at runtime.

When I configure the Uart with different rates in the GUI of the configuartion.xml

all expected baudrates are working, so the hardware isn't the problem.

 

My changing approach :

 

static void DeviceSetBaudrate(char * bd)
{
    uint32_t baudrate;
    ssp_err_t status;
   
    strcpy (Baudrate, bd);
    BaudrateChange = true;

      
    uart_cfg_t uart_config;
    memcpy (&uart_config, g_uart_usb_rs232_chip.p_cfg, sizeof(uart_cfg_t));
    uart_config.baud_rate =  (uint32_t)  atol(bd);

 


    if (((sf_uart_comms_instance_ctrl_t *)  g_sf_comms_usb_rs232_chip.p_ctrl)->state != SF_UART_COMMS_STATE_CLOSED)
    {
        status = g_sf_comms_usb_rs232_chip.p_api->close(g_sf_comms_usb_rs232_chip.p_ctrl);
        if (status != SSP_SUCCESS)
        {
            BSP_CFG_HANDLE_UNRECOVERABLE_ERROR (0);
        }
    }


    if (((sf_uart_comms_instance_ctrl_t *)  g_sf_comms_usb_rs232_chip.p_ctrl)->state == SF_UART_COMMS_STATE_CLOSED)
    {
        status = g_sf_comms_usb_rs232_chip.p_api->open(g_sf_comms_usb_rs232_chip.p_ctrl, g_sf_comms_usb_rs232_chip.p_cfg);
        if (status != SSP_SUCCESS)
        {
            BSP_CFG_HANDLE_UNRECOVERABLE_ERROR (0);
        }
    }

 

    status = g_uart_usb_rs232_chip.p_api->close(g_uart_usb_rs232_chip.p_ctrl);
    if (status != SSP_SUCCESS)
    {
        BSP_CFG_HANDLE_UNRECOVERABLE_ERROR (0);
    }


    status = g_uart_usb_rs232_chip.p_api->open(g_uart_usb_rs232_chip.p_ctrl, &uart_config);
    if (status != SSP_SUCCESS)
    {
        BSP_CFG_HANDLE_UNRECOVERABLE_ERROR (0);
    }

}

 

 

All API's return SSP_SUCCESS, but after the low level g_uart_usb_rs232_chip.p_api->close/open

the Uart doesn't work.

I saw another discussion handling the same problem:

https://renesasrulz.com/synergy/f/synergy---forum/9889/s7g2-uart-baud-rate-setting/33269#33269

but the suggestion there :

err = g_rx_uart.p_api->baudSet(&((sf_uart_comms_ctrl_t const * )g_sf_rx_comms.p_ctrl->p_extend)->uart_ctrl, 115200);

is for SSP1.1.3 and doesn't work in SSP1.30 because there is some change in the structures I think.

 

What is the correct way to change the baudrate at runtime in SSP1.3.0 ?

 

Best regards

Heinz

 


Viewing all articles
Browse latest Browse all 5781

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>