Hi Andalon:
Clearly describe the details as below:
Normal:
- Define the value of “unsigned char Flash_Buf[256]”
- In the file of .ld , reserve the fixed memory(512bytes) of “m_orange_m (rx) : ORIGIN = 0x00000600, LENGTH = 0x200”
- After the power on, re-store the value of “Flash_Buf[512]” from the m_orange_m
4.Check byte67 of “Flash_Buf[512]”,this byte is CRC byte
5-1.If the CRC byte not correct, store the default value into Flash_Buf[512](default value include 200bytes)
5-2.If the CRC byte is correct, use the value of “Flash_Buf[512]” from the m_orange_m
- Programmer start use the byte1~byte67, and when HOST send an write command via CAN bus, let the value of “Flash_Buf[512]” write into the m_orange_m area.(now calculation the CRC of byte1~byte66 and store into byte 67)
TEST:
1.Power on è HOST send an write command via CAN bus(repeat) è Power off at any time.
2.Now can find out sometime before the write sequence ,the structure of “Flash_Buf[512]” after byte 67 will be modify to 0xff, but we not modify those bytes, but before 67bytes is always correct.
PS.
- Before execute the write command, need execute the EraseSector function, it maybe cause by the EraseSector function, but before byte 67 is always correct, so this is not root cause.
- This phenomenon is happen in test of power on – power off, if the power always on the phenomenon is not happen.