Download Getting Started with Stellaris ARM Cortex-M
Transcript
116 Serial Communication with the UART select the parity mode (no parity bit, even parity bit, odd parity bit, parity bit always one, and parity bit always zero, respectively). The peripheral clock is the same as the processor clock and can be obtained by using SysCtlClockGet(). Returns: None • UARTCharGet Waits for a character from the specified port. Prototype: long UARTCharGet(unsigned long ulBase) Parameters: ulBase is the base address of the UART port. Description: This function gets a character from the receive FIFO for the specified port. If there are no characters available, this function waits until a character is received before returning. Returns: Returns the character read from the specified port, cast as a long. • UARTCharPut Waits for a character from the specified port. Prototype: void UARTCharGet(unsigned long ulBase, unsigned char ucData) Parameters: ulBase is the base address of the UART port. ucData is the character to be transmitted. Description: This function sends the character ucData to the transmit FIFO for the specified port. If there is no space available in the transmit FIFO, this function waits until there is space available before returning. Returns: None 10.4 Experiment 13 10.4.1 Objective To control the intensity of LED, LD5, connected on PC7 using software PWM using parameters received over UART. Configuration of the UART is 115200, 8, N, 1. 10.4.2 Program Flow This experiment allows us to control the intensity of an LED using parameters received over UART. The block diagram is shown in Figure 10.6. The parameter is a number between 0 to 10, where 0 signifies the least intensity and 10 signifies the highest intensity. Drawing on the algorithm from the previous experiment with the addition of software PWM, the new algorithm is: