Hallo,
Ik wil graag in een eeprom data opslaan. Deze data bestaat uit:
1. een string van 20 bytes (karakters)
2. een string van 9 bytes (dec cijfers)
3. nog een string van 9 bytes (dec cijfers)

Deze 3 wil ik in één handeling opslaan en horen ook bij elkaar. 1. is namelijk een naam van max 20 karakters, 2. is de longtitude, en 3 is de lattitude.

nu heb ik ondestaande code maar begrijp niet wat de juiste adressering is in het betreffende eeprom. deze eeprom heeft een page size van 64 bytes.

in onderstaande code gaat het mis bij de tweede keer schrijven naar adres 32 tot 61. hier wordt er het e.e.a. overschreven.

Heeft iemand suggestie over de juiste adressering?

(onderstaande code is een probeersel)


DEVICE 18F4520
CONFIG_START
OSC = HS ; HS Oscillator
FCMEN = OFF ; Failsafe Clock Monitor Disabled
IESO = ON ; Int/Ext Oscillator Switch Over Disabled 
PWRT = ON ; Power Up Timer Enabled
BOREN = OFF ; Brownout Reset Disabled
BORV = 0 ; Brownout Reset Voltage 4.6V
WDT = OFF ; Watchdog Timer Disabled
WDTPS = 1 ; Watchdog Postscaler: 1:1
MCLRE = off ; MCLR disabled
LPT1OSC = ON ; T1 Oscillator Disabled 
CCP2MX = PORTC ; CCP2 Mux Muxed with RC1
STVREN = ON ; Stack Overflow Reset Enabled
LVP = OFF ; Low Voltage ICSP Disabled 
XINST = OFF ; XINST Disabled
DEBUG = OFF ; Background Debugger Disabled 
CP0 = OFF ; Code Protection Block 0 Disabled 
CP1 = OFF ; Code Protection Block 1 Disabled 
CP2 = OFF ; Code Protection Block 2 Disabled 
CP3 = OFF ; Code Protection Block 3 Disabled 
CPB = OFF ; Boot Block Code Protection Disabled 
CPD = OFF ; Data EEPROM Code Protection Disabled 
WRT0 = OFF ; Write Protection Block 0 Disabled 
WRT1 = OFF ; Write Protection Block 1Disabled 
WRT2 = OFF ; Write Protection Block 2 Disabled 
WRT3 = OFF ; Write Protection Block 3 Disabled 
WRTB = OFF ; Boot Block Write Protection Disabled 
WRTC = OFF ; Configuration Register Write Protection Disabled 
WRTD = OFF ; Data EEPROM Write Protection Disabled 
EBTR0 = OFF ; Table Read Protection Block 0 Disabled 
EBTR1 = OFF ; Table Read Protection Block 1 Disabled 
EBTR2 = OFF ; Table Read Protection Block 2 Disabled 
EBTR3 = OFF ; Table Read Protection Block 3 Disabled 
EBTRB = OFF ; Boot Block Table Read Protection Disabled 
CONFIG_END
XTAL 20


;DECLARE SERIAL_DATA 8 
;DECLARE SERIAL_PARITY = EVEN
;DECLARE HSERIAL_BAUD 4800     'set baudrate op 9600
;DECLARE HSERIAL_RCSTA $90     '  << VUL DEZE WAAREN IN MET HET PROGRAMMA
;DECLARE HSERIAL_TXSTA $20     '   <<         PIC multi CALC 
;DECLARE HSERIAL_CLEAR = ON    ' reset buffer bij een overflow? 

;**EEPROM*********************************************

DECLARE SCL_PIN PORTD.0
DECLARE SDA_PIN PORTD.1

DECLARE SERIAL_DATA 8 
DECLARE SERIAL_PARITY = EVEN
DECLARE SERIAL_BAUD 4800     'set baudrate op 9600
DECLARE HSERIAL_RCSTA $90     '  << VUL DEZE WAAREN IN MET HET PROGRAMMA
DECLARE HSERIAL_TXSTA $20     '   <<         PIC multi CALC 
DECLARE HSERIAL_CLEAR = ON    ' reset buffer bij een overflow? 


DIM REGEL1 [20] AS BYTE
DIM REGEL2[9] AS BYTE
DIM REGEL3[9] AS BYTE 

DIM REGEL4 [20] AS BYTE
DIM REGEL5[9] AS BYTE
DIM REGEL6[9] AS BYTE    
 
   
DIM BENOEMING [20] AS  BYTE
DIM POSITIELAT [9] AS BYTE
DIM POSITIELON [9] AS BYTE                   

DIM MYARRAY[20] AS BYTE                 ' Create a 10-byte array.
DIM ARRAY [20] AS BYTE
DIM ARRAY1 [9] AS BYTE
DIM ARRAY2 [9] AS BYTE
DIM ADDRESS AS WORD
    
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $20 ' Enable transmit, BRGH = 0
SPBRG = 64  ' 4800 Baud @ 20MHz, 0,17%

HPWM 1, 100, 8000               ;SET BACKLICHT OP +- 50%
HPWM 2, 100,8000                ;SET CONTRAST OP +- 50%


DELAYMS 200 ' Wait for the PICmicro to stabilise
ALL_DIGITAL = TRUE ' Set PORTA and PORTE to all digital
CLS
PRINT AT 1,1, "     B.A.S      "
PRINT AT 2,1, "  GPS TRACKER   "
DELAYMS 2000
CLS
             ;1.......9...........
STR REGEL1 = "DIT IS DE BENOEMING'"
STR REGEL2 = "LATTITUDE" 
STR REGEL3 = "LONTITUDE"

STR REGEL4 = "OOK DIT MAAR DAN 15."
STR REGEL5 = "+++++++++" 
STR REGEL6 = "---------"
CLS        
;**SCHRIJVEN*******************************************************

ADDRESS = 00
BUSOUT %10100000 , ADDRESS , [ STR REGEL1  ] ' Send 4-byte string.
DELAYMS 10

ADDRESS = 20
BUSOUT %10100000 , ADDRESS , [ STR REGEL2  ] ' Send 4-byte string.
DELAYMS 10

ADDRESS = 29
BUSOUT %10100000 , ADDRESS , [ STR REGEL3  ] ' Send 4-byte string.
DELAYMS 10

;**OPHALEN*********************************************************

ADDRESS = 00
BUSIN %10100000 , ADDRESS , [ STR ARRAY]
DELAYMS 20
PRINT AT 1,1, STR ARRAY

ADDRESS = 20
DELAYMS 1000
BUSIN %10100000 , ADDRESS , [ STR ARRAY1]
DELAYMS 20
PRINT AT 2,1, STR ARRAY1\9

ADDRESS = 29
BUSIN %10100000 , ADDRESS , [ STR ARRAY2]
DELAYMS 20
PRINT AT 3,1, STR ARRAY2\9

DELAYMS 4000
CLS
DELAYMS 1000

;**SCHRIJVEN*******************************************************
ADDRESS = 32
BUSOUT %10100000 , ADDRESS , [ STR REGEL1  ] ' Send 4-byte string.
DELAYMS 10

ADDRESS = 52
BUSOUT %10100000 , ADDRESS , [ STR REGEL2  ] ' Send 4-byte string.
DELAYMS 10

ADDRESS = 61
BUSOUT %10100000 , ADDRESS , [ STR REGEL3  ] ' Send 4-byte string.
DELAYMS 10

;**OPHALEN*********************************************************

ADDRESS = 32
BUSIN %10100000 , ADDRESS , [ STR ARRAY]
DELAYMS 20
PRINT AT 1,1, STR ARRAY

ADDRESS = 52
DELAYMS 1000
BUSIN %10100000 , ADDRESS , [ STR ARRAY1]
DELAYMS 20
PRINT AT 2,1, STR ARRAY1\9

ADDRESS = 61
BUSIN %10100000 , ADDRESS , [ STR ARRAY2]
DELAYMS 20
PRINT AT 3,1, STR ARRAY2\9

DELAYMS 4000
CLS
DELAYMS 1000

;**SCHRIJVEN*******************************************************
ADDRESS = 65
BUSOUT %10100000 , ADDRESS , [ STR REGEL1  ] ' Send 4-byte string.
DELAYMS 10

ADDRESS = 85
BUSOUT %10100000 , ADDRESS , [ STR REGEL2  ] ' Send 4-byte string.
DELAYMS 10

ADDRESS = 94
BUSOUT %10100000 , ADDRESS , [ STR REGEL3  ] ' Send 4-byte string.
DELAYMS 10

;**OPHALEN*********************************************************

ADDRESS = 65
BUSIN %10100000 , ADDRESS , [ STR ARRAY]
DELAYMS 20
PRINT AT 1,1, STR ARRAY

ADDRESS = 85
DELAYMS 1000
BUSIN %10100000 , ADDRESS , [ STR ARRAY1]
DELAYMS 20
PRINT AT 2,1, STR ARRAY1\9

ADDRESS = 94
BUSIN %10100000 , ADDRESS , [ STR ARRAY2]
DELAYMS 20
PRINT AT 3,1, STR ARRAY2\9

DELAYMS 4000
CLS

END 
[\code]

Voor mij is het grotendeels Latijn. Maar misschien loopt het hier fout:

ADDRESS = 61
BUSOUT %10100000 , ADDRESS , [ STR REGEL3 ] ' Send 4-byte string.

Je schrijft dus naar de adressen 61, 62, 63 en 64. Maar bij een page-size van 64 bytes vallen 61, 62 en 63 in de 1e page, en is 64 het eerste adres v/d 2e page.

Bedankt pros,
Ik heb de adressen gewijzigd.
1e 0,20,30
2e 64,84,94
etc.
Ik tel er steeds 64 bij op. In eerste instantie lijkt dit te werken. wordt vervolgt..

[Bericht gewijzigd door Henry S. op (51%)]