We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am trying to write a program for an electrical device which needs calibration. The program must calibrate the device and store calibration values. This process is performed in RAM, but I need MCU to retain these information even when the power goes out. Is it the case in IAP? I mean if I copy calibration values from RAM to Flash memory using IAP, will I fulfill my requirement of not loosing them when the micro-controller is turned off?
Thanks in advance for your help
Thanks guys for answering, Now I know this is the right choice, however I have some coding problems now. I run into a hard fault when try to simulate the following code in keil-uv4.7 simulator. IAP does not run.
#include <LPC17xx.h> #include "ClockConfig.h" #define true 1 #define false 0 #define IAP_LOCATION 0x1FFF1FF1 unsigned int command[5]; unsigned int output[5]; typedef void (*IAP)(unsigned int [],unsigned int[]); #define iap_entry ((IAP) IAP_LOCATION) unsigned char x = 40; void IAP_WriteAndRead(unsigned char *variable); void Disconnect_PLL(void); int main() { SetCPUClock(); IAP_WriteAndRead(&x); while(true); } void Disconnect_PLL() { LPC_SC->PLL0CON = 0x01; LPC_SC->PLL0FEED = 0xAA; LPC_SC->PLL0FEED = 0x55; LPC_SC->PLL0CON = 0; LPC_SC->PLL0FEED = 0xAA; LPC_SC->PLL0FEED = 0x55; } void IAP_WriteAndRead(unsigned char *variable) { Disconnect_PLL(); command[0] = 50; command[1] = 0; // strat sector 0 command[2] = 0; // only sextor 0 is being written iap_entry(command, output); if (output[0]!=0) SetCPUClock(); else { command[0] = 51; command[1] = 0x100; command[2] = (unsigned int)x; command[3] = 512; command[4] = 12000; iap_entry(command, output); } SetCPUClock(); }
Keils simulator simulates a lot of hardware.
But that doesn't mean it simulates flash memory - and that it contains a copy of NXP:s proprietary boot loader.