I do it by reading the specific PIC's data sheet. It will tell you what is configurable, and what the default configuration on power-up is. You only need to set those configuration bits which are opposite of the default settings...
Perhaps I should go to the Microchip forum for this question but I like electrotech so here it goes...
I'm learning how to program the PIC12F675 in C using The High Tech C Compiler. Scrounging the internet I was able to find the configuration script at the top of the C program which is entered before main(). My question is how do I know what that is for a specific microcontroller? Does it all depend on the given compiler? If it depends on the compiler how do most micro programmers figure that out? I will add I'm slightly a noob to micro programming. Basically how does everyone figure out what the need to put in the configuration script to make the PIC do what you want.
Thanks
-mike
I do it by reading the specific PIC's data sheet. It will tell you what is configurable, and what the default configuration on power-up is. You only need to set those configuration bits which are opposite of the default settings...
Mike ML.
Thanks Mike
I found the configuration bits info in the datasheet which was helpful. They don't match up exactly but you can figure out what they are with a little intuition.
I'm able to program the PIC12F675 once but then after that I can't program it again. It being a flash device I"m a little confused. Here is my code. I have a feeling my configuration bits are incorrect locking it or something. I have gone through a handfull of chips and now it's time to figure out what's wrong. I have the 10k pullup on mclr and a bypass cap so I don't think it's my hardware. Below is code to toggle the ports.
#include <htc.h>
__CONFIG(INTIO & WDTEN & MCLRDIS & BORDIS & UNPROTECT & PWRTEN);
void main()
{
STATUS = 0b00000000; // Initializing Bank 0
CMCON = 0x07; // Digital I/O
STATUS = 0b00100000; // Initializing Bank 1
WPU = 0b00110111;
ANSEL = 0; // Digital I/O
TRISIO = 0x00;
STATUS = 0x00;
GPIO = 0x3F;//(1<<4);
_delay(50);
GPIO = 0x00;//(1<<4);
_delay(50);
while(1);
}
Last edited by wuchy143; 18th August 2010 at 07:16 PM.
The trouble you are having is because you used the internal oscillator with master clear disabled; the programmer can not put the chip into programming mode. I know with the limited number of pins on this chip that is tempting, but you may want to keep your master clear until your program is working the way you want, then go ahead and use it as a gpio.
Edit: You may be able to do an erase, then program it.
Last edited by BeeBop; 19th August 2010 at 02:42 AM. Reason: added line
If you are using a pickit2, you can erase them by doing the following,
Place a good chip in the socket.
Do a blank check to make the pickit see the chip.
Swap to a bad chip.
Erase bad chip.
This works because the pickit2 thinks a good chip is present.
Edit, there is a way to do it with a JDM but it requires a hardware mod.
Mike.
Last edited by Pommie; 19th August 2010 at 04:54 AM.
| Tags |
| Similar Threads | ||||
| Thread | Starter | Forum | Replies | Last Post |
| Hi-Tech C Compiler: What am I doing wrong? | micro571 | Microcontrollers | 72 | 9th March 2012, 06:54 PM |
| Interrupt Issues, PIC12HV615 HI-TECH Compiler | brutc001 | Microcontrollers | 2 | 13th January 2010, 08:55 PM |
| Hi Tech compiler | Chippie | Microcontrollers | 0 | 29th June 2009, 06:31 PM |
| HD44780 lcd and pic18f4550 and hi tech compiler | wojtekww123 | Microcontrollers | 1 | 15th October 2008, 06:57 PM |
| Serial port with hi tech picc compiler | fernandomierhicks | Microcontrollers | 3 | 24th February 2008, 05:56 AM |