Unable to program atmega168 after setting to internal 125kHz clock

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

I'm using an atmega168 device which I have programmed to control an ultrasonic range finder and show the distance it returns on a 7-segment LED display.  It was running with the internal 8Mhz clock and these fuses:

  • low: 0xe2
  • high: 0xdf

In an effort to run it at lower power,  I updated the fuse settings to use the internal 125kHz clock, these settings:

  • low: 0xe3
  • high: 0xdf

After this change I was no longer able to program the device (I'm using the Atmel AVR ISP mkII programmer), getting the error:

$ avrdude -F -p atmega168 -P usb -c avrisp2 -U flash:w:main.hex

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Unknown status 0x00
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000 (retrying)
avrdude: Device signature = 0x000000 (retrying)
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATmega168 is 1E 94 06
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.

I remembered that there was a '-B' flag for setting the clock period, with '1' representing 1 microsecond.  With 1/125,000, that's 8us, so I tried adding '-B 8' to the avrdude command and I still get the same error.  I'm not sure if I need to update the default baud value with '-b', so I tried using a pretty low value '-b 300', but that also had no effect.

 

As a final note, the code that is already loaded on the device still works.  On startup, it counts from 0 to 9 on the 7-segment display.  I did not update the F_CPU value in code, so I see it counting up 64 times more slowly than before.  So, the device itself is still operational.

 

Is there something I'm missing here?  How does one program an AVR running at a low clock frequency?  I've searched every way I can think of on this forum and the general internet for answers and nothing really seems to come up that helps.  

This topic has a solution.

Garth Webb

Last Edited: Sun. Oct 13, 2019 - 02:30 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The programming frequency needs to be SLOWER than 1/4 the CPU clock. So, if that clock is 125KHz (really, not very good choice, anyway), the ISP clock should be slower than 31.25KHz (that is REALLY slow). I would think that you need at least +B 34 (longer than B 32, since 8*4 = 32).

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Sat. Oct 12, 2019 - 08:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

7 seg LED and low power do not go together, so bad choice to begin with. 
At least the clock/8 fuse is not set, that is good. Use a setting for isp speed that Less than 1/4the clock speed and restore the fuses to 8MHz clock.  Then ask here how to reduce power, but you will need to find another display if power is important.  Also check out the cpu clock prescaler reg. For safe ways to reduce clock speed.

jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

In an effort to run it at lower power, 

Why not use sleep mode between it being busy? 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Than you, bringing it down to -B32 did the trick!  I really did do my best to find this info online, but there is exceedingly little said about lower clocks or especially how it relates to the -B flag.

 

Using 125kHz was really just to test whether I could run the setup at 3v (off 2x AAAs) without waiting for a more reasonable external lower power crystal could arrive.

Garth Webb

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

7 seg LED and low power do not go together, so bad choice to begin with.

Yes to the first part, the second part requires you know more than the single design requirement I listed.  I need something that will wake up and show a number that can be seen from across the room.  A low contrast LCD display isn't going to cut it.  I'll certainly post with power reduction questions separately.

Garth Webb

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

Yes, I will definitely do this as well.  It was exceedingly difficult to make additional changes like this however while I was unable to program the device.

Garth Webb

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



I need something that will wake up and show a number that can be seen from across the room. 

 

Get yourself some of these digits..I used them in the 80's for a sign for Ford...I still have a bunch of the boxes they came in (good for parts) 

 

https://www.scoretronics.com/components/Digits_Brochure.pdf

 

https://www.youtube.com/watch?v=8gWIMmRH2qA

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Have we gotten the part programmed yet?

 

So, tell us the power budget.  Tell the draw of this display, and what percentage of time it is on.

 

I'm guessing this is some type of timing display.  So how does the app keep time?  I'm getting at the ongoing draw.

 

Why am I asking?  With some models of AVR8  the power draw using watch crystal for wakeup/timekeeping and best sleep mode for that  is about as good as going to deep powerdown sleep with the watchdog.  In either case if you run the numbers using the datasheet, or run the experiments, I think you will find either of those approaches better with an AVR8 than running with a real slow clock as you are attempting.

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

a room that comes without mains !

a timber lodge off grid  ;)

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

I have heard that the human eye optic nerves are "peak hold" so an LED display is almost as bright if pulsed with a duty factor less than 100%

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

I have heard that the human eye optic nerves are "peak hold" so an LED display is almost as bright if pulsed with a duty factor less than 100%

you can also use color  to save power...we are much more sensitive to green (about 5x compared to , say, red).

 

You are correct, at least in the fact that you can use a properly pulsed led  & proper bright led to seem just as bright as a full-on & improve battery life.   So a very bright led on at a much shorter time, looks like a regular bright ledon all the time.    If not done properly (regular led , duty cycle) it will look like you are doing pwm dimming!

 

Also, apparently our eyes can't sense DC very well ...if you clamp your eye so it can't move/blink,  a steady image will fade out.

 

https://www.ledsmagazine.com/home/article/16698062/pulsedriven-leds-have-higher-apparent-brightness

 

https://www.jstage.jst.go.jp/article/jlve/32/2/32_2_161/_pdf

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Oct 17, 2019 - 05:09 AM