PV198 – One-chip Controllers, SPI / Dávid Danaj 1 PV198 – One-chip Controllers UART PV198 – One-chip Controllers, SPI / Dávid Danaj Content 1.What is UART 2.What is it used for 3.How does it work 4.FRDM-K66F UART 5.USB to UART Bridge 6.Application • 2 PV198 – One-chip Controllers, SPI / Dávid Danaj What is UART §UART – Universal Asynchronous Receiver-Transmitter • §Serial communication • 3 PV198 – One-chip Controllers, SPI / Dávid Danaj What is it used for §Intra-board communication • §Sensors §GPS §Bluetooth §Modems • • • • • 4 How does it work – Scheme PV198 – One-chip Controllers, SPI / Dávid Danaj 5 RX TX GND UART1 RX TX GND UART2 How does it work PV198 – One-chip Controllers, SPI / Dávid Danaj §2 wires (Receive – RX, Transmit – TX) §1 to 1 communication §Works without clock signal §Requires same settings for devices (baud rate, parity, etc.) §Asynchronous §Full-duplex 6 How does it work – Message PV198 – One-chip Controllers, SPI / Dávid Danaj 7 K66 Sub-Family Reference Manual How does it work – Message PV198 – One-chip Controllers, SPI / Dávid Danaj 8 http://www.circuitbasics.com/basics-uart-communication/ How does it work – Settings PV198 – One-chip Controllers, SPI / Dávid Danaj 9 §Baud rate (typical 9600 – 115200) §Number of data bits (8 – 9) §Number of stop bits (1 – 2) §Parity bit (disabled / odd / even) • • FRDM-K66F UART §5 UART modules §RS-485 support §Hardware flow control (RTS/CTS) §9-bit UART support §Interrupts §TX/RX FIFO • PV198 – One-chip Controllers, SPI / Dávid Danaj 10 USB to UART Bridge §Silicon Labs – link §Might be needed to install driver • • • • PV198 – One-chip Controllers, SPI / Dávid Danaj 11 Application §Create an application that reads data from UART and sends the data back to PC §Update your code to rotate received character +2 PV198 – One-chip Controllers, SPI / Dávid Danaj 12 Application – Step-by-step guide 1.Setup pin routing -PTB11 as UART3_TX, PTB10 as UART3_RX 2.Setup UART peripheral -UART3 with 8 bit data, 1 stop bit, no parity, 115200 baudrate 3.Use API: UART_ReadBlocking,UART_WriteBlocking 4.Connect “USB to UART bridge” to a board 5.When “USB to UART bridge” is connected to a PC, it appears in Device Manage in “Ports (COM & LPT)” as “COM” port. 6.Open terminal application (or Terminal view in MCUXpresso IDE) and connect to correct COM port with your UART settings PV198 – One-chip Controllers, SPI / Dávid Danaj 13 Application – Step-by-step guide PV198 – One-chip Controllers, SPI / Dávid Danaj 14 Application 2 §Install pyserial: -powershell: python.exe -m pip install pyserial §Open Python3 §Use import Serial §Using Serial send string to device §Check if device correctly encrypted string PV198 – One-chip Controllers, SPI / Dávid Danaj 15 Homework §On device side you will receive 3 characters §These 3 characters represent RGB values in order §Your goal is to set LED color correctly according to received values §Due to testing, set the Timer Output Frequency in the FTM peripheral to “262144hz” PV198 – One-chip Controllers, SPI / Dávid Danaj 16