diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2009-05-08 11:05:41 +0000 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2009-05-08 11:05:41 +0000 |
commit | 9858f5294bcbcb4b3aa899553951402df14dd784 (patch) | |
tree | 2f0285116b2a557b9dfbfdbed539e1bdf37f7ded /bootloaders/atmega/ATmegaBOOT_168.c | |
parent | 3531cb49f43e067779963beb2b7fc4b098ad769f (diff) |
Adding ATmega328 bootloader for the Pro and Pro Mini running at 8 MHz (3.3V). Uses the USART0 double speed mode, which according to Nathan from Sparkfun, is necessary to achieve reliable communication at 57600 baud.
Diffstat (limited to 'bootloaders/atmega/ATmegaBOOT_168.c')
-rwxr-xr-x | bootloaders/atmega/ATmegaBOOT_168.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bootloaders/atmega/ATmegaBOOT_168.c b/bootloaders/atmega/ATmegaBOOT_168.c index 8ea1509..2b9fefa 100755 --- a/bootloaders/atmega/ATmegaBOOT_168.c +++ b/bootloaders/atmega/ATmegaBOOT_168.c @@ -370,8 +370,16 @@ int main(void) UCSRA = 0x00;
UCSRB = _BV(TXEN)|_BV(RXEN);
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
+
+#ifdef DOUBLE_SPEED
+ UCSR0A = (1<<U2X0); //Double speed mode USART0
+ UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*8L)-1);
+ UBRR0H = (F_CPU/(BAUD_RATE*8L)-1) >> 8;
+#else
UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
+#endif
+
UCSR0B = (1<<RXEN0) | (1<<TXEN0);
UCSR0C = (1<<UCSZ00) | (1<<UCSZ01);
|