Better Debugging of Embedded via a Debug Port ECE152
Overview Why have a Debug Port? What is a UART? How does the Wunderboard UART work? #DEFINE
What is a Debug Port? JTAG Digital Satellite, Later ECE courses I2C Proprietary AVR serial ISP Serial (UART)
Understanding Asynchronous Serial (UART) Agreed on message format Start and Stop Bits Parity Agreed on speed
AVR Hardware UART Peripheral
Handling a UART in software Important Registers USART I/O Data Register n– UDRn USART Control and Status Register n A – UCSRnA USART Control and Status Register n B – UCSRnB USART Control and Status Register n C – UCSRnC USART Baud Rate Registers – UBRRnL and UBRRnH
Baud Rate Speed of transmission Units of bits per second (bps or baud)
Start and Stop Bits 1 start bit, 1 or 2 stop bits USBSn bit in UCSRnC
FTDI UART to USB chip Modern computers do not have RS232 USB to UART converters maintain a simple interface FTDI Chip works on Windows, Mac and Linux Often driverless installation Can be disabled to allow for Wunderboard to Wunderboard serial communication
Voltages Wunderboard 3.3V FTDI 3.3 to 5V Old School RS232 ±12V
Enabling and disabling Debug ports Why Enable and Disable Debug? Code Size Code Speed Security
#ifdef and Preprocessor Statements Preprocessor statements happen BEFORE compilation #define DEBUG #ifdef DEBUG Serial code goes here... #ifdef
Things to Remember Watch your flags to avoid buffer over run Use #define to remove code before compilation