You are on page 1of 2

Eka Kakalashvili

RED ID: 823419435

Group 2

LAB REPORT 3
Description of program

In the third lab called Serial I/O (USART), we should have written a code that transmits
and outputs characters in our RED IDs, through AVR Xplained mini 328 board, which has built-in
hardware - USART port. To do so, I used The Atmel Xplained Mini board as a transmitter,
installed and set up the PUTTY which helped me to make computer as a serial receiver. As
requested I transmitted red id as a serial string, set up the baud rate to 9600 both in a putty and
Atmel studio program, used 8 data bits (UCSR0C|=(1<<UCSZ00)|(1<<UCSZ01)), made the
transmit status register to wait until it is ready and free (inside of 1st while statement) and
finally, made 500ms delay–( _delay_ms(500)), which is repeating continuously at given speed.

Description of the result

The purpose of this assignment is to output the red id with the new line as an infinite loop
both in Atmel studio Data visualizer and in a putty. As you can see in the provided video, all of
these requirements and check points are fulfilled. Program outputs my RED ID in both resulting
screens, following with the new line and in an infinite loop. Therefore, everything was set up
appropriately.

Source code
/*
* GccApplication8.c
*
* Created: 11/10/2020 12:49:42 AM
* Author : eka
*/

#include <avr/io.h>
#include <util/delay.h>
#define F_CPU 16000000UL
#define BAUD 9600
#define BAUDRATE ((F_CPU)/(BAUD*16UL)-1)

void uart_initilation(){
UBRR0H=(BAUDRATE>>8);
UBRR0L=103;
UCSR0B|=(1<<TXEN0)|(1<<RXEN0); // transmitter
UCSR0C|=(1<<UCSZ00)|(1<<UCSZ01); // my data in 8 bits
}

void uart_transmit(unsigned char data){


while(!(UCSR0A & (1<<UDRE0)));
UDR0=data;
}

int main(void)
{
uart_initilation();
char data[]="823419435\n";
while (1)
{
for (int i=0; data[i]!='\0';i++)
{
char temp = data[i];
uart_transmit(temp);
_delay_ms(500);
}

}
}

You might also like