I have done this lots of times, but today something strange happened.
I have a atmega328p on a pcb , with 16Mhz oscillator and 2 capacitors of 20p .
I have uploaded a blinking software from the examples in the IDE , to check if things works.
I have uploaded using the tiny programmer using the spi pins .
The led is connected with resistor to pin 13 .
What happens is that when the delay is 1000 , the led blink every 10 seconds(!)
When its set to 100 , the led is blinks every second .
What could cause this thing ? a wrong oscillator ? (i actually have checked it)
Here is the code that gives a blinking every 1 second (and not 100 ms )
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
}
thanks, well nothing had changed i do it in the same way :
1.Choosing the board to be Arduino pro or pro mini
2.Choosing processor atmega328p 5v 16Mhz
3.Choosing programmer usbtinyISP
Connecting the pins to the board(pcb as i said, is the MCU, oscillator 16Mhz, 2 capacitors, led+resistor)
I haven't done anything different, the only thing that is different is that i have downloaded the new IDE, for my mac, and now things have changed ... it used to work before..
is it possible that the oscillator is not connected good? but in this case i couldn't program the chip (??)
BTW
if the chip is not running at the right speed, how could i program it using SPI when i set it to be at 16Mhz ?
You may have used chips which had the fuses set before but not this time. Factory new chips are set to run at 1MHz. In the Arduino IDE, fuses are set when you burn bootloader. This sets things such as what oscillator to use and whether or not to do clock division. So burn the bootloader at least once, even if you're not going to use a bootloader to load programs. Then you can upload sketches using programmer.
Thanks man. People should know about it, its not written anywhere.
It's in the processor datasheet.
Imagine that.
8.2.1 Default Clock Source
The device is shipped with internal RC oscillator at 8.0MHz and with the fuse CKDIV8 programmed,
resulting in 1.0MHz system clock. The startup time is set to maximum and time-out
period enabled. (CKSEL = "0010", SUT = "10", CKDIV8 = "0"). The default setting ensures that
all users can make their desired clock source setting using any available programming interface.
When I moved the thread here (it isn't a "Programming" issue, IMO), I was on a bus, without access to the datasheet to give you the exact answer (you'd whinge even more if I gave a partial or incorrect answer).
By the time I got back home, someone had answered your question
And then you got your* customary ill-informed whinge in.
@AWOL - don't you just cringe a little when someone asks a question, and you ask them "Did you read the manual?" - and they just look at you strange, like - well - someone who doesn't read manuals...? Then they complain when you do mention it!
I really hate it when this happens in relation to an automobile. You spend thousands (or 10's of thousands) on a new or used vehicle, and you can't be bothered to read the owner's manual for it?
Ok - I can understand with a used car - it may be long lost, and possibly even unavailable (but still, there's Chilton and Haynes manuals). But a new car? There's no excuse for it. If the answer is fairly simple, it's going to be in the owner's manual. Anything more complex will usually be detailed in one of the aforementioned aftermarket maintenance manuals. Beyond that, you would need super-expensive shop manuals that are in general unavailable to the public at nearly any amount of money.
It just boggles my mind - seems like sheer wilful ignorance and arrogance, mixed together.