Hello,
My question is related to this issue open. I try to record and delete information in the FLASH-2 of MC68HC908GZ60 the same way he did in the FLASH-1, with the same instructions but change the 1 to 2 logs. The problem I encounter is that whenever I try to record something in the FLASH-2 I get all the memory locations 0xAD value and I try to burn any other value. I put the code here as I record and erase in the FLASH-1 that works for me.
and how I record and erase in the FLASH-2 that does not work and whenever I try to record in one direction, I get 0xAD in all positions of that part of the FLASH-2.
FLASH-1 Code:
__________________________________________________________________________________
extern void GRABAR_FLASH(unsigned char bits);
extern void BORRAR_FLASH();
#define __DI() \
{ asm sei; } /* Disable interrupts */ \
#define __EI() \
{ asm cli; } /* Enable interrupts */ \
UINT8 *PunteroMemoria=(UINT8*)0;
extern UINT8 *PunteroMemoria;
void GRABAR_FLASH(unsigned char bits)
{
char VARIABLEINUTIL;
char DELAY = 1;
__DI();
//1
setReg8Bits(FL1CR,FL1CR_PGM_MASK);
//2
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
VARIABLEINUTIL=FL1BPR;
//3
PunteroMemoria = 0;
PunteroMemoria += 0xFFD0;
*PunteroMemoria = 25;
//4
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//5
setReg8Bits(FL1CR,FL1CR_HVEN_MASK);
//6
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//7
PunteroMemoria = 0;
PunteroMemoria += 0xFFD0;
*PunteroMemoria = bits;
//8
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//10
clrReg8Bits(FL1CR,FL1CR_PGM_MASK);
//11
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//12
clrReg8Bits(FL1CR,FL1CR_HVEN_MASK);
//13
for (VARIABLEINUTIL=0;VARIABLEINUTIL<200;++VARIABLEINUTIL){};
__EI();
}
void BORRAR_FLASH()
{
char VARIABLEINUTIL;
char DELAY = 1;
__DI();
//1
setReg8Bits(FL1CR,FL1CR_ERASE_MASK); //ERASE
clrReg8Bits(FL1CR,FL1CR_MASS_MASK); //MASS
//2
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
VARIABLEINUTIL=FL1BPR;
//3
PunteroMemoria = 0;
PunteroMemoria += 0xFFD0;
*PunteroMemoria = 25;
//4
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//5
setReg8Bits(FL1CR,FL1CR_HVEN_MASK);
//6
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//7
clrReg8Bits(FL1CR,FL1CR_ERASE_MASK);
//8
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//9
clrReg8Bits(FL1CR,FL1CR_HVEN_MASK);
//10
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
__EI();
}
______________________END FLASH1____________________________________________
FLASH-2 Code:
_____________________________________________________________________________
extern void GRABAR_FLASH(unsigned char bits);
extern void BORRAR_FLASH();
#define __DI() \
{ asm sei; } /* Disable interrupts */ \
#define __EI() \
{ asm cli; } /* Enable interrupts */ \
UINT8 *PunteroMemoria=(UINT8*)0;
extern UINT8 *PunteroMemoria;
void GRABAR_FLASH(unsigned char bits)
{
char VARIABLEINUTIL;
char DELAY = 1;
__DI();
//1
setReg8Bits(FL2CR,FL2CR_PGM_MASK);
//2
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
VARIABLEINUTIL=FL2BPR;
//3
PunteroMemoria = 0;
PunteroMemoria += 0x0462;
*PunteroMemoria = 25;
//4
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//5
setReg8Bits(FL2CR,FL2CR_HVEN_MASK);
//6
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//7
PunteroMemoria = 0;
PunteroMemoria += 0x0462;
*PunteroMemoria = bits;
//8
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//10
clrReg8Bits(FL2CR,FL2CR_PGM_MASK);
//11
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//12
clrReg8Bits(FL2CR,FL2CR_HVEN_MASK);
//13
for (VARIABLEINUTIL=0;VARIABLEINUTIL<200;++VARIABLEINUTIL){};
__EI();
}
void BORRAR_FLASH()
{
char VARIABLEINUTIL;
char DELAY = 1;
__DI();
//1
setReg8Bits(FL2CR,FL2CR_ERASE_MASK); //ERASE
clrReg8Bits(FL2CR,FL2CR_MASS_MASK); //MASS
//2
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
VARIABLEINUTIL=FL2BPR;
//3
PunteroMemoria = 0;
PunteroMemoria += 0x0462;
*PunteroMemoria = 25;
//4
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//5
setReg8Bits(FL2CR,FL2CR_HVEN_MASK);
//6
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//7
clrReg8Bits(FL2CR,FL2CR_ERASE_MASK);
//8
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
//9
clrReg8Bits(FL2CR,FL2CR_HVEN_MASK);
//10
for (VARIABLEINUTIL=0;VARIABLEINUTIL<DELAY;++VARIABLEINUTIL){};
__EI();
}
______________________END FLASH2____________________________________________
THANKS.
I keep looking at me the datasheet and the only thing I block is this note:
NOTE
The vector locations and the FLASH block protect registers are located in
the same page. FL1BPR and FL2BPR are not protected with special
hardware or software. Therefore, if this page is not protected by FL1BPR
and the vector locations are erased by either a page or a mass erase
operation, both FL1BPR and FL2BPR will also get erased.
Why the rest of the process is identical to the algorithm of the FLASH-1.
A greeting.
Hello,
In the end the solution is that when you record or erase the flash-2. code routines to perform this action program must be in the flash-1.
With this in mind there is no problem with the code that I have.
Thanks.