News:

;) This forum is the property of Proton software developers

Main Menu

[Solved] AddressOf() to point on EEPROM

Started by keytapper, Feb 04, 2023, 03:36 AM

Previous topic - Next topic

keytapper

Hello forum,
I'm studying a small project and I'm in search of strange idea  ;D

The common idea is to let the compiler compute the addressing, so the source won't be upset whenever constants are modified.

In this term, I'd like to know if the EEPROM address can be computed by the command addressOf(). Moreover the enhanced MCU can address flash and EEPROM memory in the same fashion.

Now using a 12F1840, I gave up all of obsolete stock  :P

I'd like to have something that works like:
Symbol OK_OUT  512                  ' threshold permitted to light up
Symbol NIGHTTIME  43200             ' period to disable the LDR input (12 hours)

E_OK_OUT:
EData Word OK_OUT                   ' save data for LDR
E_NIGHTTIME:
EData Word NIGHTTIME                ' save the night duration

Dim ADCthsld As Word                ' variable to store the current threshold
Dim NTCount As Word                 ' number of seconds to count night period

Main:
ADCthsld = ERead AddressOf(E_OK_OUT)' Read the threshold from eeprom
' for lazy typer may be:
' ADCthsld = ERead At E_OK_OUT
' period saved
NTCount =  ERead AddressOf(E_NIGHTTIME)

So the compile is done flawlessly, But I have a doubt:
F1_000094 equ $ ; in [P03.BAS] ADCthsld = Eread AddressOf(E_OK_OUT)
    movlw (((E_OK_OUT) + 0X8000) & 0XFF)
    movlp ((__eeread_) >> 8)
    call __eeread_
    movwf ADCthsld
    movlp ((__eeread_w_) >> 8)
    call __eeread_w_
    movwf ADCthsldH
;---------------------------------------------
; EEPROM DATA
    org 0XF000
    de 0,2,20
    de 0,192,168
    de 80,0
;---------------------------------------------

I think that the address is not on the EEPROM range.
Perhaps there would be a clause that will do:
#define __flash   0x8000                 ; setting a common name
#define __eeprom  0xF000
#if __address < __eeprom
  #define __mempointer __flash           ; a common name for __eeread_ call
#else
  #define __mempointer __eeprom
#endif
; for enhanced MCU can use the eeprom writer module
; to address flash and eeprom, IIRC
    movlw (((E_OK_OUT) + __mempointer) & 0XFF)
    movlp ((__eeread_) >> 8)
This probably triggered when the command implies a call to write/read in EEPROM. On the other hand if I'd like to change the default compiler routine, what may I try?
Ignorance comes with a cost

Dompie

E_NIGHTTIME EData Word NIGHTTIME
....
NTCount =  ERead E_NIGHTTIME

works perfect.
Johan

keytapper

#2
Oops, from one side of the story I confused the method ;D  :-X
Quote from: The manualAddressOf
Syntax
Assignment Variable = AddressOf ( Variable )
Overview
Returns the address of the variable in RAM, or a label in Code memory. Commonly known as a pointer.

At the other side of the story, I didn't catch that the manual states Code memory. In my POW the statement may have the option to span also to EEPROM address.

Perhaps, I should study to extend that command or to write a little procedure, which may be assembly coded.
I summarized is just over-complication ;D
Ignorance comes with a cost