Atmel SAM4S-XPLD Atmel ATSAM4S-XPLD ATSAM4S-XPLD Hoja De Datos

Los códigos de productos
ATSAM4S-XPLD
Descargar
Página de 1125
 376
SAM4S [DATASHEET]
11100E–ATARM–24-Jul-13
24.5.4 In Application Programming (IAP) Feature
The IAP feature is a function located in ROM that can be called by any software application.
When called, this function sends the desired FLASH command to the EEFC and waits for the Flash to be ready (looping
while the FRDY bit is not set in the MC_FSR register).
Since this function is executed from ROM, this allows Flash programming (such as sector write) to be done by code
running in Flash.
The IAP function entry point is retrieved by reading the NMI vector in ROM (0x00800008).
This function takes one argument in parameter: the command to be sent to the EEFC.
This function returns the value of the MC_FSR register.
IAP software code example:
(unsigned int) (*IAP_Function)(unsigned long);
void main (void){
unsigned long FlashSectorNum = 200; // 
unsigned long flash_cmd = 0;
unsigned long flash_status = 0;
unsigned long EFCIndex = 0; // 0:EEFC0, 1: EEFC1
/* Initialize the function pointer (retrieve function address from NMI vector) 
*/
IAP_Function = ((unsigned long) (*)(unsigned long)) 
0x00800008;
/* Send your data to the sector here */
/* build the command to send to EEFC */
flash_cmd =  (0x5A << 24) | (FlashSectorNum << 8) | 
AT91C_MC_FCMD_EWP;
/* Call the IAP function with appropriate command */
             
flash_status = IAP_Function (EFCIndex, flash_cmd);
}