Newbie: Trying to blink a LED using PIC

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

Reply to
Jack B. Pollack
Loading thread data ...

same.

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

Reply to
PeteG

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?

a

to

Reply to
Jack B. Pollack

--
Yeah.

Since it seems like you\'re going to be here for a while, why not do
like the Romans do and bottom post?
Reply to
John Fields

Studio

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

Reply to
PeteG

using a

same.

ANSEL = 0

Reply to
Anthony Fremont

Put the word "End" inside your code and try again.

"Jack B. Pollack" ?ÈëÏû?ÐÂÎÅ:DL2Mf.5715$ snipped-for-privacy@news-wrt-01.rdc-nyc.rr.com...

Reply to
Boon

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

formatting link
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.

Reply to
Anonymous

same.

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

Reply to
Jack B. Pollack

Ah yes - just like the CMCON = 7 in Picbasic Pro for the 16F628 I've been learning to use.

Jack have a look at this page. I'm certainly printing it off for future reference.

formatting link

Cheers,

Andrew.

Reply to
Anonymous

Hi

I have an LED blinking program for the PIC 12F675 on my new site, more to follow soon:

formatting link

Regards Alan

formatting link

Reply to
electronic-eng.com

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.