Little help with programming the mcu with the ISP header [SOLVED]

not sure what I am doing wrong. Using USBtiny, verified that works with a M162 but I cannot talk to the 644 at all. Any obvious things to check? The control board is not connected to anything and I get 5V everywhere I should with the programmer connected…

Can I power everything from the programmer or should I feed the board +5?

Things that come to my mind:

  • You should feed the board with +5V
  • By default, a blank 644 is configured to use the slow internal clock, so the ISP needs to work at a slow speed. I do this with avrdude terminal, command: “sck 10”
  • After the fuses have been written and when the 644 knows that it can rock with this “fast” 20MHz crystal, reset the ISP speed to “sck 1”.

ok, thats probably where i am going wrong, so turn off USB power on the USBtiny and supply +5 at header?

I cant talk to the chip at all so I cant set fuses etc…

What is the slow speed for this chip? I can try to patch it in on protoboard but the only 20 mhz osc is now soldered to the board but I have 8 and 16 mhz resonators…

No you don’t need to breadboard anything… The speed that needs to be adjusted is that of the programmer, not that of the chip. Are you using avrdude?

If so, there are two ways of adjusting the speed:

  • Start a terminal session with the programmer (the usual avrdude command line + “-tuF” option) and type the “sck N” command, where N is either 10 when you are dealing with a blank chip still being clocked by the internal clock, and 1 once the fuses have been set and the chip can now use the external crystal.
  • Or use the -B N command on the command line. So when you are setting the fuses, use -B 10, then after that you can use -B 1. This option is kind of annoying because it is sticky (once you use -B 10 all other operations will be done at this speed even if no flag is specified). I don’t like the way it works…

Regarding power I do not turn off anything on my programmer when programming the chips - power the synth, plug in the programmer and get rolling!

no matter what I do, I get an “initialization failed, rc=-1” flag from avrdude. So I cant even get the fuse set. Normally, I can check communication to the chip with:

C:\\Users\\Altitude>avrdude -c usbtiny -p atmega162

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9404

avrdude: safemode: Fuses OK

avrdude done. Thank you.

but when I do the same with the 644:

C:\\Users\\Altitude>avrdude -c usbtiny -p m644p

avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude done. Thank you.

regardless of the sck setting. This is what the terminal shows me:

C:\\Users\\Altitude>avrdude -c usbtiny -p m644p -P usb -e -tuF

avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATMEGA644P is 1E 96 0A
avrdude> sck 10
>>> sck 10
avrdude> quit
>>> quit

avrdude done. Thank you.

and then with the fuses:

C:\\Users\\Altitude>avrdude -c usbtiny -p m644p -P usb -Ulock:w:0x0F:m -e -u \\ -U
lock:w:0x3f:m \\ -U efuse:w:0xFD:m \\ -U hfuse:w:0xD6:m \\ -U lfuse:w:0xFF:m

avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude done. Thank you.

I’m sorry, I have no idea on this one. When you said you tried with a M162, was it on the Shruthi-1 board (the 162 and 644 have the same pinout) or on another device? Have you tried inserting the 644 in the other device and programming it there?

no the 162 and 644 have completely different pinouts. I program them just by sticking it in a bread board and wiring the ISP pins, power, and resonator there.

Would the chip initialize without a clock at all? Also, can I run the 644 with a different speed crystal/resonator? I dont have any 20mhz parts but do have 8 and 16mhz resonators to try to eliminate the clock as the issue (my scope does not go that fast to check it that way). There is only a couple things in the circuit (clock, chip, board) so it has to be one of those.

Oops, sorry for the confusion for the pinout.

The ATMega644 runs on anything - not only 20 MHz. I would recommend sck = 2 or 3 for anything below 16 MHz.

If the fuses are set so that it uses the internal resonator, the chip can initialize without a clock, but at a terribly low speed. This is the default when the chip comes out of the factory - this is why the ISP transmission has to be slowed down when setting the fuses.

Ok, good to know. Will report back tonight…

ok, set the chip up on breadboard and I can talk to it now correctly but now I have a problem setting the fuses:

C:\\Users\\Altitude>avrdude -c usbtiny -p m644p -P usb -Ulock:w:0x0F:m -e -u -U lo
ck:w:0x3f:m -U efuse:w:0xFD:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e960a
avrdude: erasing chip
avrdude: reading input file "0╫0F"
avrdude: invalid byte value (0╫0F) specified for immediate mode
avrdude: write to file ‘0╫0F’ failed

avrdude done. Thank you.

What is the character on this page http://mutable-instruments.net/shruthi1/firmware that looks like a small x? its not since small x is used elsewhere but when I copy and paste it, it copies it like what you see above

Awww crap, it’s the CMS that believes 0x0 is “0 times 0” and typsets it as an x (multiplication sign).

It’s an x, not a multiplication sign

getting somewhere now, however I still get an error at the end:

C:\\Users\\Altitude>avrdude -c usbtiny -p m644p -P usb -Ulock:w:0x0F:m -e -u -U lo
ck:w:0x3f:m -U efuse:w:0xFD:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e960a
avrdude: erasing chip
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying …
avrdude: 1 bytes of lock verified
avrdude: reading input file "0x3f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3f:
avrdude: load data lock data from input file 0x3f:
avrdude: input file 0x3f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying …
avrdude: verification error, first mismatch at byte 0x0000
0x3f != 0x0f
avrdude: verification error; content mismatch

avrdude done. Thank you.

also worth noting, I still cant program the chip on the digital board at all, works fine on breadboard with the the ISP pins, VCC and GND connected and nothing else

Ok, I am about to lose my mind here.

I have now bent away ALL the pins of the avr except for VCC, GND, MOSI, SCK, RST. and MISO and pulled R1 so the only connections to it are via the ISP header EXACTLY like i have it laid out on bread board. Powering from the programmer and I get a solid +5.

Works fine with bent away pins on bread board, nada on the shurthi board

Checked the ribbon cable, continuity through the ribbon cable, just about everything I can think of…

Out of ideas

  • edit MOSI pin has a 100 ohm resistance to VCC for some reason…

bingo.

Bad 595. Must have been shorting MOSI pin to +5

Now back to the fuses…

Interesting… What was wrong with your 595?

dont know, i cut it out but pin 14 was giving me a 100 ohm resistance to the 5v rail to pin 6 of the uc. I cut the pin, problem was gone, changed the chip was also gone…

any idea about this error?

avrdude: verification error, first mismatch at byte 0×0000 0×3f != 0×0f
avrdude: verification error; content mismatch

all the fuses set except for that one and I can program at sck 1…

ok,

I am getting a handle on this, so 0x3F are for 0x0F locking and unlocking bootloader?

Try moving the Ulock:w:0×0F:m at the end of the command line instead not sure how it ended up there when I captured the pages for the documentation. I don’t see those errors because I use -V. If it programs at sck 1 the clock might have been correctly set.