Shop OBEX P1 Docs P2 Docs Learn Events
Any word on the Stingrays and when they will be back in stock? — Parallax Forums

Any word on the Stingrays and when they will be back in stock?

vyper4vyper4 Posts: 7
edited 2012-03-01 09:52 in General Discussion
...Patiently waiting for the mailperson with a box. :innocent:

On a different subject, and I am sure this will not get any visibility with this thread heading, but this is my first attempt at PASM, it simulates a ping sensor. Appreciate any feedback.
{PING_Spoof}

CON
  _CLKMODE = XTAL1 + PLL16X    'Set to ext low-speed crystal, 16x PLL
  _XINFREQ = 5_000_000        'Frequency on XIN pin is 5 MHz
  
VAR
  long  Stack1[9]                      'Stack space for new cog
  byte  Cog                           'Hold ID of cog in use, if any 
  long counter
PUB Start
  Stop
  Cog := cognew(@WaitHigh, 0)
PUB Stop
{{Stop toggling process, if any.}}
  if Cog
    cogstop(Cog~ - 1) 
PUB Active: YesNo
{{Return TRUE if process is active, FALSE otherwise.}}
  YesNo := Cog > 0
DAT
              org   0
WaitHigh      or    dira, PinMask               'Makes Pin Output
              andn   outa, PinMask              'Makes Pin Low
              andn   dira, PinMask              'Makes Pin Input
              test PinMask, ina wz
              if_z jmp #$-1
              test PinMask, ina wz
              if_nz jmp #$-1
              jmp #Toggle
              
Toggle        or    dira, PinMask               'Makes Pin Output
              or    outa, PinMask               'Makes Pin High
              mov   Time, cnt
              add   Time, #9
              waitcnt Time, Delay
              waitcnt Time, Delay
              or    dira, PinMask               'Makes Pin Output
              andn   outa, PinMask              'Makes Pin Low
              jmp   #WaitHigh  
PinMask long  |<23
Delay   long  141_000
Time          res   1
Sign In or Register to comment.