char calculate_freq(void) {
if (s==125){
return 'a';
}
return 'b';
}
int main (void)
{
char ReceivedByte;
UCSR0B = (1 << RXEN0) | (1 << TXEN0); // Turn on the transmission and reception circuitry
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); // Use 8-bit character sizes
UBRR0H = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value into the high byte of the UBRR register
UBRR0L = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register
my_timer_init();
sei();
for (;;) // Loop forever
{
while ((UCSR0A & (1 << RXC0)) == 0) {}; // Do nothing until data have been received and is ready to be read from UDR
ReceivedByte = UDR0; // Fetch the received byte value into the variable "ByteReceived"
ReceivedByte = calculate_freq();
while ((UCSR0A & (1 << UDRE0)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it
UDR0 = ReceivedByte; // Echo back the received byte back to the computer
}
}