Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

same code but different output!

Status
Not open for further replies.
i had no choice since i don't have the needed crystal right now..

what do you mean by saying "to download via the serial port"? after you upload
the bootloader then it's serial programmed.

the problem is that the second atmega behaves weird, first thing it's the frequency it outputs..
which still it's not clear to me what's the reason..

and second thing it's that i have to choose the "ATmega328 on a breadboard (8 MHz internal clock)" setting or else it can't be programmed.
 
I think burt nailed it in post #16, your code thinks it's running at 16mhz, all your delays etc will be calculated for this, but your actual clock is only running at 8mhz on the chip. I initially assumed from your original post that there was only a small difference in pitch, but you confirmed in post #8 that you are only getting half the expected output frequency. Either way, it's a clocking issue between your code and what the chip is actually running at :)
 
seems you're right... but why it is running at 8Mhz? the crystal on the arduino board is at 16MHz
if it is a bootloader issue how do you think i could correct it?
 
I think the point burt was making, is that you have code loaded that expects and assumes a 16Mhz external clock oscillator, however, when you come to actually uploading it using the uno board, you are somehow actually telling the chip to use the internal 8Mhz clock oscillator instead. If you can read back the configuration fuses, you could compare those between the working chip and the non working chip. I don't think the bootloader is necessarily affecting the way the code is running, but it may do when you are actually uploading it :)

I don't use the Arduino stuff personally, so have little experience of the platform, but I have used enough of the ATmega devices to say it's definitely a screw up between what you are telling the device to use for it's clock (or what your bootloader is defaulting to, for example) and what your code expects/ believes :)
 
and second thing it's that i have to choose the "ATmega328 on a breadboard (8 MHz internal clock)" setting or else it can't be programmed.
My point exactly..... The bootloader isn't working..... The bootloader is supposed to work at 19200 baud.. But as your bootloader has been "incorectly" installed, you would need to go to settings in your IDE and set the baud to half that... 9600 baud and then you will be able to run direct from the IDE.. Your chip will still be running at half speed because of the "ATmega328 on a breadboard (8 MHz internal clock)". Once you can talk to the firmware as an arduino you will be okay...
 
There a file you have to use to use the breadboard where you get it or do you have it.
The bootloader sets the clock speed I no you can load code to the chip after installing the bootloader some how your loading code for 16mhz clock into a 8 mhz chip.

You need a hardware folder with this in it do you have it
Code:
##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard
 
Last edited:
so thank you all for the useful posts..
i was away for awhile that's why my delayed response...
now i have all the mandatory, 16mhz crystals, e.g but still i need
to use the arduino uno board as ISP, no matter what the link i gave says,
i know it can be done by replacing some files and using an older
IDE version (one thing is what be80be said).

so i'm going to do some tests to see if it is problem free and i'll let you know
from the beginning it shouldn't be that hard, but seems tha semebody doesn't
want it to be that simple for the arduino uno.
 
The ardiuino as programmer is easy to do but it will burn the bootloader to any chip as long as it fits from what I hear.
I know you can put a 168 or 328 and pick one and load it I just clone chips I made a bunch of 328 with the 16 mhz clock that I breadboarded.
 
I would try uploading same bootloader to both chips then comparing . Clearly something is different between the chips at present. Why bother with the reason
 
hi, the bootloader uploading was successful using this tutorial

**broken link removed**

now it seems it can work exactly as i want it, still i don't exactly understand why the arduino uno and IDE
can't support it directly, any explanations?

thanks
 
I think you have to have a programmer of some sort available . I have a usbtinyISP -(In Serial Programmer I think)
The IDE shows " Arduino as ISP " in the tools menu but I don't have any experience with that. If you search the Arduino.cc Forum I am sure I have seen something on this being done.
 
Last edited:
B james you are right. The only thing is the ide don't do it without a crystal you have to add to you folder a file that tells it how to set fuses. Which is in the playgroun .
 
Well I tried it with none of the above and it seemed to work but I'm not sure how to test that.

On the 1.5.8 IDE open the example ArduinoISP (ArduinoISP version 04m3)
Make sure board and port are right . Upload code

Then I tried a blink example and all seemed OK.

Now I suspect that this example just makes the arduino board into a programmer and that you must then connect up another chip to be able to upload the bootloader to it ?

Anyone know for sure? Typically they are not very clear on arduino playground
 
Last edited:
Yes you use a uio as a programmer it works great i got 10 blank chips and loaded them with the arduino uio bootloader
 
Well I tried it with none of the above and it seemed to work but I'm not sure how to test that.

On the 1.5.8 IDE open the example ArduinoISP (ArduinoISP version 04m3)
Make sure board and port are right . Upload code

Then I tried a blink example and all seemed OK.

Now I suspect that this example just makes the arduino board into a programmer and that you must then connect up another chip to be able to upload the bootloader to it ?

Anyone know for sure? Typically they are not very clear on arduino playground

i dont exactly understand what you want to say...
did you tried to upload a bootloader using the tutorials from the link i gave?

if you did then you can see that you dont need another programmer, its
pointless...

what i dont undertand is why there's no "official" way to do that for the uno
board while for other arduino boards it's possible , it is supposed that arduino
is an open project...they dont after the money....or they do??
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top