AVR-Pitfalls
Hardware Problems:
Today I tested the following 3 devices:
-
AT90S1200
see Errata sheet.
Also I tested using the EEPROM for storing constant data, since the AT90S1200
can not use the LPM instruction. But I found it altered some times after
power on, nevertheless no EEPROM write was implement in the whole program.
It seems, Atmel detect this problem, since all other AVR use an extra EEPROM
write enable bit. But I have never tested, if it work as expected.
Work around: Use never the AT90S1200 if you need the EEPROM.
-
AT90S2313
I have not really tested it, only programming of it. So I detect 1 error:
If the lock bits are set, they can not be erased with my programmer.
Only if VCC was reduced to about 4.3V, the lock bits can be erased.
Work around: Use a diode in the VCC line (give about 4.3V)
-
ATtiny22
The same error as on the AT90S2313 was seen in respect of programming the
lock bits.
The programming of the fuse bits alter also the Flash. So you must first
set the fuse bits and then erase and program the Flash.
Since I have it more extrensive used (my DCF77
project), additional errors occurs.
Some times after power on, it refuse every program execution, nevertheless
external reset was applied (similiar to the AT90S1200d).
Atmel tells me, that it was already known and a new revision was started
in the next time. But this correct only the reset problem, not the programming
problems.
But for today I found a solution in very slow rising VCC. After I inserted
a 100Ohms resistor in the VCC line and a 470µF capacitor against GND,
it seems working after every power on. Additional I wait more than 10 seconds
after power off before switching on again.
Software Pitfalls:
Some points on the AVR programming must be watched, but also some features
seems only implemented to make the programmers live even harder (means, I
can see no other reason for it).
Points to make programming harder:
-
The interupt vectors are arranged different on every different AVR
derivate.
Also the stack using differ (no stack, 8 bit stackpointer or 16 bit stackpointer)
and also the stack was initialized to a not allowed SRAM location.
So the program must always be rewritten on using a different AVR device.
In oppsition on 8051 devices the 5 standard interrupt vectors are fixed on
all derivates and the stack was initialized right for easier upgrading and
starting.
-
Also the bit handling is very complicated:
It give many different ways to test or set and clear bits
1. in the status register,
2. in the lower 16 registers,
3. in the upper 16 registers,
4. in the SRAM space,
5. in the lower IO space and
6 in the upper IO space.
But really crazy was the handling of interrupt bits, since they can not be
set, but must be set to clear it.