I was trying to send data to atmega8 board (picture below).
The crystal on the board reads kds-16.000
the code inside of atmega8 is
(recieve bit and send it to portC ,UBRR=0067)
#include <avr/io.h>
int main(void)
{
DDRC=0xFF;
UBRRH=0X00;
UBRRL =0x67;
UCSRB= 0x10;
UCSRC=0x86;
while(1){
while(!(UCSRA & 0x80));
PORTC=UDR;
}
return(0);
}
there's an led on portC's second pin which will toggle on-off if the code works fine
I am sending 0xFF and then 0x00 to atmega8 using chinese arduino nano.
but the thing is-My expecation was the following code would work-
(send 0xFF and 0x00 alternativly after short delay baud rate
9600)
void setup() {
Serial.begin(9600,SERIAL_8N1);
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
while(1){
Serial.write(15); // turn the LED on (HIGH is the voltage level)
delay(1000);
Serial.write(1); // turn the LED on (HIGH is the voltage level)
delay(1000); }}
But the one that works is-
(send 0xFF and 0x00 alternativly after short delay baud rate
1200)
void setup() {
Serial.begin(1200,SERIAL_8N1);
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
while(1){
Serial.write(15); // turn the LED on (HIGH is the voltage level)
delay(1000);
Serial.write(1); // turn the LED on (HIGH is the voltage level)
delay(1000); }}
My calculation says that an atmega8 running at 16mhz should be set for 9600 baud rate if the UBRR is set to 0067
but when I did that,Why does it work only at baud rate of 1200
Is the crystal,a fake and is 8 times slower than what I think?
btw..The fuse values are unchanged sinced it's out of the box.
another question.
is there a ciircuit to test the frequency of a crystal.I have many unmarked crystals.
Sorry for a wall of text