Connect with us

ATMega8 loses program, 328 doesn't

Discussion in 'Microcontrollers, Programming and IoT' started by (*steve*), Jun 23, 2013.

Scroll to continue with content
  1. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,496
    2,837
    Jan 21, 2010
    I have a program that requires almost all the 8K that an ATMega8 has. In order to do this, I program it with a USBasp programmer, not with a bootloader.

    If I program it with a long (almost 8K) program it works at first, then after a couple of power cycles it doesn't.

    If I program it with a shorter program it works without fail.

    If I upgrade to an ATMega328 it also works without problems.

    I suspect it may have something to do with the configuration of the chip and some sort of weirdness when the bootloader region is overwritten.

    Any ideas?
     
  2. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    Is the program writing to flash? It could be going out of bounds and destroying itself.

    Bob
     
  3. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,496
    2,837
    Jan 21, 2010
    No, the program does not write to flash.

    edit: and I have no reason to believe the libraries do either.
     
  4. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,496
    2,837
    Jan 21, 2010
    I'm pretty sure the problem is that I have the fuse bits set for a bootloader still. This makes the code start in the wrong place. Why it works once is a bit of an issue though...

    I'll see if that's the case later today...
     
  5. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    The bootloader would definitely write to flash, so, if the program is starting in the bootloader, it could be clobbering something right away.

    Bob
     
  6. GreenGiant

    GreenGiant

    842
    6
    Feb 9, 2012
    sometimes libraries do weird things...
    TimerOne/TimerThree I have used extensively but every once in a while they do weird stuff, Ill set it for say a 1ms clock period, 50% duty cycle and what I get is anywhere from 4-5ms period at 50% duty cycle.

    I also had a library hijack a variable I was using, so I was getting ridiculously weird activity until I had the program read out the variables and figured out it redefined one as a float from an integer, and it was dumping crazy weird numbers to what was supposed to be a whole number thing
     
  7. Xenophotean

    Xenophotean

    10
    1
    Jun 22, 2013
    Hello,

    I am not sure if this is a common website, but http://www.engbedded.com/fusecalc/ has some good information as to what the AVR fuse bits are made up of, so maybe you will find your answer here.
     
  8. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,496
    2,837
    Jan 21, 2010
    Yeah, I expected my problem was to do with fuses. I changed some to what I thought seemed reasonable and there was effectively no change.

    On the last try I must have changed one which affects in circuit programming because that was my last try :(

    The chip is soldered in to this board, and it's matrix board, so I'm planning to replace it with a socket and use a 328. But since it's point to point wiring to the pins of the chip, I'm putting it off until I can't find something easier to do. :D
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-