Shop OBEX P1 Docs P2 Docs Learn Events
PLease, make it stop ! — Parallax Forums

PLease, make it stop !

PliersPliers Posts: 280
edited 2008-11-27 02:08 in Propeller 1
I was just playing around, when I did this.....
PUB IOTEST
   cognew(@IO_TEST, 0)
DAT
  ORG 0
  IO_TEST
  MOV DIRA, #$01 
  MOV Outa, #1                   
  MOV Outa, #0



I thought it would pulse pin 1 once.
To my surprise it keeps pulsing at a rate of 6.4 Khz, with an "ON time" of 0.31 us.
I tried a few things to make it stop(via code), but it won't.
Somebody said...
The more I learn, the more I don't know.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-26 21:00
    There's nothing to stop your program from repeating over and over again. The cog gets filled with whatever follows your DAT section in hub memory and that will execute after your last MOV. If it's mostly zeroes, they won't do anything and, eventually, the cog program counter will wrap around and your short program will repeat. You can use either
    hang   jmp   #hang
    


    or
         cogid     temp
         cogstop  temp
    temp  long   0
    

    at the end of your short program

    Post Edited (Mike Green) : 11/26/2008 9:11:14 PM GMT
  • PliersPliers Posts: 280
    edited 2008-11-26 21:43
    Thanks Mike.
  • BergamotBergamot Posts: 185
    edited 2008-11-26 22:06
    Most processors try to hide the 'hang' command smilewinkgrin.gif

    EDIT: Ahh, nevermind, he's just repeatedly jumping to the same line, called "hang"

    Post Edited (Bergamot) : 11/26/2008 10:23:47 PM GMT
  • Bill SCBill SC Posts: 17
    edited 2008-11-26 22:10
    Hang command? Maybe you will have a laugh at a newbie, but is there such a command... like wait or pause?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-26 22:14
    There's the WAITCNT, WAITPNE, and WAITPEQ instructions which "hang" the processor until either a specific system clock time occurs (with wraparound around 50 seconds with an 80MHz system clock) or a specific I/O pin configuration occurs. Read the appropriate sections of the Propeller Manual for details.

    There's also the WAITVID instruction used to wait until the video generator is ready for data.· If the video generator for the cog isn't running, it will wait forever (which is what you want here).
    ·
  • rokickirokicki Posts: 1,000
    edited 2008-11-26 23:55
    Unfortunately, the "HCF" (halt and catch fire, which attempts to cause all pins to
    oscillate at 80MHz in order to draw enough current to ignite)---doesn't quite work.

    I guess we need another external device to act as coprocessor for this instruction.
  • RaymanRayman Posts: 14,597
    edited 2008-11-27 00:34
    It was a little short-sighted (IMHO) not to have a "HALT" instruction... Would have saved me, and apparently some other people, a great deal of fustration!

    Ooops!· I forgot for a second that contest deliberations were ongoing...

    I think the COGID/COGSTOP combo is the best way to stop the cog and free it up at the end of the code.

    Post Edited (Rayman) : 11/27/2008 1:18:07 AM GMT
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-11-27 00:49
    rokicki said...
    Unfortunately, the "HCF" (halt and catch fire, which attempts to cause all pins to
    oscillate at 80MHz in order to draw enough current to ignite)---doesn't quite work.

    I guess we need another external device to act as coprocessor for this instruction.

    That'd be over in this thread:

    http://forums.parallax.com/showthread.php?p=765599

    The device described there would do a nice job of stopping pin 1 from pulsing.
  • awesomeduckawesomeduck Posts: 87
    edited 2008-11-27 01:11
    Is there someway to configure the CLK register to halt the whole CPU? Seems like some combination of the OSCENA and CLKSEL bits might be able to cause you to hang. For example, CLK = 00000010 looks potentially hang-able. Force the source to the Oscillator but don't enable the output from the Oscillator. Just a guess, but worth a shot.
  • dpescheldpeschel Posts: 16
    edited 2008-11-27 02:08
    Good guess. The built-in downloader uses that technique to stop the system if something goes wrong with the download.
Sign In or Register to comment.