-
16F628 acting funny...?
I'm having some trouble programming a 16F628. I'm trying to get it to communicate with my computer via RS232 using the program shown below. I have LED (w/1k res) hooked up to portb.1 to indicate that it's operating. However, when I turn it on, it will sometimes operate for a few seconds and then stop. Then maybe turn back on, etc... ? I've tried it with a 20MHz ex. osc, and the internal osc. I'm powering it from 4 AA bats through a 5V regulator from Radioshack. I also tied portb.4 (low power programming pin) to ground via another 1k resistor, as I understand when portb.4 floats it can act erratically. Can anyone see what I might be doing wrong?
Thanks,
Dave
________________________________
INCLUDE "modedefs.bas"
PORTB=0
CMCON = 7
loop: Serout portb.0,T2400,["TACOS"]
pause 100
low portb.1
pause 100
high portb.1
Goto loop
________________________________
-
I think I figured out the problem... I had MCLR floating, and left the MCLR option in the configuration enabled.
I assumed that if MCLR was enabled and floating, the PIC probably wouldn't work, period. Is that usually what happens with MCLR is left floating and enabled? (i.e. sporadic operation?)
Thanks,
Dave
-
If you have not assigned the MCLR pin to internal, example...
@ DEVICE pic16F628, MCLR_OFF ' Master Clear Options (Internal)
...then it has to be tied to Vdd or reset circuitry of some sort. Failure to do so will result in unreliable operation at best, or complete failure at worst.
-
And..... You are going to have more problems shortly. 4 AA batteries = something less than 6 volts into the regulator, which means that the regulator is just barely working - unless you've got a LDO (low drop out) regulator. Either add another AA cell so the input to the regulator is ~7.5 volts, or replace the regulator with a diode - 1N4148, etc. - to drop the 6 volts from the 4 AA cells to about 5.3 volts.