From 2fe8981c13a178befe070f3a92d8590dfd475cc0 Mon Sep 17 00:00:00 2001 From: jakegoodwin Date: Fri, 13 Jan 2023 22:47:43 -0800 Subject: [PATCH] set 9600 baud rate, tested and working --- avr_usart.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/avr_usart.c b/avr_usart.c index bdae0f9..fc833ad 100644 --- a/avr_usart.c +++ b/avr_usart.c @@ -8,7 +8,7 @@ #include #include #include -#include "avr_at-09.h" +#include "avr_usart.h" //############################# @@ -23,14 +23,22 @@ int main() { led_blink(); led_blink(); _delay_ms(1000); + _delay_ms(1000); init_usart0(); //enable interrupts sei(); + unsigned char data[] = "AT+WAKE"; + while(1) { - led_blink(); + _delay_ms(1000); + //led_blink(); + for(uint8_t i = 0; i < 7; i++) { + tx_usart0(data[i]); + } + } return 0; @@ -48,16 +56,19 @@ int main() { * Description: init usart0 hardware in async mode */ void init_usart0(void) { - DDRB |= (1<>8); - UBRR0L |= (uint8_t) BT_UBRR; - + //set baud rate, this is 9600Baud with a 8Mhz clock + //UBRR0H |= (uint8_t) (BT_UBRR>>8); + //UBRR0L |= (uint8_t) BT_UBRR; + UBRR0H |= (uint8_t) (0x33>>8); + UBRR0L |= (uint8_t) 0x33; + + + //Enable recv and Transmit pins, overrides other uses. //IN the usart control and status register 0B UCSR0B = (1<