Log in

View Full Version : pic16F88 problems



sskeet
- 23rd January 2006, 05:48
Hi, I have had success testing other chips, but this 16F88 is driving me crazy...I have read all over this forum and google and cannot find out why...

First off, I have 5v power and ground hooked up correctly and have MCLR pullup attached. I am using picbasic pro 2.46 and EPIC programmer.

I am just trying to verify that I can do simple I/O before heading into my project, but when I test my blink program, no matter what I set the PAUSE to, the LED just flickers like crazy and sometimes very randomly...

Here is my code:
----------------------------
@ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF

DEFINE OSC 8

OSCCON = %01110000 ' INTRC = 8MHz

Pause 500 ' Wait for startup

loop:

LOW PORTB.4
Pause 5000 ' Wait 5 second

HIGH PORTB.4
Pause 5000 ' Wait 5 second
Goto loop ' Do it forever

END
------------------------------

The input voltage is stable, and I have 2 16f88 chips, so it is not a bad chip.

Thanks!

Dave
- 23rd January 2006, 11:42
sskeet, What are your settings when programming the micro? Do you have the OSC setting set for INTOSC? Check the settings when programming the chip as these will override the source code settings. HTH

Dave Purola,
N8NTA

sskeet
- 23rd January 2006, 14:24
sskeet, What are your settings when programming the micro? Do you have the OSC setting set for INTOSC? Check the settings when programming the chip as these will override the source code settings. HTH

Dave Purola,
N8NTA

You mean the Oscillator setting in EPIC? It is set to INTRC.

I have tried both INTRC and INTRC (Clockout) and both give the same results. It must be something else I am not declaring in the startup of the code???

Bruce
- 23rd January 2006, 16:11
Your code is fine. Under the Options menu in the EPIC software, make sure you have Update Configuration & Reread File Before Programming checked.

These options force the EPIC software to load & use config fuse settings embedded in your code, and always open/use the latest version of your .hex file.

sskeet
- 23rd January 2006, 16:21
Your code is fine. Under the Options menu in the EPIC software, make sure you have Update Configuration & Reread File Before Programming checked.

These options force the EPIC software to load & use config fuse settings embedded in your code, and always open/use the latest version of your .hex file.

I do not have the stuff in front of me right now, but I do have the software installed here at work, and I just checked the default settings in EPIC and Update Configuration is checked by default, but Reread File Before Programming is not. However, if I were to close EPIC and recompile, then reload EPIC, wouldnt that do the same thing? Because thats what I was doing every time anyway.

Bruce
- 23rd January 2006, 18:43
If your settings are the same at home, and it is loading & using config word settings in your .hex file, then i would have to suspect something in your circuit since your code posted as-is above works just fine.

sskeet
- 23rd January 2006, 19:12
If your settings are the same at home, and it is loading & using config word settings in your .hex file, then i would have to suspect something in your circuit since your code posted as-is above works just fine.

Thanks for the verification...
What is better to use, INTRC or INTRC (CLockout)? Does it make a diff?

My circuit is pretty simple, 5v to power, ground is good, and I have a 10k pullup attached to MCLR, although I believe I am disabling it in the header statement anyway??

What more should/could there be in the circuit?

Bruce
- 23rd January 2006, 19:26
With these settings @ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF you won't need much more than power. Assuming these config word settings are actually being programmed into the PIC as expected.

MCLR_OFF just disables the reset function on the /MCLR pin allowing it to be used for an input VS external reset.

You might also want to include the decoupling cap as shown in your PBP manual between Vcc and ground. Locate this cap as close to the PIC power pins as possible. Without it you can sometimes waste a ton of time chasing problems. Especially on "A" version PICs. These are more succeptible to noise than older non "A" revs.

As for clockout VS no clockout, that really depends on you. All this does is output the clock/4 on OSC2. If you want the OSC2 pin for I/O, then obviously you're better off with no clockout.

If you're curious about what these osc config options are, just look in your data sheet at the Special Features of the CPU section under CONFIGURATION WORD.

sskeet
- 23rd January 2006, 19:44
Thanks Bruce, great info..I should be able to troubleshoot a little better now...I will report back with what the problem was as soon as I figure it out later...

sskeet
- 23rd January 2006, 23:58
Damn, can I delete this thread? lol

My 5V regulator on the board was toast...I replaced it and voila

I really appreciate the responses though!

mister_e
- 24th January 2006, 00:00
**** happens :)

ntege
- 12th November 2007, 09:13
hi guys can any one help me with assembly code for dimming an led using the pic16f88.i have read the datasheet and and i have come up with code but it doesnt work.

can anyone please tell me whats wrong with with this code.

list p=16f88
INCLUDE "p16f88.inc"


_;****Set up the Constants****

STATUS equ 03h
TRISA equ 85h
TRISB equ 86h
PORTA equ 05h
PORTB equ 06h
COUNT2 equ 21h
COUNT1 equ 20h
ANSEL equ 9Bh
OSCCON equ 8Fh
CCP1CON equ 17h
T2CON equ 12h
TMR2 equ 11h
CCPR1L equ 15h
PR2 equ 92h
PIR1 equ 0Ch
PIE1 equ 8Ch


movlw B'00000000' ; 8Mhz 4Mhz = B'01100000'31.25khz
bsf STATUS, 5
movwf OSCCON
nop
nop
nop
bcf STATUS, 5
movlw b'00111100'
movwf CCP1CON

bsf 03h,5
movlw 00h
movwf TRISA

movlw 00h
movwf TRISB

movlw 00h
movwf ANSEL

movlw b'11111111'
movwf PR2

bcf 03h,5
movlw b'00001111'
movwf TMR2



Start
movlw b'00001111'
movwf CCPR1L
Loop1
decfsz CCPR1L
goto Loop1
goto Start
end