Skip to content

developer328/usart0-m328p

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

-ATmega328p USART0 8-bit Asynchronous, TX RX library

#WARNING:

  • If you make optimization (OPTIMIZE == 1) of this code, it will uses ~500bytes, but you will not be able to write baud rate(9600, 115200, ETC) value in 'usart_init();' because in this case baud rate to UBRRn converter is disabled, so you would write directly UBRRn(103, 8, ETC) value(check in ATmega328p datasheet).

Baud rate -> UBRRn (UX2n == 0): 9600 -> 103 38400 -> 25 115200 -> 8

  • Of this library target is small memory usage and fast execution.

  • In code are preprocesors where user is able active or deactive some modes:

  1. Active or deactive ISR by change value of ISR_EN (Default value is 1 as activated);

  2. user can change memory usage by changeing value of OPTIMIZE (Default value is 0 as disabled);

#Functions:

  • void usart_init(uint32_t baud, uint8_t speed);
  • void usart_sendChar(char acter);
  • void usart_sendStr(char *str);
  • char usart_getChar(void);
  • uint8_t usart_getStr(void);
  • void usart_clear(void);

#libraries

  • #include <avr/io.h>
  • #include <avr/interrupt.h>

#variables

  • volatile static char RECEIVED_CHAR = '\0';
  • volatile static char RECEIVED_BUFFER[_BUFFER_SIZE] = {0};
  • volatile static uint16_t RX_COUNT0 = 0;
  • volatile static uint8_t TX_READY = 1;

#ISR

  • USART_RX_vect
  • USART_TX_vect

#Configurations

  • #define OPTIMIZE 0

  • #define ISR_EN 1

#Hardware requirements

  • ATmega328p

#Software requirements

  • AVR-GCC
  • AVR-OBJCOPY
  • AVRDUDE
  • AVR-SIZE
  • MAKE

=========================================

#About developer

Releases

No releases published

Packages

No packages published