Created
October 19, 2017 18:54
-
-
Save esmarr58/04dc4fb86c377bdfd9ad6ed1c81ef4ea to your computer and use it in GitHub Desktop.
ATMEGA328P Configurar UART
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define FOSC 12000000 | |
#define BAUD 9600 | |
#define Rvelocidad FOSC/16/BAUD-1 | |
void main(void){ | |
//.... | |
Inicializar_UART(Rvelocidad); | |
} | |
void Inicializar_UART(unsigned int regUART){ | |
//Configurla la velocidad | |
UBRR0H = (unsigned char) (regUART >> 8); | |
UBRR0L = (unsigned char) ubrr; | |
//Habilitar la recepción y transmisión serial | |
UCSR0B = (1 << RXEN0 ) | (1 << TXEN0 ); | |
//Configurar 8 bits, 2 bits de parada | |
UCSR0C = (1 << USBS0 ) | (3 << UCSZ00); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment