Archive
The Usart Bla bla bla: The command line arguments #15
The getopt function
int getopt(int argc, char * const argv[], const char *optstring);
extern char *optarg;
extern int optind, opterr, optopt;
The getopt function is used to parse command option. The parameters argc and argv are the argument count and argument array as passed to the “command”. The argument optstring is a string of recognized option characters; if a character is followed by a colon, the option takes an argument.
The Usart Bla bla bla: The shell functions #14
The Shell functions
The shell contains the following functions:
- vConsoleLoop
- vEchoff
- vEchon
- iGetChar
The Usart Bla bla bla: functions #13
The Uart bla bla bla functions
NAME
uart_init — Init the UART port.
SYNTAX
#include “uart.h”
char uart_init (unsigned long ulBaudRate,
unsigned char ucParity,
unsigned char ucDataBit,
unsigned char ucStopBit
)
The Usart Bla bla bla: My USART implementation #12
My U[S]ART implementation
My USART software is based on the ATMEL application note AVR306 : Using the AVR® UART in C.
The original source code of the application note was changed to support receiver error and to support some of the capabilities of the avr UART interface databit (5..8 ), stop bit (1-2) and parity check (none, odd and even).
The Usart Bla bla bla: Interrupt 3 #11
UART Data Register Empty Interrupt
As described the USART can generate interrupt if the data register is empty. The interrupt could be enabled setting the Data Register Empty Interrupt Enable(UDRIE0) .
The USART Data Register Empty ISR will be executed until the UDRE0 is set (if the global interrupts are enabled).
The Usart Bla bla bla: Interrupt 2 #10
Interrupt from the USART
Before to speak about the interrupts implementation of the USART, I want to say a little bit regarding the “Interrupts” and then it will follow by a description of the usage of the USART interrupts if one of the following conditions happen:
The Usart Bla bla bla: Interrupt 1 #9
Frame format
The frame formats supported by the Atmega is the standard UART frame format, specifically it accepts all 30 combinations of the following as valid frame formats:
1 start bit
5, 6, 7, 8, or 9 data bits
no, even or odd parity bit
The Usart Bla bla bla: Errors #8
Receiver’s Errors
The USART Receiver has three Error Flags: Frame Error (FE0), Data OverRun (DOR0) and Parity Error (UPE0). All can be accessed by reading UCSR0A.
The Usart Bla bla bla: Send and Receive #7
Transmission
The USART Transmitter is enabled setting the Transmit Enable (TXEN) bit in the UCSR0B Register. When the Transmitter is enabled, the normal port operation of the TxD0 pin is overridden by the USART and given the function as the Transmitter’s serial output.
Latest Comments