I have an ATMEGA328P Custom designed Board. The microcontroller does not has bootloader installed. I am using Codeblocks IDE for Arduino and using an external usb programmer USBASP to program the ATMEGA328P microcontroller.
I am using following code to blink an led:
Code:
void setup()
{
//Serial.begin(9600);
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop()
{
//Serial.println("Hello world!");
delay(1000); // wait for a second
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
}
1. I correctly wire SPI signals of between my Custom Arduino Board and USBASP.
2. I select Arduino UNO in Codeblocks IDE,
3. and then press Build Button to compile
4. I then select upload via usbasp option from Tools > Upload Via USBasp
The code gets compiled successfully, and also gets programmed successfully. But the led blink runs very slow. It looks like as if the blink time is 10 times slower than what it should be.
If i change time from 1000 msec to something else the change gets reflected but the blink time is always very slow.
Can anyone suggest what may be wrong with Codeblocks IDE that it generate a code which is slow?
Thanks for answering to my post. I am using 16.000MHz crystal. i will try deactivating CKDIV8 fuse.
I assume arduino bootloader does couple of fuse configurations and perhaps timer settings too. when i use atmega328p microcontroller without arduino bootloader all of these things need to be done manually through code?
It would be helpful if i could see code example that arduino sets at power up and all those fuse configurations?