Problem att programmera PIC12F675 med mplab icd3 *LÖST*

PIC, AVR, Arduino, Raspberry Pi, Basic Stamp, PLC mm.
Användarvisningsbild
slatte
Inlägg: 420
Blev medlem: 1 april 2008, 16:05:17
Ort: Jönköping

Problem att programmera PIC12F675 med mplab icd3 *LÖST*

Inlägg av slatte »

Som rubriken säger lyckas jag inte att programmera min pic12f675.
Har följande system.
Programmerare: MPLAB ICD3
compilator: HI-tech C (v9.7)
MPLAB v8.6

Jag har kopplat in PICen så att #1 => +5V, #8 => GND, #7 => PGD, #6 => PGC, #4 => MCLR/VPP
Har även ett pullup på 10K på pinne 4 "MCLR".

Det lustiga i det hela är att jag "tror" att jag lyckades programmera första gången jag försökte.
Men i vilket fall så fungerar det inte nu ialf utan när jag ska programmera genom mplab så får jag detta felmeddelande.

Kod: Markera allt

Programming...
The following memory regions failed to program correctly:
Program Memory
Address: 00000000 Expected Value: 0000280f Received Value: 00000000
Programming failed
Har även googlat en hel del. Men tyvärr inte hittat någon lösning på problemet. Har aldrig förskt programmera en pic i 12-serien förut för den delen helle, kanske är något som jag har missat helt? :/
Programmet som jag hade tänkt programmera gör inget mer än sätter port GPIo2 till "1".

Kod: Markera allt

#include <htc.h>
__CONFIG(INTIO & WDTDIS & PWRTDIS & MCLRDIS & BORDIS);

void init()
{
   TRISIO = 0;    
}

void interrupt my_isr(void)
{
   
}      
void main()
{
   init();
   GPIO2 = 1;    
}   
Senast redigerad av slatte 16 december 2010, 19:28:07, redigerad totalt 1 gång.
Användarvisningsbild
Micke_s
EF Sponsor
Inlägg: 6741
Blev medlem: 15 december 2005, 21:31:34
Ort: Malmö

Re: Problem att programmera PIC12F675 med mplab icd3

Inlägg av Micke_s »

Rent spontant så tror jag inte du har kontakt. 00000000 tyder nog på det.
MCLRDIS = du har avaktiverat reset, tror du behöver vpp before vcc..
Användarvisningsbild
sodjan
EF Sponsor
Inlägg: 43205
Blev medlem: 10 maj 2005, 16:29:20
Ort: Söderköping
Kontakt:

Re: Problem att programmera PIC12F675 med mplab icd3

Inlägg av sodjan »

Tror som Micke_s, det är "MCLRDIS" som är orsaken.
Googla på "microchip icd3 "internal mclr"" och se t.ex:

http://www.microchip.com/forums/m475293-print.aspx
http://old.nabble.com/ICSP-and-Vcc-td29334843.html
http://dics.voicecontrol.ro/process_mai ... board.html
Användarvisningsbild
slatte
Inlägg: 420
Blev medlem: 1 april 2008, 16:05:17
Ort: Jönköping

Re: Problem att programmera PIC12F675 med mplab icd3

Inlägg av slatte »

Nu har jag äntligen fått tummen ur och börjat kolla på problemet.
Problemet låg i precis det ni pekade på MCLRDIS och INTIO "internal osc".

Genom att Istället ha MCLREN "Enable" så fungerar en ny PIC12F675 att programmeras flera gånger om.
:)

Denna förklringen hittade jag på Microchips forum
Probably it is because the stand alone app is using the correct Vpp before Vdd program entry mode that is required when MCLR = I/O and INTOSC is configured.

What can and does happen when you have these two config settings is that with a Vdd first program entry mode the PIC is not firmly held in RESET and with the internal oscillator runnning it can, and as often as not, actually start the PIC executing code. As a result the PICs PROGRAM COUNTER is INCREMENTED. Then the Vpp rises enough to put the PIC in program mode HOWEVER THE PICs PROGRAM COUNTER IS NOT POINTING TO 0x000 any more and program mode entry does not reset it either. As a result of this your code is programmed into the PIC offset from where it should be. Any combination of Code, OSCAL, ID config and data EEPROM where applicable, can be shifted. This is why the OSCAL goes missing. It is actually written to somewhere it should not be, usually to a non existent address.

There are a number of counter measures to prevent this from happening. One is the VPP first program entry mode. This is covered in the programming specs and it is the most convenient and useful solution as it allows you to have MCLR = I/O and INTOSC enabled without problems. My guess is that the stand alone App is correctly using this mode while the MPLAB IDE is not.

Other counter measures are to avoid the MCLR = I/O and INTOSC = enabled condition as Dariog pointed out but this is not always very convenient.

In some of the later base and mid range PIC families there is another solution. A RESET PROGRAM COUNTER command has been added to the programming commands.

There is some information about this problem in the programming specs that covers this.

So, to me it really looks like the programming script in MPLAB is not correct while in the stand alone app it is.
Danke danke sodjan och Micke_s
Skriv svar