I use an XL-216 processor with "lib-uart 3.1.0" to implement a single UART interface.
The default configuration of the UART is 115200 and the program work fine, transmit and receive without error.
During the execution program I want to change the speed of the UART to 56700, but after that I lost the communication with the host (host uart correctly changed at 57600 after the switch on xcore).
I need to change the speed in TX and RX.
I try to simplify and compact the code:
Code: Select all
...
int main (void) {
...
interface uart_rx_if i_rx;
interface uart_tx_if i_tx;
input_gpio_if i_gpio_rx[1];
output_gpio_if i_gpio_tx[1];
uart_config_if i_UART_config;
...
par {
on tile[0]: output_gpio(i_gpio_tx, 1, p_uart_tx, null);
on tile[0]: uart_tx(i_tx, i_UART_config, UARTBAUDRATE, UART_PARITY_NONE, 8, 1, i_gpio_tx[0]);
on tile[0].core[0] : input_gpio_with_events(i_gpio_rx, 1, p_uart_rx, null);
on tile[0].core[0] : uart_rx(i_rx, null, RX_BUFFER_SIZE, UARTBAUDRATE, UART_PARITY_NONE, 8, 1, i_gpio_rx[0]);
on tile[0]: {
Function1();
MainUARTcomunication(i_tx, i_rx, i_UART_config);
}
}
}
...
void MainUARTcomunication(client uart_tx_if uartTX, client uart_rx_if uartRX, client uart_config_if uart_cfg) {
...
while(1) {
...
Function2();
...
if (event) {
uart_cfg.set_baud_rate(BaudRate); //Change the baud rate
}
...
}
}
I also tried with the definition of another "uart_config_if" interface for the RX tread and call twice set_baud_rate, but it don't work:
Code: Select all
...
int main (void) {
...
interface uart_rx_if i_rx;
interface uart_tx_if i_tx;
input_gpio_if i_gpio_rx[1];
output_gpio_if i_gpio_tx[1];
uart_config_if i_UART_config;
uart_config_if i_UART_RX_config;
...
par {
on tile[0]: output_gpio(i_gpio_tx, 1, p_uart_tx, null);
on tile[0]: uart_tx(i_tx, i_UART_config, UARTBAUDRATE, UART_PARITY_NONE, 8, 1, i_gpio_tx[0]);
on tile[0].core[0] : input_gpio_with_events(i_gpio_rx, 1, p_uart_rx, null);
on tile[0].core[0] : uart_rx(i_rx,i_UART_RX_config, RX_BUFFER_SIZE, UARTBAUDRATE, UART_PARITY_NONE, 8, 1, i_gpio_rx[0]);
on tile[0]: {
Function1();
MainUARTcomunication(i_tx, i_rx, i_UART_config, i_UART_RX_config);
}
}
}
...
void MainUARTcomunication(client uart_tx_if uartTX, client uart_rx_if uartRX, client uart_config_if uart_cfg, client uart_config_if uart_RX_cfg) {
...
while(1) {
...
Function2();
...
if (event) {
uart_cfg.set_baud_rate(BaudRate); //Change the tx baud rate
uart_RX_cfg.set_baud_rate(BaudRate); //Change the rx baud rate
}
...
}
}
Regards
Piero