PDA

View Full Version : New user with PAUSE command problem



Howy
- 5th August 2004, 17:06
Hi All,

I seem to be having a problem when I use the PAUSE command in my code (basically renders the program inoperable).

I've reverted to the blink.bas example code to try a figure out what's going on here. I'm using PIC16F84a controller,the PicBasic Pro Compiler and MELabs's serial programmer.

I am confident that the circuit is wired correctly. The controller seems to be functioning to some degree as I am able to set PORTB.0 and PORTB.1 HIGH and have the LEDS light as expected. However, when I introduce a PAUSE command into the code nothing happens.

I have used mutiple 16F84A's so it does not seem to be a hardware problem. I have substitued a 4Mhz crytal/capcitor with a 4 Mhz resonator (and have verified that both are working with a frquency counter). Voltage to all pins reads correctly.

I have also played with every setting on the programmer.

Funny thing is this circuit worked before.

I know I must be doing something wrong here ... but for the life of can't figure what. Any help or ideas would be greatly appreciated ....

Howard.

Dwayne
- 5th August 2004, 19:11
Hello Howard,

Howard>>I know I must be doing something wrong here ... but for the life of can't figure what. Any help or ideas would be greatly appreciated ....<<

The pause command works great... If you can give us a water down code that shows where the pause does *not* work, maybe we can take a look at it....


Have you tried Pauseus or slower Pause command to verify?
Like Pauseus 1? then Pauseus 10 etc?

I thought I ran into something like this with the 688, until I found out the speed was set to the lowest of 34khz? And my program crawled....while I thought it was dead.

And, just to through out a few other things...Are you sure the pin you are checking is set as a output pin? Are you sure the pin you are using *IS* a i/o pin?

Are you reloading a a HEX file, instead of recompiling it and reloading it? Nothing like having a working hex file, and the code that is in the window does not match the Hex file <g>.


Dwayne

Howy
- 5th August 2004, 19:31
Dwayne,

Thanks for the reply. No matter where I place the PAUSE command the problem occurs. It seems to be related to the fact the the PAUSE simply exists somewhere in the code. For example ...

loop:
high PortB.0
low PortB.0
goto loop

works fine. LED lights.

loop:
high PortB.0
low PortB.0
goto loop
PAUSE 500

or,

PAUSE 500
loop:
high PortB.0
low PortB.0
goto loop

does not work.

I have also experimented with the PAUSEUS command and varying the period on both PAUSE commands.

A frquency counter shows the crystal to working as expected at 4MHz and the LED pin at 105KHz. When I add a PAUSE to the code LED pin reads 0 KHz.

Hope this info helps ...

Howard

NavMicroSystems
- 5th August 2004, 19:56
Howard,

if the code examples really are what you have tried, PAUSE is working as designed.


loop:
high PortB.0
low PortB.0
goto loop

works fine. LED lights.
>> In this example the LED is turned on and off over and over again, it is on about 50% of the time and due to the execution speed of the program you cant see any flickering.



loop:
high PortB.0
low PortB.0
goto loop
PAUSE 500

>>see first example, the Pause command will never be executed as there is a Loop....Goto Loop

or,

PAUSE 500
loop:
high PortB.0
low PortB.0
goto loop

>> This is almost the same as the other two examples, with one difference, there is a 500ms delay until the loop starts.

try this:


loop:
high PortB.0
PAUSE 500
low PortB.0
PAUSE 500
goto loop


rgds

Ralph

Howy
- 5th August 2004, 20:11
Dwayne and Ralph,

Thanks so much for your help!! I reinstalled both PBP and the programmer and guess what ... IT WORKS!!! I just wish I knew why it failed in the first place.

Thanks again Guys!!

Howard

CBUK
- 5th August 2004, 20:57
if you re look over your program....

loop:
high PortB.0
low PortB.0
goto loop
PAUSE 500

imagine that the lines are being processed and scanned in less than micro seconds, you send portb.0 high, then microseconds later you are telling it to turn off. now that output is on for micro seconds, but our eyes react way to slow to beable to see this. so yes the program is working, but do as whats been done in the above post and put in a pause between the highs, and lows

Chris

Dwayne
- 6th August 2004, 01:54
Hello Howard,

H>>Dwayne and Ralph,

Thanks so much for your help!! I reinstalled both PBP and the programmer and guess what ... IT WORKS!!! I just wish I knew why it failed in the first place.

Thanks again Guys!!<<

Your welcome!!! Have some fun with that chip of yours, and Don't pause too long, or you will get tired of waiting!

DWayne