PDA

View Full Version : PIC16F88 problem with TOGGLE command?



russman613
- 17th September 2006, 22:37
I am using a very slighly modified version of the blink sample program:

@ DEVICE PIC16F88, HS_OSC
define OSC 20
pinLED var portb.7

loop:
high pinLED ' Turn on LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds
low pinLED
pause 500

Goto loop ' Go back to loop and blink LED forever

End

I am using the following software:
~~~~~~~~~~~~~~~~~~~~~~
- MicroCode Studio version 2.3.0.0
- melabs Programmer Version 4.01
- PicBasic Pro version version 2.46 (with the lastest patch installed even though
it does not show the version on the command line.

For hardware, I am using:
~~~~~~~~~~~~~~~~~
- PIC16F88
- 20 Mhz Resonator
- PICPROTO18L board
- melabs USB Programmer

The Problem:
~~~~~~~~~

When i modify the program as follows:

@ DEVICE PIC16F88, HS_OSC
define OSC 20
pinLED var portb.7

loop:
toggle pinLED
'high pinLED ' Turn on LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds
'low pinLED
'pause 500

Goto loop ' Go back to loop and blink LED forever
End

the LED does not blink. The strange thing is, when I put the LED on portb.0 through portb.5 it works just fine. For all porta and portb.6, portb.7 the toggle command does not function.

What am I missing or is there a known issue?

keithdoxey
- 17th September 2006, 23:12
The Problem:
~~~~~~~~~

the LED does not blink. The strange thing is, when I put the LED on portb.0 through portb.5 it works just fine. For all porta and portb.6, portb.7 the toggle command does not function.

What am I missing or is there a known issue?

Try adding the line ANSEL=0

The pins that "dont work" are analogue by default.

"Toggle" reads the port data register, modifies the appropriate bit and writes it back to the data register. Because they are analogue inputs they read as "0" so toggle will always set it to a "1" but you wont read that value back.

Had me stumped the first time I came across it :)

russman613
- 17th September 2006, 23:31
Keith - you are a rock star.

that did it for me - guess i still have some data sheet reading to do ...

thx for the TOGGLE russFrustration.

Russ