simulavr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Simulavr-devel] Assertion fails when using at90can128


From: Petr Hluzín
Subject: Re: [Simulavr-devel] Assertion fails when using at90can128
Date: Sun, 29 Jul 2012 21:58:36 +0200

On 26 July 2012 20:56, Ytai Ben-tsvi <address@hidden> wrote:
> Hi!
> I've built simulavr from source on Ubuntu / 64-bit.
>
> I'm getting:
> $ simulavr -d at90can128 --gdbserver
> simulavr: irqsystem.cpp:289: void
> HWIrqSystem::DebugVerifyInterruptVector(unsigned int, const Hardware*):
> Assertion `existing == source' failed.
> Aborted
>
> I'm getting the same behavior with the pre-built binaries.
> It works OK with other targets (e.g. atmega 8).

The assertion means that the contstructor uses the same index (7) for
multiple interrupt vectors.

I compared the interrupt vectors to datasheet and I think the values
of vector are completly wrong. Also the code wrote beyond end of array
of vectors.

I suggest these changes (syrroy, I cannot produce proper diff):

-    irqSystem = new HWIrqSystem(this, (flash_bytes > 8U * 1024U) ? 4 : 2, 26);
+    irqSystem = new HWIrqSystem(this, (flash_bytes > 8U * 1024U) ? 4 : 2, 37);
...
-    eeprom = new HWEeprom(this, irqSystem, ee_bytes, 23,
HWEeprom::DEVMODE_EXTENDED);
+    eeprom = new HWEeprom(this, irqSystem, ee_bytes, 26,
HWEeprom::DEVMODE_EXTENDED);
...
-    timerIrq0->registerLine(0, new IRQLine("TOV0",  16));
-    timerIrq0->registerLine(1, new IRQLine("OCF0A", 15));
+    timerIrq0->registerLine(0, new IRQLine("TOV0",  17));  // TIMER0 OVF
+    timerIrq0->registerLine(1, new IRQLine("OCF0A", 16));  // TIMER0 COMP
...
-    timerIrq1->registerLine(0, new IRQLine("TOV1",  14));
-    timerIrq1->registerLine(1, new IRQLine("OCF1A", 13));
-    timerIrq1->registerLine(2, new IRQLine("OCF1B", 12));
-    timerIrq1->registerLine(3, new IRQLine("OCF1C", 11));
-    timerIrq1->registerLine(5, new IRQLine("ICF1",  10));
+    timerIrq1->registerLine(0, new IRQLine("TOV1",  15));  // TIMER1 OVF
+    timerIrq1->registerLine(1, new IRQLine("OCF1A", 12));  // TIMER1 COMPA
+    timerIrq1->registerLine(2, new IRQLine("OCF1B", 13));  // TIMER1 COMPB
+    timerIrq1->registerLine(3, new IRQLine("OCF1C", 14));  // TIMER1 COMPC
+    timerIrq1->registerLine(5, new IRQLine("ICF1",  11));  // TIMER1 CAPT
...
-    timerIrq2->registerLine(0, new IRQLine("TOV2",  9));
-    timerIrq2->registerLine(1, new IRQLine("OCF2A", 7));
+    timerIrq2->registerLine(0, new IRQLine("TOV2",  10));  // TIMER2 OVF
+    timerIrq2->registerLine(1, new IRQLine("OCF2A", 9));  // TIMER2 COMP
...
-    timerIrq3->registerLine(0, new IRQLine("TOV3",  30));
-    timerIrq3->registerLine(1, new IRQLine("OCF3A", 27));
-    timerIrq3->registerLine(2, new IRQLine("OCF3B", 28));
-    timerIrq3->registerLine(3, new IRQLine("OCF3C", 29));
-    timerIrq3->registerLine(5, new IRQLine("ICF3",  26));
+    timerIrq3->registerLine(0, new IRQLine("TOV3",  31));  // TIMER3 OVF
+    timerIrq3->registerLine(1, new IRQLine("OCF3A", 28));  // TIMER3 COMPA
+    timerIrq3->registerLine(2, new IRQLine("OCF3B", 29));  // TIMER3 COMPB
+    timerIrq3->registerLine(3, new IRQLine("OCF3C", 30));  // TIMER3 COMPC
+    timerIrq3->registerLine(5, new IRQLine("ICF3",  27));  // TIMER3 CAPT
...
-    acomp = new HWAcomp(this, irqSystem, PinAtPort(&porte, 2),
PinAtPort(&porte, 3), 23);
+    acomp = new HWAcomp(this, irqSystem, PinAtPort(&porte, 2),
PinAtPort(&porte, 3), 24);
...
-                         20,   // RX complete vector
-                         21,   // UDRE vector
-                         22,   // TX complete vector
+                         21,   // RX complete vector
+                         22,   // UDRE vector
+                         23,   // TX complete vector
...
-                         31,   // RX complete vector
-                         32,   // UDRE vector
-                         33,   // TX complete vector
+                         32,   // RX complete vector
+                         33,   // UDRE vector
+                         34,   // TX complete vector

After this changes the constructor finishes correctly and
irqSystem->DebugDumpTable() produces following table (which matches
datasheet):

Interrupt vector table (for comparison against a d
Vector | Address/2 | Source Peripheral (class)
 1  |   $0000   | funct AvrDevice::Reset()
 2  |   $0002   | class ExternalIRQHandler
 3  |   $0004   | class ExternalIRQHandler
 4  |   $0006   | class ExternalIRQHandler
 5  |   $0008   | class ExternalIRQHandler
 6  |   $000a   | class ExternalIRQHandler
 7  |   $000c   | class ExternalIRQHandler
 8  |   $000e   | class ExternalIRQHandler
 9  |   $0010   | class ExternalIRQHandler
10  |   $0012   | class TimerIRQRegister
11  |   $0014   | class TimerIRQRegister
12  |   $0016   | class TimerIRQRegister
13  |   $0018   | class TimerIRQRegister
14  |   $001a   | class TimerIRQRegister
15  |   $001c   | class TimerIRQRegister
16  |   $001e   | class TimerIRQRegister
17  |   $0020   | class TimerIRQRegister
18  |   $0022   | class TimerIRQRegister
19  |   $0024   | (unsupported or not registered)
20  |   $0026   | (unsupported or not registered)
21  |   $0028   | class HWSpi
22  |   $002a   | class HWUsart
23  |   $002c   | class HWUsart
24  |   $002e   | class HWUsart
25  |   $0030   | class HWAcomp
26  |   $0032   | class HWAd
27  |   $0034   | class HWEeprom
28  |   $0036   | class TimerIRQRegister
29  |   $0038   | class TimerIRQRegister
30  |   $003a   | class TimerIRQRegister
31  |   $003c   | class TimerIRQRegister
32  |   $003e   | class TimerIRQRegister
33  |   $0040   | class HWUsart
34  |   $0042   | class HWUsart
35  |   $0044   | class HWUsart
36  |   $0046   | (unsupported or not registered)
37  |   $0048   | (unsupported or not registered)

Opinions?

-- 
Petr Hluzin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]