Shop OBEX P1 Docs P2 Docs Learn Events
need help with direct digital synthesizer — Parallax Forums

need help with direct digital synthesizer

IanMIanM Posts: 40
edited 2006-12-05 21:42 in Propeller 1
I'm looking to cut just one instruction from the following code to get down to 7 so that it can run on 7 cogs and have a free cog for control. The code implements a pipelined DDS with an equivalent clock of 20MHz:

.ddsloop        movs tabi,tmp
                add   acc,phase
                mov   tmp,acc
                shr   tmp,#24 'get the high byte
.tabi           mov   outa,0-0
                mov   outa,#0 'allow other cogs access
                test  ina,mask wz 'time to exit?
            ifz jmp   #ddsloop

.mask           long  $10000000 'bit to exit on
.acc            long  0 'set up at init
.phase          long  0 'set up at init
.tmp            long  0




If I dispense with "test" as a means of exiting gracefully, then there are 7 instructions but i'll need to stop the cogs manually. That might not be a problem but I'm planning on driving the clock input of another prop and it might not like a big change in phase on it's clock input! So i'm looking for a gracefull way of exiting in 7 (or fewer) instructions.

Cheers, Ian

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ian Mitchell
www.research.utas.edu.au

Comments

  • rokickirokicki Posts: 1,000
    edited 2006-12-05 03:35
    Easiest way I see is to unroll the loop once, and then split the test of the pin and the djnz.

    So:

    .ddsloop movs tabi,tmp
    add acc,phase
    mov tmp,acc
    shr tmp,#24 'get the high byte
    .tabi mov outa,0-0
    mov outa,#0 'allow other cogs access
    test ina,mask wz 'time to exit?
    movs tabi2,tmp
    add acc,phase
    mov tmp,acc
    shr tmp,#24 'get the high byte
    .tabi2 mov outa,0-0
    mov outa,#0 'allow other cogs access
    ifz jmp #ddsloop
  • IanMIanM Posts: 40
    edited 2006-12-05 03:43
    How cool is that! Brilliant, thanks man!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ian Mitchell
    www.research.utas.edu.au
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-12-05 03:54
    Ian,

    How many bits of OUTA (and which ones) are you actually using for your synth output?

    -Phil
  • IanMIanM Posts: 40
    edited 2006-12-05 04:21
    I haven't decided yet. The sine lookup will be 256 entries out of cog memory - perhaps 10 bits to the port will suffice. But because it's a lookup, any pin combination will work. In fact, for one project i'll be using two sets in quadrature.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ian Mitchell
    www.research.utas.edu.au
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-12-05 06:26
    Oh, okay. I was thinking that if you were using eight bits, there might be some clever way to press the video circuitry into service.

    -Phil
  • nutsonnutson Posts: 242
    edited 2006-12-05 15:21
    Carefull, "test ina,mask" does not work, ina can only be used as a source. See the tricks and traps document. "test mask, ina" does work. I fell into this one myself....(only once)

    Nico
  • IanMIanM Posts: 40
    edited 2006-12-05 21:42
    yes, thanks for that

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ian Mitchell
    www.research.utas.edu.au
Sign In or Register to comment.