Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ATMEGA328P Custom Designed Board, Codeblocks IDE and USBAsp Programmer

Status
Not open for further replies.

asimlink

Full Member level 1
Joined
Jun 24, 2009
Messages
96
Helped
12
Reputation
24
Reaction score
12
Trophy points
1,288
Location
Islamabad
Activity points
2,288
Hi Friends,

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?

Kind Regards
Asim
 

Hi,

what frequency is your ATMEGA running?

Did you select the correct clock source as system clock? (fuses)
Are there any prescaler active?

Did you tell the compiler the correct clock frequency?

Klaus
 

Also you could check CKDIV8 fuse (divide clk by 8 internally). It should be deactivated.
 

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?

thanks
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top