PIC Microcontroller

PIC16F1937에서 Eeprom 문제점(microchips 내부 eeprom read 문제점)

EP 기술연구소 2019. 3. 22. 19:03

< microchips 내부 eeprom read 문제점 >

초기에 data를 Load 하면 (DataRload_IntE2p() 하면 data가 틀리게 들어간다.

그러나 일정 시간이 지나고 난후에 다시 Reload 하면 data 가 정산동작한다..  따라서  data write는 정산적으로 동작하지만 Read 에 문제가 있다.  도대체 왜 그럴까..?


//==============================================================================

unsigned char DataRload_IntE2p()

{

unsigned char i;

SensorType[0] = read_EEPROM(eeprom_start_addr + 0);

SetTemp[0] = read_EEPROM(eeprom_start_addr + 1);

SensorType[1] = read_EEPROM(eeprom_start_addr + 2);

SetTemp[1] = read_EEPROM(eeprom_start_addr + 3);

SensorType[2] = read_EEPROM(eeprom_start_addr + 4);

SetTemp[2] = read_EEPROM(eeprom_start_addr + 5);

SensorType[3] = read_EEPROM(eeprom_start_addr + 6);

SetTemp[3] = read_EEPROM(eeprom_start_addr + 7);

SensorType[4] = read_EEPROM(eeprom_start_addr + 8);

SetTemp[4] = read_EEPROM(eeprom_start_addr + 9);

TempCorrect[0] = read_EEPROM(eeprom_start_addr + 10);

TempCorrect[1] = read_EEPROM(eeprom_start_addr + 11);

TempCorrect[2] = read_EEPROM(eeprom_start_addr + 12);

TempCorrect[3] = read_EEPROM(eeprom_start_addr + 13);

TempCorrect[4] = read_EEPROM(eeprom_start_addr + 14);

Used_HeatingFlags = read_EEPROM(eeprom_start_addr + 15);

i = read_EEPROM(eeprom_start_addr + 16); // addr + 33

if(AllDataSum() & i) return 0; // false

else return 1; // True

}


// Data save to Internal EEPROM

void DataSave_IntE2p()

{

unsigned char i = 0;

//unsigned long addr = eeprom_start_addr;

E2p_SaveFlag = 0;

write_eeprom(eeprom_start_addr + 0,SensorType[channel_1]); // Channel_1 on/off control

write_eeprom(eeprom_start_addr + 1, SetTemp[channel_1]);

write_eeprom(eeprom_start_addr + 2,SensorType[channel_2]); // Channel_2 on/off control

write_eeprom(eeprom_start_addr + 3, SetTemp[channel_2]);

write_eeprom(eeprom_start_addr + 4,SensorType[channel_3]); // Channel_3 on/off control

write_eeprom(eeprom_start_addr + 5, SetTemp[channel_3]);

write_eeprom(eeprom_start_addr + 6,SensorType[channel_4]); // Channel_4 on/off control

write_eeprom(eeprom_start_addr + 7, SetTemp[channel_4]);

write_eeprom(eeprom_start_addr + 8,SensorType[channel_5]); // Channel_5 on/off control

write_eeprom(eeprom_start_addr + 9, SetTemp[channel_5]);

write_eeprom(eeprom_start_addr + 10, TempCorrect[0]);

write_eeprom(eeprom_start_addr + 11, TempCorrect[1]);

write_eeprom(eeprom_start_addr + 12, TempCorrect[2]);

write_eeprom(eeprom_start_addr + 13, TempCorrect[3]);

write_eeprom(eeprom_start_addr + 14, TempCorrect[4]);

write_eeprom(eeprom_start_addr + 15, Used_HeatingFlags);

write_eeprom(eeprom_start_addr + 16, ~AllDataSum());

//enable_interrupts(GLOBAL); /* all interrupts on */


}