1. tpavai

    Thread Starter New Member

    Sep 13, 2011
    i would like to have some tips for programming pic microcontroller....i am just a beginner , just started reading basics...

    plz someone do help me.....
  2. CraigHB


    Aug 12, 2011
    Flashing an LED is usually the best place to start.

    Take any PIC and put it on a breadboard. Wire in the power supply, an LED-resistor on one of the port pins, and an ICSP interface. Then write a few lines of code to flash the light, program the PIC, and see if it flashes. Troubleshoot as required.

    I even still do something like that when starting a new project as a quick test to make sure my ICSP and code templates are set up right.

    You need to do some initiallization in your code. Set up all your ports and initialize or clear your data registers. Most PICs default to analog on all analog/digital ports and default to input on all digital I/O ports. You'll need to set those config registers in code as required.

    There's also config registers in flash memory set in code sometimes referred to as fuses. You'll need to set those up with special lines in your code.

    You'll need to avoid floating inputs. You can either pull them down to Vcc or Vss with a resistor or more easily, set unused I/O pins to to outputs in code.

    In general, you should review all of the configuration defaults in the data sheet and make sure they are acceptable for your application. Change them in your initialization code as required.

    Bypass all Vcc and Vss pin pairs with a .1uF capactor as close to the pins as possible. You can avoid some strange issues due to noisy power that way. As a general rule, all digital chips should have bypass capacitors right on the power pins.

    Attached is some example code for a device that provides a couple pulsed outputs using MPASM for a PIC16.

    Well, hope that helps and good luck with PIC programming.
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    We should have a sticky for this, it gets asked every week or so. ;)

    Have a look here. These are entry level development boards that include a programmer that also works as an in-circuit debugger.

    The Debug Express uses a more advanced (harder to use) PIC, but is geared for using C to write code. The Starter Kit is a simpler PIC and is geared for assembler. They both cost about $50USD.

    The PicKit that comes with them is an excellent mature tool, I have several of them (they can occasionally break when testing breadboards). You also get a tested PCB with a PIC, several LEDs, a button, a potentiometer, and some bread boarding room too.

    Both include a nice set of tutorials. You can test out the sample programs and try out your own changes.

    Going this way means you have tested good hardware to start out with, as you don't want to try to figure out if your code or your hardware is not working when you're just starting out.

    Good luck, and let us know what happens!
  4. t06afre

    AAC Fanatic!

    May 11, 2009
  5. upand_at_them

    Active Member

    May 15, 2010