# atmega32 is working OK but atmega32A is NOT!

I have a board which there is an LCD on it and I want to show some lines in the LCD. I have a broken-pin Atmega32 which the broken pins didn't used for LCD, I have written a simple code which just shows on and off a text in LCD.

Since my Atmega32 is broken and the broken pins are needed for another part of circuit I had to buy a new Atmega32 but all I found is Atmega32A.

Since technically Atmega32A can be used instead of ordinary Atmega32, I have compiled and burnt the same code that I have written for Atmega32 into the newly bought Atmega32A. But the LCD does not work anymore and also I had a sample code which rotates a step-motor clockwise and counter-clockwise each with 1000ms delay. But it took almost 5000ms in Atmega32A in order to change the rotation direction.

I don't really know what is going on!!!

Can anybody help me on this?

here is a question about the same problem that I have but the accepted answer does not contain any useful detail on how to solve the problem(or atleast I don't get it!!).

## More details

Above picture is the the LCD display on an ordinary Atmega32. Above picture is the LCD display with same code on an Atmega32A(no output)

The codes to compile and burn the codes:

#!/bin/bash
avr-gcc -mmcu=atmega32 lcd-sample-main.c -o .makefiles/lcd-sample-main  -O1 && \
avr-objcopy -O ihex .makefiles/lcd-sample-main .makefiles/lcd-sample-main.hex && \
sudo avrdude -c usbasp -p m32 -U flash:w:.makefiles/lcd-sample-main.hex

• Have you tried pulling the firmware from the '32 to be certain that both are running the same code? – Ignacio Vazquez-Abrams Dec 30 '14 at 16:35
• I believe this is the fuse bits problem. Fresh chip may come with different default bits. – Maxthon Chan Dec 30 '14 at 16:41
• Good call. A big chunk of port C is used by JTAG by default, and the incorrect clock source would throw off the timing for the LCD. – Ignacio Vazquez-Abrams Dec 30 '14 at 16:47
• Use AVRDUDE to read the current fuse bytes from the '32 and then write them to the '32A. AVRDUDE documentation – Ignacio Vazquez-Abrams Dec 30 '14 at 17:24

## 1 Answer

The problem was with the fuse bits setting in the new '32A controller.
Thanks to Ignacio for giving the idea, I read the current fuse bytes from the '32 and then wrote them to the '32A and everything is working now.

To reading the fuse bits:

sudo avrdude -c usbasp -p m32 -U lfuse:r:-:h -U hfuse:r:-:h


And for writing them(These are the values that i have read from the '32 fro lfuse and hfuse)

sudo avrdude -c usbasp -p m32 -U lfuse:w:0xf4:m -U hfuse:w:0xdf:m


Done!