Maker Pro
Maker Pro

Newbie: Trying to blink a LED using PIC

J

Jack B. Pollack

Jan 1, 1970
0
Can someone help me get started. I have been trying to blink a LED using a
16F88 all morning without any success.

I am not seeing any logic levels on any of the outputs (they are all
tri-stated). I have tried a different chip and the second one does the same.


What is wrong with my code?


@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, WDT_OFF
OSCCON = $60

LOW PORTB.1

LOOP:
Toggle PORTB.1
Pause 1000
GoTo LOOP
 
P

PeteG

Jan 1, 1970
0
Jack B. Pollack said:
Can someone help me get started. I have been trying to blink a LED using a
16F88 all morning without any success.

I am not seeing any logic levels on any of the outputs (they are all
tri-stated). I have tried a different chip and the second one does the same.


What is wrong with my code?


@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, WDT_OFF
OSCCON = $60

LOW PORTB.1

LOOP:
Toggle PORTB.1
Pause 1000
GoTo LOOP
After power up the ports are set to input. I don't see anything in those
commands that set the port or the pin to output before you start writing to
it. The fact that you say the pins are all tri-stated suggest the same.

You need to find the command to set the TRISB register to output on that
pin. Since I'm not sure what language you're writing in I don't know what
command you need to add but I'm sure you can work it out.

Pete
 
J

Jack B. Pollack

Jan 1, 1970
0
Thanks for your reply.

I just tried TRISB = %00000000 and Output B.1

Both are valid commands according to the help file for the MicroCode Studio
editor/compiler. Unfortunately results are the same (tri-state).
Any other ideas?
 
J

John Fields

Jan 1, 1970
0
Thanks for your reply.

I just tried TRISB = %00000000 and Output B.1

Both are valid commands according to the help file for the MicroCode Studio
editor/compiler. Unfortunately results are the same (tri-state).
Any other ideas?
 
P

PeteG

Jan 1, 1970
0
Jack B. Pollack said:
Thanks for your reply.

I just tried TRISB = %00000000 and Output B.1

Both are valid commands according to the help file for the MicroCode Studio
editor/compiler. Unfortunately results are the same (tri-state).
Any other ideas?
Nothing that comes to mind.

May be someone who has some knowledge of the language you are using can
help.

There's really not that much more to blinking a LED on a PIC than what I see
you're doing.

Also, you should put your reply at the bottom of the message not the top;
it's newgroup etiquette.

Pete
 
A

Anthony Fremont

Jan 1, 1970
0
Jack B. Pollack said:
Can someone help me get started. I have been trying to blink a LED using a
16F88 all morning without any success.

I am not seeing any logic levels on any of the outputs (they are all
tri-stated). I have tried a different chip and the second one does the same.


What is wrong with my code?


@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, WDT_OFF
OSCCON = $60

ANSEL = 0
 
B

Boon

Jan 1, 1970
0
Put the word "End" inside your code and try again.
 
R

Rubicon

Jan 1, 1970
0
Hello,

It looks like PicBasic or PicBasic Pro.

I haven't used the 16F88 PIC but a search has shown it has the same
pinout as the 16F84 and uses an internal oscillator. Pete is right in
that you have to set the TRISA and TRISB registers to what you want.

For example using a 16F84
TRISA = %00000 'All PortA output pins output
PORTA = 0 'Set all PortA pins LOW
TRISB = %01000010 'RB1 & RB6 input all other PortB pins output
PORTB = 0 'Set all PortB output pins LOW

If you go to http://picbasic.com/resources/index.htm there is a forum
and an archive available. However it seems the forum may be down at
the moment, either that or my PC is playing up.

I'm no expert but try the program below. I've dressed it up a little
with remarks as it's a good habit to get into for when you start on
much larger programs. I'll remember that and three months later when
you look at it again it's "What?"


'********************************
' Blinking LED program *
'********************************

'CONFIGURATION FUSES
'*******************
@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, WDT_OFF


'HARDWARE SETUP
'**************
OSCCON = $60 'Enable internal oscillator
TRISA = %00000 'All PortA pins output
PORTA = 0 'Set all PortA output pins LOW
TRISB = %00000000 'All PortB pins output
PORTB = 0 'Set all PortB output pins LOW


'PROGRAM
'*******
LOOP: 'Main program start
Toggle PORTB.1 'Invert RB1 pin
Pause 1000 'Pause for 1 second
GoTo LOOP 'Return to main program start

'*****************************************************


Cheers,

Andrew.
 
J

Jack B. Pollack

Jan 1, 1970
0
Jack B. Pollack said:
Can someone help me get started. I have been trying to blink a LED using a
16F88 all morning without any success.

I am not seeing any logic levels on any of the outputs (they are all
tri-stated). I have tried a different chip and the second one does the same.


What is wrong with my code?


@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, WDT_OFF
OSCCON = $60

LOW PORTB.1

LOOP:
Toggle PORTB.1
Pause 1000
GoTo LOOP

Thanks to all that posted. I found the problem was a bad PIC programmer.
Everything is working great now.
Thanks again.
 
Top