Electronic – Programming and using a flash memory PIC

flashpic

I'm learning how to program a PIC12F609 and I have what (I think) is a silly n00b question. As a test I'm trying to burn a program that simply turns all 5 IO pins to output and turns them all on, so that if I connect an LED in series with a resistor to any pin it will light up. My program is dead simple and builds fine and MPLAB says the PicKit3 has successfully programmed the device. But when I try to use the programmed chip it doesn't work.

My fear is that the program is expiring from the memory as soon as I disconnect the PicKit. My plan was to program the PIC, pull it out, drop it into the LED circuit and connect the power source (9V battery run through 5V regulator). In all my previous microcontroller experience, the program disappeared from RAM as soon as power stopped and only programs stored in EEPROM, which this tiny 8 pin Pic doesnt have, would boot when power was reconnected.

If this is the case, how do I get a program to "stick" on my chip? and if not, what else about my process seems wrong?

edit: I'm posting my code in hopes this will be helpful. I really appreciate the thoughtful answers that have already been given, hopefully this way someone can help me set my configuration switches.

#include <12F609.h>
#include <stdlib.h>

void main (){
    // All five IO pins are on port A. 
    SET_TRIS_a(11111);
    OUTPUT_a(11111);
    while(1){
        // endless loop, my attempt to make sure it didn't stop running
        // I've also tried putting the OUTPUT and TRIS in here but no luck
    }
}

my configuration bits are

FOSC – Oscillator Selection bits – RC oscillator
WDTE – Watchdog Timer Enable bit – WDT disabled
PWRTE – Power-up Timer Enable bit – PWRT enabled
MCLRE – MCLR Pin Function Select bit – MCLR pin function is MCLR
CP – Code Protection bit – CP is disabled
IOSCFS – Internal Oscillator Frequency Select – 8 MHz
BOREN – Brown-out Reset Selection bits – BOR enabled.

I think I understand what most all of those do, but I really don't know enough to select the right ones.

Best Answer

Your plan is fine as it stands - when you program the PIC it programs the flash memory. This program should be able to be retained for many tens, even hundreds of years.

The problem that most people (myself included) have with getting started with PICs is with the configuration fuses. These are settings which define how the PIC runs, including what oscillator to use to drive it.

It is most likely that you haven't set these fuses properly (they can be a real pain), so your program just isn't running.

If you could post your full program into your question we can help you diagnose it better.