Shop OBEX P1 Docs P2 Docs Learn Events
What am I doing wrong? — Parallax Forums

What am I doing wrong?

Spork FrogSpork Frog Posts: 212
edited 2007-03-24 21:35 in Propeller 1
My code is as follows:

CON   

  _xinfreq = 10_000_000
  _clkmode = xtal1 + pll8x 

PUB Main

  cognew(@entry, 0)
                                     
DAT

entry   org   0

        mov   dira, #1
        mov   time, cnt
        
:loop   waitcnt time, delay
        xor   outa, #1            
        jmp   #:loop

time    res   1
delay   long  40_000_000



I'm trying to toggle an LED on pin 0, the debug LED on the Hydra. But, it's not working, for some reason. Can anyone show me what I'm doing wrong?

Comments

  • Graham StablerGraham Stabler Posts: 2,510
    edited 2007-03-24 21:32
    The only thing I can see is that your res should come after your float declaration.

    delay   long  40_000_000
    time    res   1
    
    



    Its one of those things.

    Graham
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-24 21:33
    you have to place RESs after anything else that's on the same cog. The long "delay" gets overwritten now - RES increments program counter but doesn't take up any space.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-03-24 21:34
    All res declarations need to come at the end of an orged DAT segment. The way you've written it, the 40_000_000 you meant for delay gets loaded into time when the program is started via cognew.

    -Phil
  • cgraceycgracey Posts: 14,133
    edited 2007-03-24 21:34
    Two things are wrong here:
    LarryHedgehog said...
    My code is as follows:

    CON   
    
      _xinfreq = 10_000_000
      _clkmode = xtal1 + pll8x 
    
    PUB Main
    
      cognew(@entry, 0)
                                         
    DAT
    
    entry   org   0
    
            mov   dira, #1
            mov   time, cnt
    [b][color=red]        ADD   time,delay      'YOU NEED TO SET THE INITIAL CNT TARGET
    [/color][/b]        
    :loop   waitcnt time, delay
            xor   outa, #1            
            jmp   #:loop
    
    [b][color=red]delay   long  40_000_000      'ALL DECLARED DATA MUST PRECEDE ANY RES's[/color][/b]
    [b][color=red]time    res   1
    [/color][/b]
    



    I'm trying to toggle an LED on pin 0, the debug LED on the Hydra. But, it's not working, for some reason. Can anyone show me what I'm doing wrong?
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Spork FrogSpork Frog Posts: 212
    edited 2007-03-24 21:35
    Ah... now it works.

    Thanks for the help
Sign In or Register to comment.