set 9600 baud rate, tested and working
This commit is contained in:
parent
290629670d
commit
ae1a5d5947
29
avr_usart.c
29
avr_usart.c
|
@ -8,7 +8,7 @@
|
|||
#include <avr/interrupt.h>
|
||||
#include <avr/sleep.h>
|
||||
#include <util/delay.h>
|
||||
#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<<TX_DDR)|(0<<RX_DDR);
|
||||
PORTD |= (0<<TX_PIN)|(0<<RX_PIN);
|
||||
//DDRB |= (1<<TX_DDR)|(0<<RX_DDR);
|
||||
//PORTD |= (0<<TX_PIN)|(0<<RX_PIN);
|
||||
|
||||
//setup stuff for usart communications.
|
||||
|
||||
//set baud rate, this is 9600Baud with a 1Mhz clock
|
||||
//so it should be equal to 6 or 0x006
|
||||
UBRR0H |= (uint8_t) (BT_UBRR>>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<<RXEN0) | (1<<TXEN0);
|
||||
|
|
Loading…
Reference in New Issue