Essential functions to get started with programming an AVR ATmega MCU
- Create a new file like main.c
- Include essential.c
- In the main.c create the main function and start programming
- USART
- SPI
- ADC
- more functionalities will be added regularly.
- To initialize USART use
USARTinit(uint16_t ubrr_value)
. For variousubrr_value
visit this site or check the datasheet. - Read a character using
USARTReadChar()
. - Write a character using
USARTWriteChar(char data)
. - Read a string using
USARTReadString(int si)
. Whereint si
is the size of the string to read. - Send a string using
USARTSendString(char s[])
. Wherechar s[]
is the string to be sent.
- To initilize Master use
initMasterSPI()
. - To initilize Slave use
initSlaveSPI()
. - To transmit data in Master mode use
transmitMaster(unsigned char data)
. - To receive data in Slave mode use
receiveSlave()
.
- To initilize ADC use
initADC()
. - To read the input voltage use
readADC(uint8_t ch)
. Whereuint8_t ch
is the channel.