News:

Let's find out together what makes a PIC Tick!

Main Menu

EEPROM misfire

Started by Fanie, Nov 11, 2024, 05:42 PM

Previous topic - Next topic

Fanie

I cannot believe I'm having trouble with this
I've used the Eread and Ewrite numerous times, and now cannot get it working.
I'm beginning to think the pic is broke.

Device = 16F684

Dim Drukker As Dword             ' frekwensie waarteen drukker gedryf word
Dim Voerder As Dword


Drukker = 20
       EWrite 10, [Drukker]    ' Start val for drukker 
       Voerder = 63
       EWrite 20, [Voerder]

Drukker = 0
       Voerder = 0
       Drukker = ERead 10
       Voerder = ERead 20


  Dis1 = Dig Drukker , 0                  ' Extract Current values for display
        Dis2 = Dig Drukker , 1
        Dis3 = Dig Drukker , 2
        Dis4 = Dig Drukker , 3
 
        Dis5 = Dig Voerder , 0                  ' Extract Current values for display
        Dis6 = Dig Voerder , 1
        Dis7 = Dig Voerder , 2
        Dis8 = Dig Voerder , 3
       
        GoSub Display


Display 7295 and 0100


Device = 16F684

Dim Drukker As Dword             ' frekwensie waarteen drukker gedryf word
Dim Voerder As Dword



       EWrite 10, [20]    ' Start val for drukker 

       EWrite 20, [63]

Drukker = 0
       Voerder = 0
       Drukker = ERead 10
       Voerder = ERead 20


  Dis1 = Dig Drukker , 0                  ' Extract Current values for display
        Dis2 = Dig Drukker , 1
        Dis3 = Dig Drukker , 2
        Dis4 = Dig Drukker , 3
 
        Dis5 = Dig Voerder , 0                  ' Extract Current values for display
        Dis6 = Dig Voerder , 1
        Dis7 = Dig Voerder , 2
        Dis8 = Dig Voerder , 3
       
        GoSub Display


Display 7060 and 7103


     Drukker = 20 : Voerder = 63

  Dis1 = Dig Drukker , 0                  ' Extract Current values for display
        Dis2 = Dig Drukker , 1
        Dis3 = Dig Drukker , 2
        Dis4 = Dig Drukker , 3
 
        Dis5 = Dig Voerder , 0                  ' Extract Current values for display
        Dis6 = Dig Voerder , 1
        Dis7 = Dig Voerder , 2
        Dis8 = Dig Voerder , 3
       
        GoSub Display

Display 20 and 63

John Lawton

You haven't waited for the EEPROM to write before reading it.

John

top204

If you are running an interrupt, disable it while you write to the on-board EEPROM.

The compiler's library code waits for the EERPOM to finish writing, however, the old devices did have querks, so try a small DelayMs after the EWrite command, just in case. Also, make sure your voltage is stable, because this can also effect the old dev ices while writing to flash or EERPOM.

Fanie

#3
Thank you John and Les.

No interrupts running and I had up to delayms 20 after each write and read - the longer write required is mentioned in the manual.

Perhaps this pic has a punctured EEPROM.  I'll swap it with another and try again.
I was thinking perhaps I'm staring against my eyelids and am missing something obvious.

Fanie

#4
I swapped the South African ::) (Mantech) pic out for another (Mouser) one and this one works with a delay of 20ms after each write.
It still did not work with a delayms 10 delay.  Very slow.

Thanks for looking. 
I will use the one I took off for flashing LED purposes ;D
When I started with the ESP32, my brother sent me a C flashing LED routine.
I think I must send him a flashing LED routine in Pic basic.

John Lawton

Did you set the declare correctly, (to match the actual frequency) e.g.
Declare Xtal = 4
Otherwise the EEPROM write delay might not be correct.

John

Fanie

Yes John.  I've used the same many times in the past.  Remember I have most of my analog inputs calibrate themselves automatic, they all use values saved in EEPROM.

I have lost a few pics in the not too distant past due to malfunction.  With these things you cannot do much because the user is always at fault.  You simply replace it and things go on.  Who knows, they may have been abused getting here, and some of the resellers have illiterates repackaging components by hand.  This you can see by the waveform the pins are bent on one side, and you cannot complain because then you are a racist. Trump wasn't too far off when he called this place a sht-hole.