松翰SONiX MCU:SN8F5708 UART 通用非同步收發傳輸器

這裡先說明什麼麼是 UART

UART 全名為 通用非同步收發傳輸器(Universal Asynchronous Receiver/Transmitter),或稱 非同步收發傳輸器

UART他是電腦/MCU或硬體中的一部分(資料傳輸介面),可以將數據透過串列通訊和平行通訊間執行與同樣有UART的裝置作為傳輸與轉換

UART追加同步方式的序列訊號變換電路後,被稱為:通用同步非同步收發傳輸器USART(Universal Synchronous Asynchronous Receiver Transmitter)

---------------------------------------------------------------------------------------------------------------

回到文章主題: 松翰SONiX,MCU:SN8F5708 UART 通用非同步收發傳輸器

The UART provides a flexible full-duplex synchronous/asynchronous receiver/transmitter.
UART提供了靈活的全雙工同步/異步接收器/發送器。

The serial interface provides an up to 0.25MHz flexible full-duplex transmission.
串行接口提供高達0.25MHz的靈活全雙工傳輸。

It can operate in four modes
它可以在四種模式下運行

Mode0 is a shift register mode and operates as synchronous transmitter/receiver.
模式0是移位寄存器模式,用作同步發送器/接收器。

In Mode1-Mode3 the UART operates as asynchronous transmitter/receiver with 8-bit or 9-bit data.
在Mode1-Mode3中,UART用作具有8位或9位數據的異步發送器/接收器。

The transfer format has start bit, 8-bit/ 9-bit data and stop bit.
傳輸格式具有起始位,8位/ 9位數據和停止位。

Transmission is started by writing to the S0BUF register.
通過寫入S0BUF寄存器開始發送。

After reception, input data are available after completion of the reception in the S0BUF register.
接收後,輸入數據在S0BUF寄存器中接收完成後可用。

TB80/RB80 bit can be used as the 9th bit for transmission and reception in 9-bit UART mode.
TB80 / RB80位可用作9位UART模式下的發送和接收的第9位。

Programmable baud rate supports different speed peripheral devices.
可編程的波特率支持不同速度的外圍設備。

---------------------------------------------------------------------------------------------------------------

The UART features include the following:
UART功能包括:

 Full-duplex, 2-wire synchronous/asynchronous data transfer.
全雙工2線同步/異步數據傳輸

 Programmable baud rate.
可編程的波特率。

 8-bit shift register: operates as synchronous transmitter/receiver
8位移位寄存器:用作同步發送器/接收器

 8-bit / 9-bit UART: operates as asynchronous transmitter/receiver with 8 or 9-bit data bits and programmable baud rate.
8位/ 9位UART:用作具有8位或9位數據位和可編程波特率的異步發送器/接收器。

---------------------------------------------------------------------------------------------------------------

UART Operation

The UART UTX and URX pins are shared with GPIO.
UART UTX和URX引腳與GPIO共享。

In synchronous mode, the UTX/URX shared pins must set output high by software.
在同步模式下,UTX / URX共享引腳必須通過軟件將輸出設置為高電平。

In asynchronous mode (8-bit/9-bit UART), the UTX shared pins must set output high and URX set input high by software.
在非步模式(8位/ 9位UART)下,UTX共享引腳必須通過軟件將輸出設置為高電平,而URX輸入設置為高電平。

Thus, URX/UTX pins will transfers to UART purpose.
因此,URX / UTX引腳將轉換為UART目的。

When UART disables, the UART pins returns to GPIO last status.
當UART禁用時,UART引腳返回到GPIO的最後狀態。

The UART supports interrupt function.
UART支持中斷功能。

ES0 is UART0 transfer interrupt function control bit.
ES0是UART0傳輸中斷功能控制位。

UART transmitter and receiver interrupt function is controlled by ES0.
UART發送器和接收器中斷功能由ES0控制。

When ES0 = 0, disable transmitter/receiver interrupt function.
當ES0 = 0時,禁用發送器/接收器中斷功能。

When ES0 = 1, enable UART transmitter/ receiver interrupt function.
當ES0 = 1時,使能UART發送器/接收器中斷功能。

UART transmitter and receiver interrupt function are share interrupt vector 0x0023.
UART發送器和接收器中斷功能是共享中斷向量0x0023。

When UART interrupt function enable, the program counter points to interrupt vector to do UART interrupt service routine after UART operating.
當UART中斷功能使能時,程序計數器指向中斷向量以在UART操作後執行UART中斷服務程序。

TI0/RI0 is UART0 interrupt request flag, and also to be the UART operating status indicator when interrupt is disabled.
TI0 / RI0是UART0中斷請求標誌,並且在禁止中斷時也用作UART工作狀態指示器。

TI0 and RI0 must clear by software.
TI0和RI0必須通過軟件清除。

UART provides four operating mode (one synchronous and three asynchronous) controlled by S0CON register.
UART提供由S0CON寄存器控制的四種工作模式(一種同步和三種異步)。

These modes can be support in different baud rate and communication protocols.
這些模式可以支持不同的波特率和通信協議。
SM[0:1]
00: Mode 0
01: Mode 1
10: Mode 2
11: Mode 3


---------------------------------------------------------------------------------------------------------------

Mode 0: Synchronous 8-bit Receiver/Transmitter

Mode0 is a shift register mode. It operates as synchronous transmitter/receiver.
模式0是移位寄存器模式。它用作同步發送器/接收器。

The UTX pin output shift clock for both transmit and receive condition.
UTX引腳在發送和接收條件下都輸出移位時鐘。

The URX pin is used to transmit and receive data.
URX引腳用於發送和接收數據。

8-bit data will be transmit and receive with LSB first. The baud rate is fcpu/12.
首先使用LSB發送和接收8位數據。波特率為fcpu / 12。

Data transmission is started by writing data to S0BUF register.
通過將數據寫入S0BUF寄存器開始數據傳輸。

In the end of the 8th bit transmission, the TI0 flag is set.
在第8位傳輸結束時,設置TI0標誌。

Data reception is controlled by REN0 bit and clearing RI0 bits.
數據接收由REN0位和RI0位清零控制。

When REN0=1 and RI0 is from 1 to 0,data transmission starts and the RI0 flag is set at the end of the 8th bit reception.
當REN0 = 1且RI0從1到0時,數據發送開始,並且在第8位接收結束時設置RI0標誌。

Mode 1: 8-bit Receiver/Transmitter with Variable Baud Rate
模式1:具有可變波特率的8位接收器/發送器

Mode1 supports an asynchronous 8-bit UART with variable baud rate.
模式1支持具有可變波特率的異步8位UART。

The transfer format includes 1 start bit, 8 data bits (LSB first) and 1 stop bit.
傳輸格式包括1個起始位,8個數據位(低位在先)和1個停止位。

Data is transmitted by UTX pin and received by URX pin.
數據通過UTX引腳發送,並通過URX引腳接收。

The baud rate clock source can be baud rate generator or T1 overflow controlled by BD bit.
波特率時鐘源可以是波特率發生器,也可以是由BD位控制的T1溢出。

When BD=0, the baud rate clock source is from T1 overflow.
當BD = 0時,波特率時鐘源來自T1溢出。

When BD=1, the baud rate clock source is from baud rate generator controlled by S0RELH and S0RELL.
當BD = 1時,波特率時鐘源來自S0RELH和S0RELL控制的波特率發生器。

Additionally, the baud rate can be doubled by SMOD bit.
此外,波特率可以通過SMOD位加倍。

Data transmission is controlled by REN0 bit.
數據傳輸由REN0位控制。

After transmission configuration, load transmitted data into S0BUF, and then UART starts to transmit the pocket.
完成傳輸配置後,將傳輸的數據加載到S0BUF中,然後UART開始傳輸數據包。

The TI0 flag is set at the beginning of the stop bit.
TI0標誌在停止位的開頭設置。

Data reception is controlled by REN0 bit. When REN0=1, data reception function is enabled.
數據接收由REN0位控制。當REN0 = 1時,啟用數據接收功能。

Data reception starts by receiving the start bit for master terminal,  URX detects the falling edge of start bit, and then the RI0 flag is set in the middle of a stop bit.
通過接收主終端的起始位開始數據接收,URX檢測到起始位的下降沿,然後在停止位的中間設置RI0標誌。

Until reception completion, input data is stored in S0BUF register and the stop bit is stored in RB80.
在接收完成之前,輸入數據存儲在S0BUF寄存器中,停止位存儲在RB80中。





待續.....









學習邏輯
1.尋找價值感---思考學習後得到的意義---尋找價值感與工作鏈結得到更好的目標
2.設立學習目標---步驟學習---逐步累積
3.回饋/追蹤---產生反省---持續提升能力---過程痛苦是成長過程---會讓人掙扎的地方 就是會讓人成長的地方

自我提升方式
1.閱讀
2.寫作
3.演講

學習分為三類型
1.目標型-以目標方式去訓練達成結果
2.學習型-從過程開始學習到達結果
3.努力型-土法煉鋼方式完成結果

以上共勉



留言