Connect with us

Troubles with PIC 16F88

Discussion in 'Electronic Design' started by Brian KP, Dec 2, 2005.

Scroll to continue with content
  1. Brian KP

    Brian KP Guest

    I have been trying to program an 18pin 16F88 for a project, my first
    attempt at using PIC chips. So far I haven't been able to get an LED to
    blink. I have this PIC-PG2C programmer: and am using the ICProg program
    the manufacturer said is compatible. I am currently using CCS C
    compiler that I received from a friend who has worked with PICs
    before, but haven't figured how to use CCS from within MPLAB and
    currently just double click the executable in its directory and it asks
    for the location of the source code and spits out a hex file. I have
    the 16F88.h file in the same directory, and CCS C reports no errors.

    I am just powering the PIC with +5V and Ground, someone also told me I
    might need to feed pin 4 high, or low, to keep the device from
    continuously resetting. Is that correct?
    I don't have an external RC attached and wish to use the internal
    clock, I set the ICProg configuration to "IntRC". The programmer
    programs and then verifies the programming, yet when I put the chip
    into a circuit with +5 on pin 14, ground on pin 5, and an LED between
    pin 17 and ground; the LED has a barely detectable blink to it, but
    when I connect pin 4 to +5 the LED remains on solid, and when I connect
    pin 4 to ground the LED turns off completely. Here is a link to the
    16F88 data sheet:

    I assume CCS C is a good compiler, but is there another one anyone
    would suggest?

    Here is my source code:
    #include <16F88.h>
    #use delay(clock=4000000)
    // Wait for one second
    void wait() {
    int count = 0;
    while(count < 100000) {
    count = count + 1;
    // Blink the PIN
    void blink() {
    void main() {
    while(TRUE) {

    I have also read about PIC simulators, has anyone used one and can
    recommend it? My project involves gathering data from two to three
    voltage imputs (carbon di/monoxide detectors) and converting those
    voltages to ppm and outputing the values to an LCD display. Then
    calculating and storing or displaying the average over certain time
    spans. One step at a time though.
  2. See below.

    This stuff is real important. You need to set the fuses correctly for
    your circuit. In the program, you've presumably asked for the 'HS'
    oscillator option, which requires an external crystal and capacitor or
    resonator etc. You probably want to enable the INTRC oscillator with
    no output on RA6.

    What you have to do with RA5 also depends on the CONFIG1 settings, but
    tying it to Vdd is safe in any case (it's input only even if the /MCLR
    function is disabled).

    Maybe you're overriding the configuration fuse settings with your
    programmer, I don't know, this is a 3rd party programmer.

    BTW, you should have a resistor in series with the LED, probably you
    just didn't mention it.
    You probably need to set up the TRIS register for port A *and* to
    disable analog inputs before you can get any output unless CCS does
    something really strange by default(since you're seeing output from
    the pin, maybe it does!). Also, check to make sure CCS has 16 bit
    integers.. there is one of the compilers that defaults to 8 bits,
    believe it or not. 8-(

    You should be able to use the simulator in MPLAB. It will show you all
    the SFR values (including port pins) and so on-- and you can set
    breakpoints and measure time intervals. You need to understand most of
    the low-level stuff even if you are using C (or CCS 'C').

    Best regards,
    Spehro Pefhany
  3. Guest

    You appear to have set the oscillator to external xtal and not internal
    RC, you appear to have not set port A to output mode. I'm not familiar
    with this compiler but you might want to consider useing assembler for
    a little chip like this or you may run out of program space as your
    project gets going.
  4. Hmm... according to your source the oscillator is set to HS instead of
    INTOSC. I see no trace of configuring pin 17 for output. When using a common
    red LED I'd advise to use a series resistor of let's say 330 Ohm. Can't you
    tell the compiler to output assembler code so you can see what it has done?
    (And show us as well.) Once you have the code in assembler you can also use
    the MPLABs simulator to see your program execute.

    petrus bitbyter
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day