PDA

View Full Version : Out of loop and no repeating



Areal Person
11-10-2006, 09:42 AM
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[Pin]~~
· repeat Count·············· 'Repeat for Count iterations
··· !outa[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[Pin]~~
· repeat Count·············· 'Repeat for Count iterations
··· !outa[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

cgracey
11-10-2006, 09:54 AM
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 Person
11-10-2006, 10:07 AM
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

SailerMan
11-10-2006, 10:26 AM
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

cgracey
11-10-2006, 10:26 AM
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[Pin]~~
· repeat Count·············· 'Repeat for Count iterations
··· !outa[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 Person
11-10-2006, 10:44 AM
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 !