Mega644-20P
2009-03-29 by David VanHorn
Is there something unusual I should know with this device?
I'm watching it step through a simple routine to light some LEDs, and
after stepping through a single CBI instruction it's telling me that
half of SRAM has been changed..
There are four alarm timers, and if any of them is > 0, I want to
light the appropriate LED, if the timer is Zero, then turn the LED
off.
Sane at this point:
1638: if (A_Alarm_Timer > 0) {
+000004C1: 9180022E LDS R24,0x022E Load direct from data space
+000004C3: 2388 TST R24 Test for Zero or Minus
+000004C4: F019 BREQ PC+0x04 Branch if equal
1639: LED_DDR |= (1 << LED_1); // Output
+000004C5: 9A24 SBI 0x04,4 Set bit in I/O register
1640: LED_Port |= (1 << LED_1); // High
+000004C6: 9A2C SBI 0x05,4 Set bit in I/O register
+000004C7: C001 RJMP PC+0x0002 Relative jump
1642: LED_Port &= ~(1 << LED_1); // Low
+000004C8: 982C CBI 0x05,4 Clear bit in I/O register
1646: if (A_Warn_Timer > 0) {
+000004C9: 91800230 LDS R24,0x0230 Load direct from data space
+000004CB: 2388 TST R24 Test for Zero or Minus
+000004CC: F019 BREQ PC+0x04 Branch if equal
1647: LED_DDR |= (1 << LED_2); // Output
+000004CD: 9A25 SBI 0x04,5 Set bit in I/O register
1648: LED_Port |= (1 << LED_2); // High
+000004CE: 9A2D SBI 0x05,5 Set bit in I/O register
+000004CF: C001 RJMP PC+0x0002 Relative jump
Sane to this point
1650: LED_Port &= ~(1 << LED_2); // Low
+000004D0: 982D CBI 0x05,5 Clear bit in I/O register
BOOM. Total corruption of SRAM, stack pointer blown, all hope abandon
ye who enter here..
The device itself, without the ICE, is crashing when I run this
routine, so I'm thinking it muse be some wild config problem.
I'm running 20 MHz external crystal, and that's confirmed by the 1mS
interrupt and serial baud rate being correct.
Fuses:
BODLEVEL is set at 4.3V, (VCC is solid at 5.05V)
JTAGEN is checked
SPIEN is checked
EESAVE is checked
BOOTSZ is 512 words (I'm not using it)
SUT_CKSEL is Ext Xtal osc, 8.0 - 16k clock + 65mS
--
There is no computer problem which cannot be solved by proper
application of a sufficiently large hammer.