PIC16F627A - LED does not lit

Thread Starter

tekinzen

Joined Nov 22, 2009
30
Is that different from MCLR? Also, what is the purpose of turning it on/off?

As for the oscilator, what config directive should I use to tell the compiler to use the internal oscilator?

Many thanks!!!
 

Thread Starter

tekinzen

Joined Nov 22, 2009
30
After more reading I have realized that I was setting the wrong bit high, for pin 18 it is bit 1 not 2 because it corresponds to RA1 (bit 2 is RA2 -> pin 1).

Anyhow, the LED still does not turn on. Have also used this directive in my program to turn comparators off and enable to internal oscilator:

Rich (BB code):
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT & _LVP_OFF
I'm am giving this up until I get my stripboard and solder everything. I'm having a hard time keeping the voltage regulator on the breadboard. (I HATE breadboards!)

Then I'll try getting another PIC chip and get a $100+ programmer. Maybe the $25 programmer I have is just not writing the chip properly.

... but I'm not giving this up entirely. I'll try until I get the damn LED to flash even If it's going to take me reading ten different books on how to make it work.

Cheers my friends!
 

thatoneguy

Joined Feb 19, 2009
6,359
Your headache may be the programmer if you have copy and pasted the code the duck posted above for the skeleton of a program.

I'd HIGHLY suggest a PicKit2. You can program an IC while it is still on the breadboard with it, and do some minor runtime debugging, just run a few extra wires to a 4 pin header on the breadboard.

It shouldn't be this frustrating, I mostly see it when people are using DIY programmers of various sorts. With ICSP being standard on all PICs now, there's no reason not to use the PicKit2.
 

thatoneguy

Joined Feb 19, 2009
6,359
I've attached a ZIP file that I KNOW works on a 16F627 and 16F627A, it is from what the snippet above was for.

If you load it, and have a 0.1uF cap across the power on the uC, you there should be pins that have blinking LEDs and solid LEDs.

Load it and let me know, it's a .hex file ready for programming. Works with a TOP 2049 programmer as well as an PicKit2 and PicKit3.

Simplebot16F627.zip
 

Thread Starter

tekinzen

Joined Nov 22, 2009
30
I'll check that when I get my bypass capacitor (it's on its way).
I'm unable to download the attached zip file, maybe the forum is blocking it.
 

t06afre

Joined May 11, 2009
5,934
Is that different from MCLR? Also, what is the purpose of turning it on/off?

As for the oscilator, what config directive should I use to tell the compiler to use the internal oscilator?

Many thanks!!!
On your chip you can disable the MCLR pin. It will then become a pin that may be used for input. What kind of programmer do you have? After you have programmed your chip. You should always do a verify to check if your programming is correct. I think many programming tools do this as a part of the programming cycle.
I also think some of problems is that you assume to much. Instead of being sure. Like with the oscillator. Then you assume, it will always be wrong. Attention to details is important. Then in doubt check with the datasheet.
 

Thread Starter

tekinzen

Joined Nov 22, 2009
30
So, my 0.1uF capacitor has arrived and I have added it to the circuit but my LED still does not turn on. I also gave it a try with a 8-pin PIC (PIC12F629) with the following code:

Rich (BB code):
#include "p12f629.inc"

bsf                   03h,5
movlw               00h
movwf               85h
bcf                   03h,5
                    
movlw               02h
movwf               05h
movlw               00h
movwf               05h
                      
end
In this code I set all pins as outputs (movlw 00h) and turn pin5 high (movlw 02h). The LED connected to pin5 does not lit.
The only pin that I can get the LED to light up with is pin 1 (Vdd of my PIC).

Without attempting to assume anything else could please someone tell me if my code is correct? Based on that I will purchase a PicKit programmer. Maybe my DIY programmer is screwing things up although programming verifies ok...or at least it says it does.

I cannot imagine why this is so hard to make it work. I have literally copied and pasted dozen codes from several articles beside my code to give it a try but none of them would work. How did you guys learn to make an LED flash? If my code is incorrect then maybe the book I'm learning from is crap? ("PIC Projects - A Practical Approach by Hassan Parchizadeh")

I have used "known" codes for the pic16f627a and pic12f629 chips but none of them have worked. I'm really pissed :mad:
 

thatoneguy

Joined Feb 19, 2009
6,359
I'll try attaching the simplebot file again here. It won't work on the 12F device, just the 16F627, but it is ready to go and a few ports should be high when it is running. It is set for internal oscillator, so you only need to program it and add power to the right pins.

If it doesn't work, try a PICKit2 and you should have no more headaches.
 

Attachments

thatoneguy

Joined Feb 19, 2009
6,359
Thanks a lot, this flashes the LED on some pins, on others the LED is steady.
What would you suggest?
Try SourceBoost using C to write your programs instead of assembly. That is what was used to whack together the program you just ran.

It is a LOT easier and just as speedy for most all PIC programs. Same goes for most high level languages, this one just happens to be very affordable and capable.
 

Markd77

Joined Sep 7, 2009
2,806
Looks like the programmer is working. I'd suggest using the template I posted above, with your code added. Change the config to required, then if it doesen't work repost the new code here.
MPLAB also contains a simulator, which you enable by going to the debugger menu, select tool, MPLAB SIM.
It is very useful in finding problems as you can step through the code and see everything that is happening, rather than programming the device and either seeing it work or do nothing.
 
Top