MEAM.Design - Senior Design - Team 06 (Chris, Edgar, Holt, Hughes) - Engineering Responsibilities- Mechatronics- GPS Reading
USART
GPS Setting
- Serial 0 (NMEA)4800 Baud
- 8 data Bits
- No Parity
- 1 Stop Bit
- No flow Control
USART Initialization
Steps
- set the baud rate
- set frame format
- enable the Transmitter or the Receiver depending on the usage.
Sample Code
void USART_Init( unsigned int baud )
{
/* Set baud rate */
UBRR1H = (unsigned char)(baud>>8);
UBRR1L = (unsigned char)baud;
/* Enable receiver and transmitter */
UCSR1B = (1<<RXEN1)|(1<<TXEN1);
/* Set frame format: 8data, 2stop bit */
UCSR1C = (1<<USBS1)|(3<<UCSZ10);
}
|
Calculating UBBRn (baud in the sample code) for a given Baud rate
UBBRn = baud =fosc/(Baud_rate*16) -1 (:commentboxchrono:)