14M2 interrupt error in model

#1
I'm trying to detect a low input on either pin C.0 or pin C.1 using the interrupt thus:

Code:
SETINT OR 0x00, 0x03
This simulates correctly in PE6.0.9.3, but completely misbehaves in the mixed signal environment. I'm hoping that the solution will be a fairly simple update to the AXE14M2.MDF model file. Could someone at RevEd take a look at this please?
 
#2
Since one line of code does not provide a program to test, can you post the full code and a circuit diagram of your project so that RevEd or other forum members can offer help.
 
#3
I'm not certain that the code and circuit diagram are going to be helpful in this particular case, however, since you asked, here they are.

Code:
; This is a programme for driving the beep test circuitry.
#PICAXE 14M2
#TERMINAL 38400


; Define the PICAXE port directions.
LET dirsB = %00111111 ; [0] is serial data output,
                      ; [1..4] are BCDDa[0..3],
                      ; [5] is the audio output to the loudspeaker.
LET dirsC = %00010100 ; [0] is the SETUP select DOWN input,
                      ; [1] is the SETUP select UP input,
                      ; [2] is the LED0 data strobe signal,
                      ; [3] is the SETUP / RUN input,
                      ; [4] is the LED1 data strobe signal,
                      ; [5] is the serial data input.

; Define the input and output signals.
SYMBOL AudioPin = B.5
SYMBOL SelDownPin = pinC.0
SYMBOL SelUpPin = pinC.1
SYMBOL SetRunPin = pinC.3
SYMBOL Strobe0 = outpinC.2
SYMBOL Strobe1 = outpinC.4

; Define the registers.
SYMBOL Exercise = b4
SYMBOL DataLocStart = b5
SYMBOL DataLocStop = b6
SYMBOL DataPointer = b7
SYMBOL SecondsCounter = b8
SYMBOL StepCounter = b9
SYMBOL BeepCounter = b10
SYMBOL Temp02 = b26
SYMBOL Temp01 = b27

; The exercise to be run is stored in EEPROM at location 0. By default, this is
; set to 1.
EEPROM 0, (1)
; The next set of memory locations hold the starting memory location for the
; data for the exercise number that matches the memory location in this set.
; For example, memory location 1 holds the starting location of the data for
; exercise number 1. The final location for each set of data is deduced from
; the starting point of the following set of data, and so this information must
; be included even if there are no data.
EEPROM 1, (10)
EEPROM 2, (30)
; The remaining memory locations hold the actual data values for each of the
; exercises. These are always stored in pairs of values, first the length of
; each run in seconds and secondly the number of times that have to be completed
; before moving on to the next set of data.
EEPROM 10, (20, 2, 15, 2, 12, 4, 10, 6, 9, 6, 8, 7, 7, 8, 6, 10, 5, 12, 4, 15)

; A sub-routine to send the contents of a register to the two digit display.
; Leading zeroes are blanked.
#MACRO OutputValue(Reg)
  LET b0 = Reg // 10
  SendDigit(Strobe0)
  IF Reg > 9 THEN
    LET b0 = Reg / 10
  ELSE
    LET b0 = 0x1F
  ENDIF
  SendDigit(Strobe1)
#ENDMACRO

; This is the sub-routine that does the actual physical sending of a
; digit to the display. The strobe is active low, and there is a very
; wide margin for the timing.
#MACRO SendDigit(Strb)
  LET outpinB.1 = bit0
  LET outpinB.2 = bit1
  LET outpinB.3 = bit2
  LET outpinB.4 = bit3
  PAUSEUS 1
  LET Strb = 0
  PAUSEUS 10
  LET Strb = 1
  PAUSEUS 1
#ENDMACRO

; The main part of the programme consists of first selecting a set of sequences,
; and then secondly running that set of sequences, the whole lot being set in an
; infinite loop.
DO
; First the set up phase. Select the programme to run.
setup:
  READ 0, Exercise
  SETINT OR 0x00, 0x03   ; Comment out this line for the mixed signal simulation.
  DO WHILE SetRunPin = 0
    WRITE 0, Exercise
    OutputValue(Exercise)
  LOOP

; The exercise has been selected, now run it. Start by disabling the interrupts
; and clearing the number of beeps.
  SETINT OFF
  LET BeepCounter = 0
  OutputValue(BeepCounter)
; Next, get the start and stop points of the data to use.
  READ Exercise, DataLocStart, DataLocStop
  LET DataLocStop = DataLocStop - 2
; Send out three beeps warning that the test is about to start...
  SOUND AudioPin, (125, 50)
  PAUSE 250
  SOUND AudioPin, (125, 50)
  PAUSE 250
  SOUND AudioPin, (125, 50)
  PAUSE 500
; ... and then the start beep proper.
  SOUND AudioPin, (90, 80)

; Now start the main looping.
  FOR DataPointer = DataLocStart TO DataLocStop STEP 2
    READ DataPointer, SecondsCounter, StepCounter
    FOR Temp01 = 1 TO StepCounter
      FOR Temp02 = 1 TO SecondsCounter
        IF SetRunPin = 0 THEN
          GOTO setup
        ENDIF
        PAUSE 1000
      NEXT Temp02
      SOUND AudioPin,(100, 80)
      LET BeepCounter = BeepCounter + 1
      OutputValue(BeepCounter)
      NEXT Temp01
  NEXT DataPointer

LOOP

; The interrupt is active only when the SetRunPin is low, i.e. for selectimg
; the test.
interrupt:
IF SelDownPin = 0 THEN
  LET Exercise = Exercise - 1 MIN 1
ENDIF
IF SelUpPin = 0 THEN
  LET Exercise = Exercise + 1 MAX 9
ENDIF
PAUSE 750 ; Crappy SW de-bounce filter. If no good, go back to HW solution.
SETINT OR 0x00, 0x03
RETURN
The problem line is line 88, the first SETINT statement. As already stated, everything seems to be fine when I simulate with PE6.0.9.3, getting the results I would want. However, when I simulate using the AXE14M2.MDF model then it's a different story. The interrupt always triggers -- seemingly no matter what I do to the C.0 and C.1 inputs. The interrupt is re-activated in the interrupt sub-routine, and when this returns, the interrupt triggers again instantly. This then repeats perpetually. If I comment out the first SETINT command then the interrupt never gets set and the main looping part of the programme runs as expected. From this I've concluded that the AXE14M2.MDF model is faulty.
 

Attachments

hippy

Technical Support
Staff member
#4
This simulates correctly in PE6.0.9.3, but completely misbehaves in the mixed signal environment. I'm hoping that the solution will be a fairly simple update to the AXE14M2.MDF model file. Could someone at RevEd take a look at this please?
We will take a look at this and other issues you have raised. Whether any alterations would be 'a fairly simple update', would only be determined by that investigation.

When posting PICAXE VSM issues; it always helps to post the VSM design file (.DSN) along with the program. That saves time in having to create test simulations and potentially ending up with differences to the design actually being used which may deliver different results.
 

Technical

Technical Support
Staff member
#5
Normally this type of VSM issue is where the simulation does not have a common simulation ground (e.g. the external components (which should be a digital resistor to switch) accidentally do not use the same two power rails as the PICAXE model).

SETINT OR 0x00, 0x03

is the same as

'is not' SETINT 0x03,0x03

and hence anything in the digital simulation not pulling either pin high correctly will cause an immediate trigger.

In the PDF screenshot there are two ground rails 0V_A and 0V_B - but are these actually 'simulation joined'? Add earth symbols to both.
 
#6
Thanks hippy and Technical for your inputs. There is a single 0V rail, the various separately drawn parts being connected by signal naming, "ZEROV" and "LOGIC0". 0V_A and 0V_B are components on this rail: solder pins for connecting to the off PCB circuitry. I've just double-checked the simulation and all switches are functioning correctly -- red or blue square dots are clearly seen at each of the inputs (and outputs, for that matter) of the 14M2, changing correctly as the switches are opened and closed.
 
Last edited:

Technical

Technical Support
Staff member
#7
To be able to look at this further we will need copies of your .dsn file and .bas files, please send by email.
 
#8
Hi Technical,

Generating a suitable .dsn file is going to be time consuming, assuming I can do it at all, that is. I haven't used Proteus v7 for some years now, having switched to v8. I can send you the .pdsprj file without any problem, but I suspect that you won't be able to handle it. Is this correct? I may also need to generate some component views and models for v7, since quite a lot of what I use has been generated by me for v8. I'll do what I can, but it won't be quick unless you can use Proteus v8 files directly.
 
Top