20m2 code not working on 20x2

Sam1

New member
Hi,
I've searched forums, manuals etc but am stuck. Bit of a beginner so I hope I can be clear...

On my prototype I've a 20m2 performing actions based on a value it gets from a 14m2 via serin. I now wish to use a 20x2 in place of the 20m2 but the 20x2 refuses to work when I do a straight swap.

I have removed most of my code to test where the problem is and am still stuck.

The below test code works perfectly with the 20m2 but not 20x2. It uses an interrupt to blink an LED based on the val value received from the 14m2. Am I missing something obvious? The interrupt from the 14m2 is coming in on pin C.1

The reason I want to use a 20x2 is because I read elsewhere on this forum the x2 would be better to read MIDI which is the next step on my project.

Thanks in advance,
Sam

Code:
#picaxe 20x2   'change as necessary

symbol val = b1
symbol num = b2

main:

    let val = 0
    let num = 0

    setint %00000010, %00000010, C

stop

interrupt:

    high C.7                     ' send RTR message to other chip
    
    serin C.0, N2400, val             ' get the message

    gosub SendOutput              'act on the message

    low C.7                     ' clear RTR message to other chip to confirm message received

    do pause 5 loop until pinc.1 = 0     'wait to see that other chip has closed RTS message

      setint %00000010, %00000010, C     ' reset the interrupt

return
SendOutput:

    for num = 1 to val step 1
        high B.1
        pause 100
        low B.1
        pause 100
    next num
            
return
 

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

There's nothing I can see which would appear to be wrong with the code, anything which would make it not work on the 20X2 exactly as it does on the 20M2.

You could add "#TERMINAL 9600" at the top of the code and add SERTXD commands to see what's going on.

I would try these three programs first ...
Code:
#Picaxe 20X2
#Terminal 9600
#No_Data

Pause 2000
SerTxd( "Button Push Test Started", CR, LF )
Do
  Do : Loop Until pinC.1 = 1
  SerTxd(" Button on C.1 pushed", CR, LF )
  Do : Loop Until pinC.1 = 0
  SerTxd(" Button on C.1 released", CR, LF )
Loop
Code:
#Picaxe 20X2
#Terminal 9600
#No_Data

Pause 2000
SerTxd( "Button Interrupt Test Started", CR, LF )
Gosub Interrupt_Enable
Do:Loop

Interrupt:
  SerTxd( "Button on C.1 pushed", CR, LF )
  Do : Loop Until pinC.1 = 0
  SerTxd( "Button on C.1 released", CR, LF )
Interrupt_Enable:
  SetInt %00000010, %00000010, C
  Return
Code:
#Picaxe 20X2
#Terminal 9600
#No_Data

Pause 2000
SerTxd( "SERIN Test Started", CR, LF )
Do
  SerTxd( "C.7 receive ... " )
  High C.7
  SerIn C.0, N2400, b0
  Low C.7
  SerTxd( "Got ", #b0, CR, LF )
  Pause 1000
Loop
The #NO_DATA makes downloading slightly quicker when not using Data Eeprom.
 

inglewoodpete

Senior Member
Can you confirm that the download circuit resistors (10k + 22k) remain in place, even when the download cable is disconnected.
 
Top