Shop OBEX P1 Docs P2 Docs Learn Events
logic mode in counters: PHSx as index register? — Parallax Forums

logic mode in counters: PHSx as index register?

Fred HawkinsFred Hawkins Posts: 997
edited 2007-10-29 19:19 in Propeller 1
Is it possible to use the PHSx registers as index registers that increment once on a single software event?

IF·I read the Counters application note correctly, it seems that a pos edge event (any pin·connected to pin A, going from low to high) could be used to increment·PHSa and PHSb by whatever step value is placed into FRQa and FRQb.

My thought is to have two lock-step pointers to arrays, one in words, another in longs.

Ideally, could the counters be set up so they increment on both pos edges and neg edges? (That would allow a single line in the code to increment two registers).·

Post Edited (Fred Hawkins) : 10/29/2007 12:44:22 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-29 14:34
    You could set up the counters to work this way. You'd use the positive edge mode with the same I/O pin for both counters, set the DIRA bit to output mode, and toggle the OUTA bit from 0 to 1 (then back to 0) to increment both counters. In Spin, you could use
    (OUTA[noparse][[/noparse] <pin> ]!) | (OUTA[noparse][[/noparse] <pin> ]!)
    In assembly, you'd need two instructions to toggle the bit.
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-10-29 17:12
    Mike Green said...
    In assembly, you'd need two instructions to toggle the bit.
    and I was so hoping to skin that cat...
  • LawsonLawson Posts: 870
    edited 2007-10-29 18:22
    well... a COG counter in NCO mode can also be setup to generate a pulse with one instruction. I think some of the SPI code for the SD drivers do this, and it was discussed a few months ago on the forums too. Doesn't really help to create fast Hub-Cog or Cog-Hub block transfer code. (I assume two pointers would need to be updated with one instruction for that to happen?)

    my two cents,
    Marty

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Lunch cures all problems! have you had lunch?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-29 19:19
    Lawson,
    If you want to do the same thing that Rokicki does, you have to synchronize the cog counters and the cog's instruction stream. It's certainly doable and you can get higher transfer rates, but it's messier, particularly if you have to transfer the data directly to Hub memory.
Sign In or Register to comment.