I'm stuck. I'm using my old 30F4013/20MHz. LVD module is enabled. When the PIC works without PLL, i.e. on 20MHz the LVD module works just fine - everything is written correctly to PIC's EEPROM. When however I set the PIC to work on HS2PLL4 or HS2PLL8 (40 and 80MHz respectivly) the LVD "sometimes" misses the write operation - either does not write, or writes incorrect data. What may be the reason? I need the PLL in order to have a good communication with the ENC. So I have to find a decision. Here's my code for the LVD module:
Code: Select all
procedure WaitWR;
begin
while NVMCON.15 = 1 do //wait until WR:=0
// nop;
// begin
// end;
end;
procedure LVDetect_Interrupt; org $68; // low voltage detection!
var Data : array [24] of Word;
begin
IEC0:=0;
IEC1:=0;
// IEC2.10:=0;
CORCON.3:=1;
SR.7:=1;
SR.6:=1;
SR.5:=1;
//IEC0:=IEC0 and 0xFFB7; //0xFFF7; // %1111111111110111
Data[0]:=ProductionCounterLowWord;
Data[1]:=ProductionCounterHighWord;
Data[2]:=TaLowWord;
Data[3]:=TaHighWord;
Data[4]:=Tf;
Data[5]:=Tmin;
Data[6]:=Tmax;
Data[7]:=Day;
Data[8]:=Month;
Data[9]:=Year;
Data[10]:=Hour;
Data[11]:=Min;
Data[12]:=Sec;
Data[13]:=LastLogPage;
Data[14]:=LastLogNum;
Data[15]:=Address_485;
Data[16]:=myIpAddr[0] shl 8 + myIpAddr[1];
Data[17]:=myIpAddr[2] shl 8 + myIpAddr[3];
Data[18]:=myPort;
Data[19]:=PasswordLowWord;
Data[20]:=PasswordHighWord;
Data[21]:=myMacAddr[0] shl 8 + myMacAddr[1];
Data[22]:=myMacAddr[2] shl 8 + myMacAddr[3];
Data[23]:=myMacAddr[4] shl 8 + myMacAddr[5];
Eeprom_Write_Block(CounterAddress, Data);
WaitWR;
CORCON.3:=0;
SR.7:=0;
SR.6:=0;
SR.5:=1;
IEC0:=IEC0 or 0x0048;
end;
Any suggestions will be highly appreciated.
Thank you in advance.
Regards,
Javor