SerIn and SerInt

dlenox

New Member
new guy here,

I have an 18x chip and simply trying to count high pulses coming into Input #0 generated by a magnetic reed switch closure at a very slow rate of speed. (I assume that high means +5v, and low means 0v)

I seem to be having a problem with the following code

Code:
    w1 = 0
    SerInt 1,1

Top:
    SerIn 1, N4800, b0

    If b0 = "P" Then GoTo SendCount

    SerOut 4, N4800, ("?", 0x0d, 0x0a)
    GoTo Top

SendCount:
    SetInt OFF
    w2 = w1 + 65
    w1 = 0
    SetInt 1,1

    SerOut 4, N4800, ("<P>", w2, "</P?, 0x0d, 0x0a)
    GoTo Top

interrupt:
    w1 = w1 + 1
    SetInt 1,1
    return
I never see the interrupt! Does it have to do with my blocking using a SerIn command?

Modified code to interrupt on low, but with same results.

Any ideas what I am doing wrong?

thanks,
Dan
 

hippy

Ex-Staff (retired)
Yes; while waiting for something to be received with SERIN the PICAXE will not be servicing interrupts.

It should be possible to reconfigure the TIMER hardware within the PICAXE by poking SFR's so it counts external pulses but that would require some effort to do, particularly needing an understanding of the TIMER hardware within the 16F88.
 

lahaye

Member
I think this is a bit strange... you have misspelled Setint twice (once in your title and once in your code). The one in the code should prevent this code from getting simulated and/or downloaded onto your PICAXE so with the code you have posted you should get a Syntax error on line 2. It certainly doesn't run on my Programming Editor (Version 5.2.0 set to an 18X) when I try to simulate your code => Syntax Error (on line 2 which is SerInt 1,1).

I changed your code a bit: Setint not SerInt + Pause 3000 (so I have enough time to get into step-trough-mode before I have to enter something).
Then the Interrupt works on Input 0

Code:
 w1 = 0
 SetInt 1,1

Top:
Pause 3000
    SerIn 1, N4800, b0

    If b0 = "P" Then GoTo SendCount

    SerOut 4, N4800, ("?", 0x0d, 0x0a)
    GoTo Top

SendCount:
    SetInt OFF
    w2 = w1 + 65
    w1 = 0
    SetInt 1,1

    'SerOut 4, N4800, ("<P>", w2, "</P?, 0x0d, 0x0a)
    GoTo Top

interrupt:
    w1 = w1 + 1
    SetInt 1,1
    return

[Edit]
Please note that I only tested this in the simulator.
Just saw hippys comment: The simulator doesn't let you do anything during Serin (hence the pause to have some time to step trough or turn an Input high before you get into an eternal Enter-something loops)
[/Edit]
 
Last edited:

dlenox

New Member
typo here

lahaye,

it was a typo on my part putting the code into this forum...

I am doing development on another machine and had to type it in here, when I did so I typed incorrectly. I looked on the other machine and have it typed correctly.

I must have gotten a bit dizzy looking back/forth between computers...

Dan
 

dlenox

New Member
hippy,

Yes; while waiting for something to be received with SERIN the PICAXE will not be servicing interrupts.

It should be possible to reconfigure the TIMER hardware within the PICAXE by poking SFR's so it counts external pulses but that would require some effort to do, particularly needing an understanding of the TIMER hardware within the 16F88.
thanks, wish that the help .pdf files stated this...

I will be migrating the code to a 28x chip, any differences there?

Dan
 
Top