Download BACHELOR THESIS
Transcript
• Than based on counter overflow event flag in Timer SR (Status register) register the LED
status is toggled (flag is cleared on read).
//toggle LED status on overflow event
if(TIM2->SR & 0x0001 != 0)
{
GPIOA->ODR ^= 0x2000;
}
4.3
Debugging with USART unit
The Universal Asynchronous/Synchronous Receiver/Transmitter (USART) controller is the key
component of the serial communications subsystem of computers, MCUs and other devices.
The USART takes bytes of data and transmits the individual bits in a sequential fashion. At the destination, a second USART re-assembles the bits into complete bytes. Serial transmission is
commonly used with modems and for non-networked communication between computers, terminals and other devices. There are two primary forms of serial transmission: Synchronous
and Asynchronous. Depending on the modes that are supported by the hardware, the name
of the communication sub-system will usually include ’A’ if it supports Asynchronous communications and ’S’ if it supports Synchronous communications. Both forms are described below:
• UART Universal Asynchronous Receiver/Transmitter
• USART Universal Synchronous-Asynchronous Receiver/Transmitter
STM32 has up to 3 USART interface and up to 2 additional UART interfaces. These interfaces
are one of the most important from an application development point of view. I think that
everyone who has ever been developing any embedded application will have to agree - UART
communication is a fundamental debugging tool. I will now examine the function. Almost all
examples and application provided use USART for communication with PC especially because
no additional software on PC (not on Windows Vista) is needed.
USART setting as debugging tool
• As usually first the clock signal need to be enable for dedicated USART interface
RCC->APB2ENR |= 0x4000;
//USART1
26