English
Language : 

AN1576 Datasheet, PDF (7/15 Pages) STMicroelectronics – The In-Application Programming
XFLASH DRIVER
1.3.3 Firmware template
#include "io72264.h"/* ST72264 memory and register mapping */
#include "Xflash.h" /* XFlash driver software
*/
void Loop(void);
/*************************Main loop ****************************************/
void main(void)
{
/************************ Initialization **********************************/
ST7_Init();
//General initialization
while(1) Loop();
}
/*****************UserWhileWriteBlock*************************************/
void UserWhileWriteBlock(void)
{
WDGCR=0x08;
//Refresh WATCHDOG Timer
}
/***************Programming routine within External ISR*********************/
@interrupt void On_DEMO(void)
{
unsigned char tmp;
unsigned char RamBuffer [64]@0xA6; /* New code and RASS keys buffer */
SPI_Init();
//initialize SPI communication
SPI_Rx(RamBuffer,2,100,(char)0);
//Receive RASS keys from EEPROM
RASS_Disable(RamBuffer[0],RamBuffer[1]); //Unlock Flash
for (tmp=0;tmp<2;tmp++)
{
SPI_Rx(RamBuffer,64,64*tmp,(char)0);
XFlashWriteBlock(RamBuffer,(unsigned int)&Loop+64*tmp,64);
}
SPI_Disable();
WDGCR=0xC0; //Resets the MCU which also relocks the XFLASH;
}
/************************Sector 1 software*********************************/
#pragma section (Loop)
void Loop(void)
{
}
7/15