Sure,
Configuration:
- RTOS: ThreadX
- One thread with sf_uart_comms framework (channel 5, asynchronous mode enabled, RXI TXI TEI and ERI with priority 6)
- Pins:
- P510: Peripheral mode, None, Medium, CMOS, RXD5_SCL5_MISO5
- P509: Peripheral mode, None, Medium, CMOS, TXD5_SDA5_MOSI5
- PB06: Output mode, High, CMOS, GPIO
- Board -> RS485 communication:
- DIP SWITCH: SLW, SPB and HALF ON
- Phisical connection:
- Connect B-Z and A-Y to get RS485
- Connect A, B and GND to the RS485 device
CODE:
ssp_err_t ReturnVal;
uint8_t Write_Message[16], Read_Message[16];
memcpy(Write_Message, "Hello World\n", 12);
//Open the uart
ReturnVal = g_sf_comms0.p_api->open(g_sf_comms0.p_ctrl, g_sf_comms0.p_cfg);
while (1)
{
tx_thread_sleep (10);
//write to uart
g_ioport.p_api->pinWrite(IOPORT_PORT_11_PIN_06, IOPORT_LEVEL_HIGH);
ReturnVal = g_sf_comms0.p_api->read(g_sf_comms0.p_ctrl, Write_Message, sizeof(Write_Message), TX_WAIT_FOREVER);
tx_thread_sleep (10);
//read from uart (an external source has to write something)
g_ioport.p_api->pinWrite(IOPORT_PORT_11_PIN_06, IOPORT_LEVEL_LOW);
ReturnVal = g_sf_comms0.p_api->read(g_sf_comms0.p_ctrl, Read_Message, sizeof(Read_Message), TX_WAIT_FOREVER);
//!This will block the execution if there's no message. Change the timeout to change this behavior
}
Regards,
isaenz.