atmega324PA not working at higher than 1MHZ freq

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello I have been trying to make my MCU work at 8MHZ or 12MHZ for my project but I cannot seem to make it work even when I change the fuses accordingly.

 

For the 8MHZ i changed the fuses like:

LOW = 0xE2

HIGH = 0xD9 ( I don't need JTAG)

 

For the 12MHZ low power crystal oscillator i changed the fuses:

LOW = 0xFF

HIGH = 0xD9

 

I used 2 22pF ceramic capacitors and a 12MHZ crystal in the configuration provided by the datasheet:

 

The moment I power up my PCB the program is not working on either 8MHZ or 12MHZ.I also changed the CPU freq in atmel studio to 8000000 or 12000000.

Does it need more power than the 5V I supply?

Thanks!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It certainly doesn't need any more voltage, but it might want more current.  What's your supply rated at, in amperes?

 

It might also want a better pullup on the /RESET pin and a lot more local decoupling capacitance.

 

Furthermore, if you can, turn on the 'CLKO' fuse and measure the frequency there - you'll find a lot of folks around here insist upon checking that first.

 

Have fun,

 

S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am supplying with a LIPO battery(I tried with an alkaline 9V battery but it was dropping voltage too fast) which is rated at:

11.1V

1000mAH

25C

So it can discharge 25 Amps which i guess is more than enough.

 

This battery is connected to a voltage regulator which has:

Min. input voltage: 7V

Max. input voltage: 35V

Fixed output voltage : 5V

Output current : 1A

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's the voltage regulator that bothers me.  We're going to need a lot more information about how that's working, and what it has as output.  Is it a switching regulator?  Then we'll need to know about the inductors.  If it's linear, we need to know more about the capacitors.  If you have an oscilloscope, watch the voltage rails as you switch frequencies (even a meter might help here).  If something's wrong there, it'll be obvious.

 

Furthermore, when you say, "Doesn't work" do you mean it does nothing?  Or does it do weird things that it's not supposed to?

 

Okay.  Next suggestion:  Dramatically simplify the program.  Make it just flash an LED.  That's all.

 

At 1MHz have the program flash the LED once per second.  At 8MHz the exact same program should flash the LED eight times per second.  Note that setting F_CPU in the code has absolutely nothing to do with how fast the CPU runs.

 

Incidentally, to rule out other nonsense, I believe your chip has an internal oscillator that'll run at 8MHz.  Try blowing the fuses to use that instead - and CLKO - and see if there might be something wrong in your crystal wiring.  De-select the CLKDIV fuse. 

 

Still making debugging suggestions here.  I don't have an instant answer for you yet.

 

S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So, a 7805?  Do you have input and output bypass caps on it?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes a 7805(NCP7805TG specifically) it is linear and I do not have input and output bypass caps.

It does not do any strange things ,it doesn't do anything.

 

I am testing at the moment if the simple LED code works.

Last Edited: Sun. Apr 5, 2020 - 09:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I do not have input and output bypass caps.....It does not do any strange things

If only you had an oscilloscope on the pins on the regulator then you WOULD see strange things.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When you programmed the high fuse to 0xD9, you turned off the SPIEN fuse.  This is the configuration switch that allows the AVR CPU to be programmed through the SPI pins [MISO, MOSI, SCK].  Almost every cheap AVR development system uses SPI programming.  You may be able to access this fuse (which would allow you to re-enable the SPIEN programming system) through various debug systems from Atmel/Microchip.   I don't know: I don't play with the fuses anymore.  Focus on the application, not the CPU.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

0xD9 is 11011001 and the SPIEN is the 5th bit so i did not turn it off.

So after i tested the simple LED blinking code I came to the following conclusions:

Disabling CKDIV8 makes the LED blink 8 times faster which is normal because it works at 8MHZ in this case.

Using the crystal oscillator makes the LED blink 12 times faster which is also normal.

So the simple LED code works in all cases and ALSO it works with the voltage regulator and my 11.1V battery.

Since my project uses a bluetooth module(HC05) and I was initially using the 1MHZ freq then I figured out I need to recalculate the UBRR register values for the 9600 baud rate.

Based on the datasheet there is no 12 MHZ:

Should I go with the 11MHZ which is lower or the 14MHZ which is superior?

Last Edited: Sun. Apr 5, 2020 - 10:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Calculate UBRR value for 9600 baud at 12MHz. i.e. 77

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Simonetta wrote:
When you programmed the high fuse to 0xD9, you turned off the SPIEN fuse
Uh, no:

 

Unless the OP has been programming with HVPP, it's not possible to change SPIEN.

tirleaxzy wrote:

Yes a 7805(NCP7805TG specifically) it is linear and I do not have input and output bypass caps.

What does the datasheet say?  Hint:

 

 

 

 

Speaking of bypass caps, you have one on the AVR as well, right?  In fact, you should have one across every (A)VCC/GND pair.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Mon. Apr 6, 2020 - 12:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So the blinky LED thingy works fine at all frequencies.  The chip is happy.

 

But it won't be, if you don't have caps on your 7805 outputs.  10uF would be a starting point.

 

And there's an equation for UBRR that applies to any crystal frequency.  The tables given in the spec sheet are just examples.

 

Sounds like we're making progress!

 

S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The bluetooth module is working well and thank you for the UBRR value david.prentice ,I found out later about the formula in the datasheet besides that big table of values.

Between VCC and GND i have a 100nF cap.

And how exactly will it affect the circuit in the future if I do not use the caps?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Between VCC and GND i have a 100nF cap.

And how exactly will it affect the circuit in the future if I do not use the caps?

The cpu will be unstable, or it will not work at all. Take care that the 100nF caps are as close as possible to the Vcc/GND pins.

Last Edited: Mon. Apr 6, 2020 - 12:25 PM