The Elektor Forum will close. See also this link. From Friday March 1st it is no longer possible to log in to the forum. However, the content of the forum will remain visible until the end of March. As of April 1st the forum will definitely go off the air.

T-board test with atmega 328

The topic on number crunching

T-board test with atmega 328

Postby Nixies » Fri Jan 30, 2015 9:43 pm

Hello,
I'have aquired the t-board recently and I have tried the first helloworld. The problème is that the clock, supposed to generate 1 second flashing led is not that accurate. I'm working without crystal, so I modified the commande F_CPU with the value 1000000 (this is the value which allows me to approach as much as possible to the second). If I compare the pace of this 1 second clock, it is slighly different than the one of my Watch. I don't understand why. I've tried it under linux (avr-gcc + avrdude) and Under Windows 7 but the result is the same, a second a bit longer than one second :?
Is it possible that the problem comes from the fact that I don't use any cristal ?
I've tried with a cristal of 4 MHz, modifying the F_CPU with 4000000 but it does not work, probably because I need to configure the fuse with external cristal, but I don't know how to do it :-(

Help from you should be really welcome :-)
Thank you very much.
Nixies
Nixies
 
Posts: 11
Joined: Fri Jan 30, 2015 9:04 pm

Re: T-board test with atmega 328

Postby ag » Sat Jan 31, 2015 1:29 pm

Hi Nixies,

If I compare the pace of this 1 second clock, it is slighly different than the one of my Watch.


How much different?

I've tried with a cristal of 4 MHz, modifying the F_CPU with 4000000


According to the datasheet, the internal clock of the ATMega328 is 8 MHz, so I don't think you can improve the tolerance by using a 4 MHz external crystal.

but it does not work, probably because I need to configure the fuse with external cristal, but I don't know how to do it :-(


The nice thing about the Arduino IDE is that beginners do not have to worry about setting fuses. I recommend you use the Arduino IDE until you have gained more experience.

Regards,
Ag
ag
 
Posts: 533
Joined: Thu Jan 02, 2014 10:37 am

Re: T-board test with atmega 328

Postby Nixies » Sat Jan 31, 2015 9:50 pm

Hello Ag,
To be honest I want to avoid Arduino, because I really want to understand what is Inside the µc.
Difficult to describe the difference, but if if want to make a clock with this kind of programme, it will quickly drift :-(
I modified the fuses by means of AVR Studio (Menu Tools -> Device programming) to use the 4 MHz Crystal, that's why change the F_CPU. In the meantime I read some docs and I saw that I did not use the good fuse option. I will try again. I let you know.
Ag, do you have the possibility to try this king of code ?

Anyway, thank you very much.
Nixies
Nixies
 
Posts: 11
Joined: Fri Jan 30, 2015 9:04 pm

Re: T-board test with atmega 328

Postby ag » Sat Jan 31, 2015 10:24 pm

Hi Nixies,

I do not have a T-Board, but I do have an Arduino with a ATMega328 (Duemilanove), which is basically the same. So yes, I can test such code. That is why I wanted to know how far off your timing is running. Fuse settings are always a problem for beginners, but with reading the docs to find out how, you are going in the right direction. You might want to visit AVR Freaks at http://www.avrfreaks.net to get some good beginners tutorials and assistance. ;)

Regards and LoL,
Ag
ag
 
Posts: 533
Joined: Thu Jan 02, 2014 10:37 am

Re: T-board test with atmega 328

Postby Nixies » Sat Jan 31, 2015 10:45 pm

Thank you Ag for this link. I will take a look to it.
Speek to you later.
Regards,
Nixies
Nixies
 
Posts: 11
Joined: Fri Jan 30, 2015 9:04 pm

Re: T-board test with atmega 328

Postby Nixies » Sun Feb 01, 2015 6:11 pm

I've tried with the second T-board, embedding a ATtiny 84, and the second is a second :D
I will try to search why it is not the same with the atmega328.
Nixies
 
Posts: 11
Joined: Fri Jan 30, 2015 9:04 pm

Re: T-board test with atmega 328

Postby Nixies » Sat Feb 07, 2015 11:42 am

I changed the mega 328 and it is working.
Honestly I don't know why it did not work with the first one. Probably the fuses :(
Nixies
 
Posts: 11
Joined: Fri Jan 30, 2015 9:04 pm


Return to Microcontrollers & Embedded

Who is online

Users browsing this forum: No registered users and 2 guests

cron