Author Topic: Fake crystal?  (Read 1270 times)

0 Members and 1 Guest are viewing this topic.

Offline RajTopic starter

  • Frequent Contributor
  • **
  • Posts: 701
  • Country: in
  • Self taught, experimenter, noob(ish)
Fake crystal?
« on: November 09, 2017, 08:36:36 am »
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)
Quote
#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)
Quote
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)

Quote
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
« Last Edit: November 09, 2017, 08:43:12 am by Raj »
 

Offline RajTopic starter

  • Frequent Contributor
  • **
  • Posts: 701
  • Country: in
  • Self taught, experimenter, noob(ish)
Re: Fake crystal?
« Reply #1 on: November 09, 2017, 08:43:28 am »
Use an oscilloscope to tap XOUT pin.
Wish I had one
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3322
  • Country: gb
Re: Fake crystal?
« Reply #2 on: November 09, 2017, 09:15:47 am »
Check the configuration fuse settings, the AVR may be running from the internal RC oscillator rather than the crystal.
 
The following users thanked this post: Raj

Offline RajTopic starter

  • Frequent Contributor
  • **
  • Posts: 701
  • Country: in
  • Self taught, experimenter, noob(ish)
Re: Fake crystal?
« Reply #3 on: November 09, 2017, 09:41:00 am »
ouch! problem with fuse-
high D9   low E1   lock FF
(internal rc oscallator,at 1mhz)
But it's still half the story
16/1 not equal to 9600/1200
« Last Edit: November 09, 2017, 12:25:40 pm by Raj »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf