Shop OBEX P1 Docs P2 Docs Learn Events
Time between outa and subsequent outa ? — Parallax Forums

Time between outa and subsequent outa ?

RogerInHawaiiRogerInHawaii Posts: 87
edited 2009-05-09 00:14 in Propeller 1
If I do two outa operations, as in


outa[noparse][[/noparse]pin1]~~
outa[noparse][[/noparse]pin2]~~

how much time is there between the two operations? That is, how long between the setting of pin 1 and the setting of pin2?

Post Edited (RogerInHawaii) : 5/8/2009 8:36:49 PM GMT

Comments

  • RaymanRayman Posts: 14,827
    edited 2009-05-08 20:41
    That's kinda a problem with SPIN... You pretty much need to use Waitcnt or do it in assembly to get known timing. But, if you don't change anything in those two lines the timing should be determinist (at least I'd think so). But, it would take some work (or an oscope) to figure it out...

    Actually, you could used jazzed's tool or viewport to see it....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • RogerInHawaiiRogerInHawaii Posts: 87
    edited 2009-05-08 21:17
    Hmmm, assembly code. I seem to recall something in the user manual or somewhere that you can define assembly code somewhat directly within SPIN code. How would I do those two outa instructions in assembly, within SPIN?
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-05-08 21:21
    I wrote a debugger which will give you the actual number of instructions (both pasm and spin) so you could determine this. See my signature for a link to tools and that thread will give you the Zero Footprint debugger.

    Update: Also look at the new announcement PST Lite - not sure if this will do the count or not.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: Micros eg Altair, and Terminals eg VT100 (Index)
    · Search the Propeller forums (via Google)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm

    Post Edited (Cluso99) : 5/8/2009 9:31:44 PM GMT
  • BEEPBEEP Posts: 58
    edited 2009-05-08 21:21
    80 MHz Clock Speed - approximately 8 µs
  • rokickirokicki Posts: 1,000
    edited 2009-05-08 21:23
    You could easily measure this exactly using the counters. Set up a counter to count how long a pin is high,
    do the two statements, and look at the counter register. All in Spin, of course.
  • RogerInHawaiiRogerInHawaii Posts: 87
    edited 2009-05-08 21:32
    BEEP said...
    80 MHz Clock Speed - approximately 8 µs

    8 µs. Thank you. That's what I was looking for.

    The device that I'm trying to control needs the second pin to go high within 1.8µs, so if it takes 8µs in SPIN I clearly can't handle it in SPIN.

    Is it even conceivable to do it within that time constraint by doing it in assembly?
  • jazzedjazzed Posts: 11,803
    edited 2009-05-08 22:00
    You could toggle bits at 10MHz with PASM if that's all you want to do. Each instruction takes 50ns at 80MHz except for HUB instructions. Use the counters for simple clocks at higher rates.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • RaymanRayman Posts: 14,827
    edited 2009-05-08 22:00
    I bet you could do it in SPIN using two cogs... Just have them wait for a slightly different WAITCNT...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-08 22:44
    I think you could do this all in Spin using the two cog counters.· Get the application note on the counters (AN001) from the Propeller downloads page and read through it.· You'd set up both counters so they increment at something on the order of the clock rate.· You set up one counter to overflow maybe 50us later and the other counter to overflow maybe 51us or whatever·later.· Since you can't set both timers at the same time, you'd have to adjust the initial values by experiment.· One of the modes causes the associated output pin to toggle when the counter overflows.· At that point, you have lots of time before the counter wraps around again to reset them and terminate the output pulses.· If you use a pulldown on the two output pins, you could switch both pins to input mode [noparse][[/noparse]DIRA &= !(pinX | pin Y)] at the same time·causing both signals to become zero.

    With this scheme, you can get a granularity of about 6ns.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-08 23:22
    If your sole objective is for one output to trail another by a small non-zero amount, you can set up two counters, each with negative feedback, and the first feeding the second (using up a spare pin). In this program, CTRA's input is A0; its output, A1; CTRB's input, A1; its output A2:

    [b]CON[/b]
    
       [b]_clkmode[/b]       = [b]xtal1[/b] + [b]pll16x[/b]
       [b]_xinfreq[/b]       = 5_000_000
    
    [b]PUB[/b]  Start
    
      [b]ctra[/b] := %01001 << 26 | 1 << 9 | 0
      [b]ctrb[/b] := %01001 << 26 | 2 << 9 | 1
      [b]dira[/b] := 7
      [b]repeat[/b]
        [b]outa[/b][noparse][[/noparse]*0]~~
        [b]outa[/b][noparse][[/noparse]*0]~
    
    
    


    Here's the output it produces:

    attachment.php?attachmentid=60759

    -Phil
    640 x 480 - 16K
  • RogerInHawaiiRogerInHawaii Posts: 87
    edited 2009-05-08 23:57
    Mike and Phil,

    Excellent advice!

    Yes, my situation is that I've got this device that has two input pins. One pin needs a rising edge, followed by a rising edge on the second pin, with the second pin's rising edge occurring not more than 4ms after the first rising edge.

    I'll give that ctra, ctrb approach a try

    Thank you!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-09 00:11
    4 milliseconds is nearly forever using Spin. Keep it simple and use the two OUTA statements.
  • RogerInHawaiiRogerInHawaii Posts: 87
    edited 2009-05-09 00:14
    Sorry, I was reading the wrong page from the manual for the device I'm working on. It has two modes of operation. The one mode has a 4ms time range, the other has a 1.8 us time range. It's that shorter range mode that I
    m trying to get working.
Sign In or Register to comment.