Hi everyone, again I found some problem when I tried to upload the program that will take my character input and display the ASCII value on the LEDs based on the "Make: AVR Programming" book and I did the modification to make it work on my UNO clone board (ATMega 328p SMD Based) that runs on default at 16 MHz clock speed but I change my MCU to run at 1MHz clock speed, my modification code looks as follows:
/*
A simple test of serial-port functionality.
Takes in a character at a time and sends it right back out,
displaying the ASCII value on the LEDs.
*/
#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <avr/power.h>
#include "pinDefines.h"
#include "uart.h"
int main(void) {
clock_prescale_set(clock_div_16); //run your 16MHz hardware at 1MHz
char serialCharacter;
// -------- Inits --------- //
LED_DDR = 0xff; /* set up LEDs for output */
initUSART();
printString("Hello World!\r\n"); /* to test */
// ------ Event loop ------ //
while (1) {
serialCharacter = receiveByte();
transmitByte(serialCharacter);
LED_PORT = serialCharacter;
/* display ascii/numeric value of character */
} /* End event loop */
return (0);
}
but when I tried to upload the program, there was this error and I believe that my code is not being uploaded properly to the board:
1. there is so-called like a "not in sync" error code as shown in the below picture
Is it possible for everyone here to check what was my issue here and help me to solve it? because I have done these following steps:
1. include all the required .h file and .c file in my project
2. setting my baud rate become 9600 in my USART.h file as shown in the following picture
2. and the USART.c file that I include has a following code: