by StuartL » Fri Sep 05, 2008 7:16 am
by StuartL
Fri Sep 05, 2008 7:16 am
Other things to note when you're programming AVRs:
- Read the ATmega128 PDF at least twice. Cover to cover. Make notes of anything that might affect what you're doing.
- The fuse bits are critical to getting the AVR running. By default the JTAG port is enabled and the AVR uses its internal (uncalibrated) 8MHz RC oscillator. This is definitely not what you want.
- It's VERY easy to brick an AVR if you set the wrong fuse bits. We have one here that got bricked because we read the wrong PDF when calculating what the fuse bits should be. For the record a ATmega164p doesn't work well with ATmega8 fuse bit settings. It's currently trying to use an external 500kHz crystal, something we don't have.
- Read the ATmega128 PDF at least twice more. You're bound to have missed something.
- Be super careful with the clock settings, prescaler etc when you initialise the AVR. It's easy to cock up here too
- Use the 'register' sections of each chapter to calculate what you need for the registers for each of your sections. Make sure that you get them right and test-test-test each section of your C/ASM before assuming it works.
- Until you've got debugging working out of the serial port(s) you're going to be reliant on LED or pin+multimeter debugging. Test small amounts of code by setting the LED to a value dependent on a condition you're expecting. For a CM-5 clone the large number of LEDs makes this easier. e.g. We don't set the power LED as 'on' in our software until we've confirmed that the initialisation has worked.
Other things to note when you're programming AVRs:
- Read the ATmega128 PDF at least twice. Cover to cover. Make notes of anything that might affect what you're doing.
- The fuse bits are critical to getting the AVR running. By default the JTAG port is enabled and the AVR uses its internal (uncalibrated) 8MHz RC oscillator. This is definitely not what you want.
- It's VERY easy to brick an AVR if you set the wrong fuse bits. We have one here that got bricked because we read the wrong PDF when calculating what the fuse bits should be. For the record a ATmega164p doesn't work well with ATmega8 fuse bit settings. It's currently trying to use an external 500kHz crystal, something we don't have.
- Read the ATmega128 PDF at least twice more. You're bound to have missed something.
- Be super careful with the clock settings, prescaler etc when you initialise the AVR. It's easy to cock up here too
- Use the 'register' sections of each chapter to calculate what you need for the registers for each of your sections. Make sure that you get them right and test-test-test each section of your C/ASM before assuming it works.
- Until you've got debugging working out of the serial port(s) you're going to be reliant on LED or pin+multimeter debugging. Test small amounts of code by setting the LED to a value dependent on a condition you're expecting. For a CM-5 clone the large number of LEDs makes this easier. e.g. We don't set the power LED as 'on' in our software until we've confirmed that the initialisation has worked.