Shop OBEX P1 Docs P2 Docs Learn Events
Out of loop and no repeating — Parallax Forums

Out of loop and no repeating

Areal PersonAreal Person Posts: 197
edited 2006-11-10 03:44 in Propeller 1
Hi my chip is not running correctly, I got it wired on my breadboard

When I do F7 - everything is OK
The chip will not repeat and/or return/loop correctly
I can execute the example 01 code only one time / all my pins
work ok.

This only flashes pin 16 one time, It willnot execute the toggle(17...) line
pin 17 works if I just hardcode it in pub toggle, but it willnot loop/repeat

Also, is the EEPROM required ? or is it optional for development, I know

its nice and all, but is it required for the propeller to function correctly ?

PUB Main
· Toggle(16, 3_000_000, 10)· 'Toggle P16 ten times, 1/4 s each
· Toggle(17, 3_000_000, 10)· 'Toggle P17 twenty times, 1/6 s each


PUB Toggle(Pin, Delay, Count)
{{Toggle Pin, Count times with Delay clock cycles in between.}}

· dira[noparse][[/noparse]Pin]~~
· repeat Count·············· 'Repeat for Count iterations
··· !outa[noparse][[/noparse]Pin]
··· waitcnt(Delay + cnt)····

Thanks,



Ok, thanks, I changed it to 3_000_000, thats what the example uses.

I made a typo, it was not 0, but your kinda right, when I changed it to 500

both leds flashed, but only one time, not looping this code only flashes each led one time



PUB Main
· repeat
··· Toggle(16, 500, 10)· 'Toggle P16 ten times, 1/4 s each
··· Toggle(17, 500, 10)· 'Toggle P17 ten times, 1/6 s each


PUB Toggle(Pin, Delay, Count)
{{Toggle Pin, Count times with Delay clock cycles in between.}}

· dira[noparse][[/noparse]Pin]~~
· repeat Count·············· 'Repeat for Count iterations
··· !outa[noparse][[/noparse]Pin]
··· waitcnt(Delay + cnt)·

I need it to run forever, and it will not

Post Edited (Areal Person) : 11/10/2006 3:08:18 AM GMT

Comments

  • cgraceycgracey Posts: 14,206
    edited 2006-11-10 02:54
    You can't do an effective waitcnt(0+cnt). The problem is that 0+cnt is computed, but cnt is immediately past the target. You wind up waiting for the 32-bit counter to loop all the way around again, taking a very long time (~5 minutes at RCFAST's 12MHz). If you specified a delay of at least 500, it should work fine.

    BTW, you don't need an EEPROM, or even a crystal for development, just the chip and a means to load it. Connecting BOEn to VSS will make life easier, too.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Areal PersonAreal Person Posts: 197
    edited 2006-11-10 03:07
    bump, please see my notes above, thanks

    It's still not looping and flashing forever

    Post Edited (Areal Person) : 11/10/2006 3:25:48 AM GMT
  • SailerManSailerMan Posts: 337
    edited 2006-11-10 03:26
    It Should run indefinatley... What makes you feel otherwise? I used your code and hooked up a scope and sure enough I get a constantly running program.

    Use ctrl-I and see if your indentation is correct.


    A WaitCnt of 500 is only 6.25 microseconds. You wouldn't see any flashing. just probably a dim LED.


    Post Edited (SailerMan) : 11/10/2006 3:32:48 AM GMT
  • cgraceycgracey Posts: 14,206
    edited 2006-11-10 03:26
    Well, I ran your program, but had to change those 500 delays to 1_000_000 to get a slow-enough flash rate. It works fine on my Demo Board:

    PUB Main
    · repeat
    ··· Toggle(16, 1_000_000, 10)· 'Toggle P16 ten times, 1/4 s each
    ··· Toggle(17, 1_000_000, 10)· 'Toggle P17 ten times, 1/6 s each


    PUB Toggle(Pin, Delay, Count)
    {{Toggle Pin, Count times with Delay clock cycles in between.}}

    · dira[noparse][[/noparse]Pin]~~
    · repeat Count·············· 'Repeat for Count iterations
    ··· !outa[noparse][[/noparse]Pin]
    ··· waitcnt(Delay + cnt)·



    Could you be having a power-supply issue? It helps to have a 1uF cap tied across VSS and VDD right near the chip. Also, you need to be able to supply sustained current of probably 5ma to VDD, assuming your using ~300 ohm resistors on your LEDs. I don't know what else the problem could be.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Areal PersonAreal Person Posts: 197
    edited 2006-11-10 03:44
    Yep,

    OK, dumb newbie mistake, my input voltage dropped to 3.0- volts, but
    I don't know why it was still showing a good 3.3 over vdd, probly the caps charging
    and current was not stable. BINGO - I ramped up.

    Thanks, I'm on my way now, cool !
Sign In or Register to comment.