UART ON SYNERGY SK-S7G2

Pocket

次に定番のUARTを使っています。SK-S7G2は、SCI3をRS-232SかRS-485に使用できます。RS-232C側は、トランシーバにつながっています。。TTLレベルで通信したかったのでRS-485の設定にしてP76、P77ピンで通信しました。
Jpeg
まずUART用のスレッドを追加します。
UARTDriver on r_spi_uart
Communications Framework on sf_uart_comms
SCI Common
の3つのモジュールをスレッドに追加します。
2016-01-17 (5)
SCI CommonのプロパティでUARTを有効にします。
2016-01-17 (3)
UART Driverのプロパティに通信設定を行います。
2016-01-17 (7)2016-01-17 (6)  2016-01-17 (1)  2016-01-17 (4)2016-01-17 (8)
コードジェネレートしてコンパイル通りました。
インスタンスはできているのでAPIを呼び出すと案外簡単にループバックが完成しました。
/* UART Thread entry function */
void uart_thread_entry(void)
{
/* TODO: add your own code here */

// Creates a variable for the error
ssp_err_t ssp_err_g_sf_comms;

// Creates a destination buffer
uint8_t dest_buffer[16];

while (1)
{
// Reads 16bytes from the SCI channel5 as an UART port.
// Wait until your callback funtion is called from SCI ISR.
ssp_err_g_sf_comms = g_sf_comms.p_api->read(g_sf_comms.p_ctrl, dest_buffer, 1, 100);
if (SSP_SUCCESS == ssp_err_g_sf_comms)
{
// Writes 16bytes to the SCI channel5 as an UART port.
ssp_err_g_sf_comms = g_sf_comms.p_api->write(g_sf_comms.p_ctrl, dest_buffer, 1, 100);
}
}
}

Post Tagged with ,

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください