Skip to content

Instantly share code, notes, and snippets.

@esmarr58
Created October 19, 2017 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esmarr58/04dc4fb86c377bdfd9ad6ed1c81ef4ea to your computer and use it in GitHub Desktop.
Save esmarr58/04dc4fb86c377bdfd9ad6ed1c81ef4ea to your computer and use it in GitHub Desktop.
ATMEGA328P Configurar UART
#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