Difference between revisions of "Embedded System Tutorial UART"
From Embedded Systems Learning Academy
(→Introduction) |
|||
(10 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | Socialledge is moving to two portals. | ||
+ | * The Wiki will remain here for general references about the SJ-One board, and to document student reports. | ||
+ | * The bookstack will now be used for SJSU assignments | ||
+ | |||
+ | [http://books.socialledge.com/books/embedded-drivers-real-time-operating-systems/chapter/lesson-uart This article has been moved here] | ||
+ | |||
+ | <!-- | ||
== Introduction == | == Introduction == | ||
The objective of this lesson is to understand UART, and use two boards and setup UART communication between them. | The objective of this lesson is to understand UART, and use two boards and setup UART communication between them. | ||
Line 9: | Line 16: | ||
A micrcontroller can have multiple UARTs in its hardware, and usually UART0 is interfaced to a "USB to serial" converter chip which is then connected to your computer. In this exercise, you will write a driver for UART-2 and attempt to communicate between two boards. | A micrcontroller can have multiple UARTs in its hardware, and usually UART0 is interfaced to a "USB to serial" converter chip which is then connected to your computer. In this exercise, you will write a driver for UART-2 and attempt to communicate between two boards. | ||
− | I encourage you to fully read this article first, and here is a video about the UART0 tutorial. This is a FAST PACED video, so learn to pause the video and look over your LPC user manual frequently :) | + | I encourage you to fully read this article first, and here is a video about the UART0 tutorial. This is a FAST PACED video, so learn to pause the video and look over your LPC user manual frequently :) '''Note that I forgot to configure the PINSEL registers, which are covered by this tutorial below.''' |
− | * | + | * [https://www.youtube.com/watch?v=RU_NUPprx2Y UART Driver Video] |
<BR/> | <BR/> | ||
Line 59: | Line 66: | ||
LPC_UART0->LCR = (1 << 7); // Enable DLAB | LPC_UART0->LCR = (1 << 7); // Enable DLAB | ||
+ | /* See the formula picture to get more info. | ||
+ | * Default values of fractional dividers simplifies the equation | ||
+ | * Warning: You need to set DLM/DLL correctly, but if divider is small enough, it will fit inside DLL | ||
+ | */ | ||
LPC_UART0->DLM = 0; | LPC_UART0->DLM = 0; | ||
− | |||
− | |||
LPC_UART0->DLL = CPU_CLOCK / (16 * 9600) + 0.5); | LPC_UART0->DLL = CPU_CLOCK / (16 * 9600) + 0.5); | ||
+ | |||
LPC_UART0->LCR = 3; // 8-bit data | LPC_UART0->LCR = 3; // 8-bit data | ||
} | } | ||
Line 87: | Line 97: | ||
== Assignment == | == Assignment == | ||
− | * Locate the physical pins for a UART that is not already used by your board | + | * <b>Assignment Outline</b> |
− | * | + | *: Form 2 people teams for this assignment. |
− | * | + | *: Write a driver for UART2 or UART3 |
− | * | + | *: Do not use the pre-built driver or Uart2/3 class |
− | * | + | *: Connect your UART to your partner's UART (to his board) |
+ | *: Prove that you can send/receive data across multiple boards. | ||
+ | *: Upload Logic Analyzer Screenshot for the UART Frame. | ||
+ | * <b>Extra Credit</b>: | ||
+ | *: Use Uart interrupt to queue the received data to avoid polling. You just need to enable UART RX interrupt and then hookup an interrupt callback to do the receive. | ||
+ | * <b>Steps</b> | ||
+ | *: Locate the physical pins for a UART that is not already used by your board | ||
+ | *: Configure the PINSEL to use the pins for UART Rx/Tx | ||
+ | *: Initialize your UART at any baud rate | ||
+ | *: Write uart_putchar(char) and uart_getchar() functions | ||
+ | *: Interface your UART with someone else's board, and test the communication. | ||
+ | --> |
Latest revision as of 20:05, 25 January 2019
Socialledge is moving to two portals.
- The Wiki will remain here for general references about the SJ-One board, and to document student reports.
- The bookstack will now be used for SJSU assignments
This article has been moved here