Flash 1 Programming on the MC68HC908GZ60

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flash 1 Programming on the MC68HC908GZ60

1,361 Views
CyrilG_
Contributor I
hello,

I am trying to develop some in-Can programmability for the the uC MC68HC908GZ60. Basically I am loading an external RAM with bytes that represent  the updated version of the binary code that is supposed to be programmed in Flash 1.
Some functions in Flash 2 read the RAM, do an mass erase of Flash 1 and program Flash 1. The problem I am having is to write the interrupt and reset vectors. They start at address $FFCC and according to the datasheet, I am supposed to write the entire row, starting a $FFC0. However, the bytes from the address $FFC0 to $FFCC are reserved according to the datasheet and thus i am not supposed to programmed them.
Is it a problem with the datasheet or am I missing something?
Regards
Cyril
Labels (1)
0 Kudos
Reply
4 Replies

676 Views
bigmac
Specialist III
Hello Cyril, and welcome to the forum.
 
It is not necessary to program every flash location within a row - just program the locations that are required by your code, and leave the others unprogrammed.  Alternatively, if it simplifies the operation of the programming code within flash2, you could program the value 0xFF into the unused locations, which is equivalent to leaving them unprogrammed.
 
I think the point that the datasheet is making is that the row size represents the maximum number of locations that may be programmed in a single burst.
 
Regards,
Mac
 
0 Kudos
Reply

676 Views
SaaacAstarc
Contributor I

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.

0 Kudos
Reply

676 Views
SaaacAstarc
Contributor I

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.

0 Kudos
Reply

676 Views
Saaac
Contributor I

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.

0 Kudos
Reply