BrianT
- 17th July 2008, 07:32
18LF4620, MCSP, MPASM, Melabs USB serial programmer.
Program 1 writes data to the EEPROM and successfully plays it back.
During programming, the coonfiguration bit "Data EEPROM" Protected or Not Protected makes no difference. The EEPROM always gets programmed by the DATA statements. Likewise changing Table Write Data EEPROM makes no difference - the EEPROM always gets what is in the DATA statements.
Program 2 always overwrites the data EEPROM. Playback shows the EEPROM as all $FF regardless of whether I have the Data EEPROM protected or not or whether I have the Table Write Data EEPROM protected or not.
In my real application, program 2 must not corrupt the data stored in EEPROM as it contains unique data like serial numbers and calibration coefficients that were derived when program 1 ran for the first time.
What am I doing wrong?
Program 1
'************* Config Register setup for USB programmer ****************
' OSC = HS, FSCM = En, IESO = En, PwrupTmr = En, BrownOut = Dis
' BOR Volts = 2, WDT = Off, WDTPS = 1:512, CCP2 mux = RB3,
' PortB rst = Digital, LPT1Osc = Low, MCLR = Reset, LVP = Dis
' Enhanced CPU = Dis, All memory = Not Protected
' Note re power consumption. PBP assumes the WDTPS is set to 512.
' SLEEP draws 2.5 uA in this system. Each time sleep times out there
' is a current pulse for 2.5 mSecs at 600 uA. Setting WDTPS = 1024 extends
' the SLEEP internal period by 2 and so the average power drops BUT
' PBP will get the sleep times wrong by the factor of chosen WDTPS:512
'************************************************* ***********************
'
data @900, "This is a string from byte 900 ",13,10
data @850, "This is a string from byte 850 ",13,10
data @800, "This is a string from byte 800 ",13,10
data @750, "This is a string from byte 750 ",13,10
data @650, "This is a string from byte 650 ",13,10
data @600, "This is a string from byte 600 ",13,10
data @500, "This is a string from byte 500 ",13,10
data @400, "This is a string from byte 400 ",13,10
data @350, "This is a string from byte 350 ",13,10
data @300, "This is a string from byte 300 ",13,10
data @250, "This is a string from byte 250 ",13,10
data @200, "This is a string from byte 200 ",13,10
data @150, "This is a string from byte 150 ",13,10
data @100, "This is a string from byte 100 ",13,10
data @50, "This is a string from byte 50 ",13,10
data @0, "Data Read Write test from byte 0 ",13,10
'************************* Defines *****************************
DEFINE OSC 4
DEFINE DEBUG_REG PORTB 'Debug pin port
DEFINE DEBUG_BIT 6 'Debug pin bit
DEFINE DEBUG_BAUD 19200 'Debug baud rate
DEFINE DEBUG_MODE 0 'Debug mode: 0 = True, 1 = Inverted
DEFINE DEBUG_PACING 2000
A var byte
B var byte
C var byte
pause 2000
debug 13, 10, 13, 10, 13, 10, "Data loaded to EEPROM", 13, 10
debug 13, 10, "Numeric EEROM dump 0 ~ 1023", 13, 10
for a = 0 to 63
for b = 0 to 15
read (16*a + b), c
debug #c, ", "
next b
debug 13, 10
next a
debug 13, 10, "Literal EEROM dump 0 ~ 1023", 13, 10
for a = 0 to 63
for b = 0 to 15
read (16*a + b), c
debug c, ", "
next b
debug 13, 10
next a
end
Program 2
'************* Config Register setup for USB programmer ****************
' OSC = HS, FSCM = En, IESO = En, PwrupTmr = En, BrownOut = Dis
' BOR Volts = 2, WDT = Off, WDTPS = 1:512, CCP2 mux = RB3,
' PortB rst = Digital, LPT1Osc = Low, MCLR = Reset, LVP = Dis
' Enhanced CPU = Dis, Data EEPROM = Protected, All the rest of memory = Not Protected
'************************* Defines *****************************
DEFINE OSC 4
DEFINE DEBUG_REG PORTB 'Debug pin port
DEFINE DEBUG_BIT 6 'Debug pin bit
DEFINE DEBUG_BAUD 19200 'Debug baud rate
DEFINE DEBUG_MODE 0 'Debug mode: 0 = True, 1 = Inverted
DEFINE DEBUG_PACING 2000
A var byte
B var byte
C var byte
pause 1000
debug 13, 10, 13, 10, 13, 10, "Data being retrieved from EEPROM", 13, 10
debug 13, 10, "Numeric EEROM dump 0 ~ 1023", 13, 10
for a = 0 to 63
for b = 0 to 15
read (16*a + b), c
debug #c, ", "
next b
debug 13, 10
next a
debug 13, 10, "Literal EEROM dump 0 ~ 1023", 13, 10
for a = 0 to 63
for b = 0 to 15
read (16*a + b), c
debug c, ", "
next b
debug 13, 10
next a
end
Program 1 writes data to the EEPROM and successfully plays it back.
During programming, the coonfiguration bit "Data EEPROM" Protected or Not Protected makes no difference. The EEPROM always gets programmed by the DATA statements. Likewise changing Table Write Data EEPROM makes no difference - the EEPROM always gets what is in the DATA statements.
Program 2 always overwrites the data EEPROM. Playback shows the EEPROM as all $FF regardless of whether I have the Data EEPROM protected or not or whether I have the Table Write Data EEPROM protected or not.
In my real application, program 2 must not corrupt the data stored in EEPROM as it contains unique data like serial numbers and calibration coefficients that were derived when program 1 ran for the first time.
What am I doing wrong?
Program 1
'************* Config Register setup for USB programmer ****************
' OSC = HS, FSCM = En, IESO = En, PwrupTmr = En, BrownOut = Dis
' BOR Volts = 2, WDT = Off, WDTPS = 1:512, CCP2 mux = RB3,
' PortB rst = Digital, LPT1Osc = Low, MCLR = Reset, LVP = Dis
' Enhanced CPU = Dis, All memory = Not Protected
' Note re power consumption. PBP assumes the WDTPS is set to 512.
' SLEEP draws 2.5 uA in this system. Each time sleep times out there
' is a current pulse for 2.5 mSecs at 600 uA. Setting WDTPS = 1024 extends
' the SLEEP internal period by 2 and so the average power drops BUT
' PBP will get the sleep times wrong by the factor of chosen WDTPS:512
'************************************************* ***********************
'
data @900, "This is a string from byte 900 ",13,10
data @850, "This is a string from byte 850 ",13,10
data @800, "This is a string from byte 800 ",13,10
data @750, "This is a string from byte 750 ",13,10
data @650, "This is a string from byte 650 ",13,10
data @600, "This is a string from byte 600 ",13,10
data @500, "This is a string from byte 500 ",13,10
data @400, "This is a string from byte 400 ",13,10
data @350, "This is a string from byte 350 ",13,10
data @300, "This is a string from byte 300 ",13,10
data @250, "This is a string from byte 250 ",13,10
data @200, "This is a string from byte 200 ",13,10
data @150, "This is a string from byte 150 ",13,10
data @100, "This is a string from byte 100 ",13,10
data @50, "This is a string from byte 50 ",13,10
data @0, "Data Read Write test from byte 0 ",13,10
'************************* Defines *****************************
DEFINE OSC 4
DEFINE DEBUG_REG PORTB 'Debug pin port
DEFINE DEBUG_BIT 6 'Debug pin bit
DEFINE DEBUG_BAUD 19200 'Debug baud rate
DEFINE DEBUG_MODE 0 'Debug mode: 0 = True, 1 = Inverted
DEFINE DEBUG_PACING 2000
A var byte
B var byte
C var byte
pause 2000
debug 13, 10, 13, 10, 13, 10, "Data loaded to EEPROM", 13, 10
debug 13, 10, "Numeric EEROM dump 0 ~ 1023", 13, 10
for a = 0 to 63
for b = 0 to 15
read (16*a + b), c
debug #c, ", "
next b
debug 13, 10
next a
debug 13, 10, "Literal EEROM dump 0 ~ 1023", 13, 10
for a = 0 to 63
for b = 0 to 15
read (16*a + b), c
debug c, ", "
next b
debug 13, 10
next a
end
Program 2
'************* Config Register setup for USB programmer ****************
' OSC = HS, FSCM = En, IESO = En, PwrupTmr = En, BrownOut = Dis
' BOR Volts = 2, WDT = Off, WDTPS = 1:512, CCP2 mux = RB3,
' PortB rst = Digital, LPT1Osc = Low, MCLR = Reset, LVP = Dis
' Enhanced CPU = Dis, Data EEPROM = Protected, All the rest of memory = Not Protected
'************************* Defines *****************************
DEFINE OSC 4
DEFINE DEBUG_REG PORTB 'Debug pin port
DEFINE DEBUG_BIT 6 'Debug pin bit
DEFINE DEBUG_BAUD 19200 'Debug baud rate
DEFINE DEBUG_MODE 0 'Debug mode: 0 = True, 1 = Inverted
DEFINE DEBUG_PACING 2000
A var byte
B var byte
C var byte
pause 1000
debug 13, 10, 13, 10, 13, 10, "Data being retrieved from EEPROM", 13, 10
debug 13, 10, "Numeric EEROM dump 0 ~ 1023", 13, 10
for a = 0 to 63
for b = 0 to 15
read (16*a + b), c
debug #c, ", "
next b
debug 13, 10
next a
debug 13, 10, "Literal EEROM dump 0 ~ 1023", 13, 10
for a = 0 to 63
for b = 0 to 15
read (16*a + b), c
debug c, ", "
next b
debug 13, 10
next a
end