I am using the atmega328p-an-ad ic , i order this ic from digikey. when I replace this ic with old one the delay which i give in this ic is not same. in previous ics delay(1000) have complete 1 second delay but in this ic delay(67) give approx. 1 sec delay. I don't understand why this is happening. When i am using old ic(atmega328p-U-KR) then its works proper but in new ic having the issue. Can anyone explain why this is happening?
my code and schematic:
Thanks for your reply but I am new in this field, can you explain what you want to say?
I know prescaler but don't know how to change them or use them as per our requirement.
And how i can check the clock frequency, I mean, I checked the oscillator frequency connected with pin 6 and 7. but Don't know how to check internal frequency, please help me, or give me some sources to check?
I never build my own Atmega board, don't know what exactly must be observed. I also don't know about the differences between your and the other ATmegas. Do you have a second chip to compare the timing?
From experience and data sheets I know that the Arduino core adjusts for correct micros and millis, based on constants in the board variant file which you select in the Tools menu.
Without digging into details I suggest the following tests:
Serial.println("Hello"); to check for the correct baudrate.
Tests with delayMicros() whether these times are correct.
yes, I have both ICs old one and new. I compared both by simple led blink code. I keep everything same (hardware, software/code). only changes the ICs then in old the delay (1000) means 1 second and in new IC the delay (1000) means 14.99756 seconds. I think IC is ok because all functions work proper except timing delay issue.
And if we talk about baud rate, I am not using serial monitor or anything which needs baud rate. Yes, I mention baud rate in my code but only for testing purpose for use the Arduino nano modules, I first write code and test it in Arduino modules for monitering.
If you use a factory new ATMEGA328P, you have to "Arduinoize" it by burning a bootloader on to it. As a side effect, this sets the fuses which make it compatible with the Arduino environment.
If, however, you are not using a bootloader, and use an Arduino core which supports this, then you have to use AVRDUDE to set the fuses which have an impact on the timing.
Beware of using an ICSP programmer to load a sketch if there has been a bootloader previously on the chip without previously cleaning the fuses.
I've just looked at the schematic and there appears to be no FTDI header so I guess this is being programmed over the ICSP header and no bootloader is used.
As I told I am newbie in this field. from starting I want to be embedded engineer, and after lots of struggle I got job as embedded engineer. And this is my first project on atmega328 onboard ic. please help me to know about the minicore or how I can change fuses.
You have obviously got somewhere because you have got as far as loading a program onto that new ATmega328p and come to the conclusion that it is running at 1/16 of the expected speed.
OK. Before we start, please answer the following 3 questions.
Which version of the Arduino IDE are you using ?
How did you load the program onto the ATmega328p ?
Are you using that "Genset" (as in the schematic) as your test environment ?
As for the Aref circuit, I would keep the 100nF decoupling capacitor and omit the10k pullup resistor (although I don't think it does and harm because you are using 5 volts as the reference voltage.
I check from other sources and design another circuit for atmega328 ic, In this circuit AREF connection is different, can you explain its ok or not? See microcontroller block.
The file is in attachment: COMPLETE SRT IEG SCOOTY SYSTEM IN ALTIUM.pdf (1.3 MB)
Yes. That is the normal way to connect Aref, that is by a 100nF capacitor to ground.
Don't be confused by the 3 smoothing/decoupling capacitors connected between 5v0 and ground in that diagram.
.