PDA

View Full Version : Portb = % ???



xobx
- 23rd July 2007, 14:51
Shouldnt this code make all leds on PORTB blink?
Now its only one led thats blink (PORTB.1)



@ device pic16F648A, hs_osc, wdt_off, mclr_on, lvp_off, protect_off
DEFINE OSC 20


loop:

high PORTB = %11111111
pause 250
low PORTB = %11111111
pause 250
goto loop
end

sayzer
- 23rd July 2007, 15:10
TRISB = 0 'Assign all pins as output pins.

loop:

PORTB = 255 'Set all PortB pins HIGH. Or, PORTB = %11111111.
PAUSE 250
PORTB = 0 'Set all PortB pins LOW. Or, PORTB = %00000000.
PAUSE 250
GOTO loop


' "HIGH" Command can be used for an individual pin.
' Ex: HIGH PORTB.0 'This will set PORTB.0 high.
' LOW PORTB.0 'This will set PORTB.0 Low.

end

Melanie
- 23rd July 2007, 17:03
Sigh....

Only the third time THIS MONTH...

If you read the manual, or downloaded the manual (it's FREE!!!) if you don't have one, or SEARCHED the forum, you will have discovered that HIGH and LOW only work on a PIN and NOT on a PORT which is why you're only blinking ONE pin.

ooops... just noticed that's what sayzer just said... ah well, nothing like reenforcing the message....