All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Using a flash memory PIC12F609
PostPosted: November 25th, 2017, 3:35 
Offline

Joined: November 25th, 2017, 3:22
Posts: 1
Location: guangdong,shenzhen
I'm learning how to program a PIC12F609(datasheet:http://www.kynix.com/uploadfiles/pdf8798/PIC12F609-E2fMD.pdf) 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.
Image
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.


Top
 Profile  
 
 Post subject: Re: Using a flash memory PIC12F609
PostPosted: November 25th, 2017, 13:44 
Offline
User avatar

Joined: August 15th, 2006, 3:01
Posts: 2532
Location: CDRLabs @ Chandigarh [ India ]
Hi Buddy ,
Well This Forum is For Flash Memory " Data Recovery " Flash Memory In The Sense Like Pen Drives , SD Cards , Cf Cards , SSD's And Mobile Emmc Etc Not Microcontrollers You Are At a Wrong Forum :D

_________________
Regards
Amarbir S Dhillon , Chandigarh Data Recovery Labs
Logical,Semi Physical And Physical Data Recovery
Website-> http://www.chandigarhdatarecovery.com


Top
 Profile  
 
 Post subject: Re: Using a flash memory PIC12F609
PostPosted: November 25th, 2017, 15:25 
Offline
User avatar

Joined: September 8th, 2009, 18:21
Posts: 10855
Location: Australia
The PIC12(F)609 has 1024 words of (F)lash memory (see page 4 of the datasheet).

A "1" in the TRISIO register configures the corresponding GPIO pin as an input whereas a "0" configures it as an output (see page 43). The exception is GP3 (pin4, MCLR) which is always an input.

So in your case you would set the TRISIO/TRISA register to 001000. The OUTPUT (GPIO/PORTA) register should be set to 111111 if the PIC is sourcing current, and 001000 if it is sinking current. The maximum current into or out of any GPIO pin is 90mA.

BTW, Microchip has its own forum.

_________________
A backup a day keeps DR away.


Top
 Profile  
 
 Post subject: Re: Using a flash memory PIC12F609
PostPosted: November 26th, 2017, 3:36 
Offline
User avatar

Joined: December 4th, 2012, 1:35
Posts: 3161
Location: Adelaide, Australia
Amarbir, technically you are right, but seeing as there is so very little posted to do with lash, I don't think anyone is going to begrudge these questions. And if anyone is going to want to research Flash and possibly build power/controller/miscellaneous circuits it would help to understand this stuff.

To get it to stick, you would use something like a PIC12C508. I played around with these many years ago, for the obvious purpose these were popular. Not sure about the particular properties of yours. possibly just need to keep it powered

As fzabkar is saying in detail, I think there is more setup of the chip to get right before making it do its work.

look around on the net for sourcecode of your chip that involve LEDS and you will probably get the Aha moment reading through it.


Top
 Profile  
 
 Post subject: Re: Using a flash memory PIC12F609
PostPosted: November 26th, 2017, 14:36 
Offline
User avatar

Joined: September 8th, 2009, 18:21
Posts: 10855
Location: Australia
@HaQue, as I've already pointed out, the OP's PIC has 1K words of flash memory, so the code should "stick" for 40 years. Your PIC12(C)508 uses EEPROM memory, also with 40 year retention.

PICs are simple microcontrollers whose primary function is I/O. If you have "played" with such a device, you would know that one of the very first things you should do after applying power is to define the direction of its GPIO (General Purpose Input Output) pins. That's the function of the TRISIO register. As I've already explained, the problem with the OP's code is not that it doesn't "stick", but that it is defining the GPIO pins as inputs when they should be outputs. That makes it no more useful than a write-only memory.

_________________
A backup a day keeps DR away.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: Google Adsense [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group