Hi,
I seem to have a grounding or noise problem with my PIC pcb. When I program the PIC to flash an LED, it seems to only flash when I touch the pcb or a pin on the pic like the crystal or a cap on the 3V3 circuit.
Overview of my board:
12-24Vdc in.... 3V3 LDO.....
I currently use a wall socket adapter, and I have tried on a different location, thought maybe my mains was interfering.
ANy ideas? Does the pic need a pull-up resistor somewhere to stop noise.
I can draw up a quick circuit diagram if need be.
First, if your MCLR pin is enabled, does it have a pull up? It needs one. I've got 33K resistors on several boards here. I'm sure a range of values would work fine though.
Second, the rest of the pins are likely floating (not connected). All kinds of strange, random things can happen when they're in this state and configured as inputs. Either pull up or down all of em (pain in the butt), or just set your TRIS registers so all unused pins are outputs.
Please put code inside CODE tags. If you don't the formatting disappears and it's VERY difficult to read (not too bad on a short program like that, but when they get longer it's a mess)
When you're about to paste your code, just click on the # in the menu above the text entry window first. Then paste.
I am using the PIC18LF252. Do I need to to make all the ports output - I think this might be the problem.
Though I've done plenty of C programming in the past on PC's, I've never programmed a PIC with it. I only use assembly on PICs. That said, it looks fine to me. Someone who does C on PICs may spot something that I don't see.
Try setting all ports to all outs - all zeros. Any pin you're not using, anyway.
If you're someplace with cold weather and your house is dry and staticy, don't wear those staticy clothes (fleece, sweaters, etc.) when doing electronics. That can cause weirdness for sure. Cotton (jeans/tee shirt) works well to limit static a bit. A grounded wrist strap is a good idea, but they're a royal pain in the butt with the snagging on everything.
I shall try and get back to you. I also used to use assembly but trying C programming now. Just getting started.....my end goal is to develope an embedded webserver..... well we all got to start somewhere. Will keep it updated.
Thanks
ya sorry, just had a look at my mplab code and the return is in the right place....not sure why its hanging around there lol..... my bad .... Mike do you do alot of C programming with PIC's?
Well, you've got a hardware problem if it's responding to a finger touch.
- Check you don't have any floating inputs (or set them to outputs)
- Disable BOR (brown out reset), this will make you more noise tolerant
- Add your own pullup to mclr/reset (one less thing to go wrong)
- Check your voltage levels and noise on your power line.
- Implicity disable interupts as your first line of code (GIE=0)
LDO regulators require careful selection of the output capacitor. Is this requirement met in your circuit? Have you tried powering it from batteries?
Have you connected all power pins of the uC to Vdd/GND?
Show your configuration settings (oscillator type, etc... as suggested, BOR should be disabled; MCLR must be pulled up to Vdd with an external resistor if MCLR is enabled).
ya sorry, just had a look at my mplab code and the return is in the right place....not sure why its hanging around there lol..... my bad .... Mike do you do alot of C programming with PIC's?