Re: [Amforth] Read/write from safe known fixed EEPROM address

2019-08-07 Thread Tristan Williams
Hello Erich,

Thank you! 

I wish to read/write the value from/to a known fixed EEPROM address
from applturnkey using assembler. Thank you for pointing me towards
avr8/amforth-eeprom.inc 

In avr8/amforth-eeprom.inc the top line is

.dw -1   ; EEPROM Address 0 should not be used

Does this mean that $0 is reserved and used by AmForth internally or
$0 is not to be used because historically it has been used by other
programs e.g. storing calibrated OSCCAL value? If it is the latter,
then it would be very opportune.

kind regards and thanks,
Tristan


On 07Aug19 12:09, Erich Wälde wrote:
> Hello Tristan,
> 
> 
> Tristan Williams writes:
> 
> > Hello,
> >
> > I would like to modify my AVR build of AmForth to read/write a byte
> > from a known fixed EEPROM address, perhaps from applturnkey. This byte
> > may be written outside of AmForth. Is there a safe area of EEPROM
> > from which to do this or a way making one? Any pointers as to where to
> > look appreciated.
> 
> 
> Words like "eallot" "Evalue" "e@" "e!" and the like are
> available, let's see ...
> 
>   | @e  | ./avr8/words/fetch-e.asm
>   | !e  | ./avr8/words/store-e.asm
>   | ehere   | ./avr8/words/ehere.asm
>   | eallot  | ./avr8/lib/eallot.frt
>   | Evalue  | ./avr8/lib/forth2012/core/avr-values.frt
>   | 2@e 2!e 2Evalue | ./avr8/lib/2evalue.frt
>   | Eallot Ebuffer  | ./avr8/lib/forth2012/core/eeprom-buffer.frt
> 
> 
> So I think, creating an Evalue could help you. There is some
> more text here
> http://amforth.sourceforge.net/TG/recipes/Values.html
> 
> You can then wrap such stuff together with applturnkey
> (example):
> 
> >  : run-turnkey
> >applturnkey \ call the original turnkey first
> >  
> >init\ add one time stuff here
> >  
> >starttasker \ start the loop!
> >  ;
> 
> 
> 
> 
> However, if you want to modify AmForth to be assembled with this
> value already, then avr8/amforth-eeprom.inc is the place to
> start. Add another label and value in this file, verify that
> ehere points to the correct (first empty) location after
> assembling, and be sure to add a word, which will retrieve this
> EEprom content and place it on the stack.
> 
> Well, I have done this before ... /me searches the archives ...
> 
> in a project-local copy of amforth-eeprom.inc I added 2 lines to
> define a location in eeprom
> 
> >  EE_UBRRVAL:
> >  .dw UBRR_VAL ; BAUDRATE
> > +EE_PROMPT_RDY:
> > +.dw XT_PROMPTREADY_INT
> 
> This label (EE_PROMPT_RDY) is used in a word defined in asm:
> 
> >  cat words/prompt-ready.asm
> >  ; make prompt_ready a deferred word
> >   
> >  VE_PROMPTREADY:
> >  .dw $ff04
> >  .db "p_rd"
> >  .dw VE_HEAD
> >  .set VE_HEAD = VE_PROMPTREADY
> >  XT_PROMPTREADY:
> >  .dw PFA_DODEFER1
> >  PFA_PROMPTREADY:
> >  .dw EE_PROMPT_RDY  ; < used here
> >  .dw XT_EDEFERFETCH
> >  .dw XT_EDEFERSTORE
> 
> The content of this location is retrieved (edefer@) and should
> be on top of the stack then (it is consumed again by edefer! in
> this case.)  The defined "p_rd" is used in Forth code later:
> 
> : +stationid
>   ['] prompt_rd to p_rd
> ;
> : init
>   +stationid
>   ...
> ; 
> 
> In this particular case I made the ready prompt to be a deferred
> word, because I wanted it to print some information (the
> stationID). Nowadays all prompt functions are deferred and I
> don't need to do this any more. But it should give you an idea
> on how to proceed.
> 
> There is one more option: the Evalue can live in an external i2c
> EEPROM, too. See
> http://amforth.sourceforge.net/TG/recipes/I2C-Values.html#i2c-values
> 
> 
> So many options!
> Hope this helps,
> 
> Erich
> 
> --
> May the Forth be with you ...
> 
> 
> ___
> Amforth-devel mailing list for http://amforth.sf.net/
> Amforth-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/amforth-devel
> 


___
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel


Re: [Amforth] Read/write from safe known fixed EEPROM address

2019-08-07 Thread Erich Wälde
Hello Tristan,


Tristan Williams writes:

> Hello,
>
> I would like to modify my AVR build of AmForth to read/write a byte
> from a known fixed EEPROM address, perhaps from applturnkey. This byte
> may be written outside of AmForth. Is there a safe area of EEPROM
> from which to do this or a way making one? Any pointers as to where to
> look appreciated.


Words like "eallot" "Evalue" "e@" "e!" and the like are
available, let's see ...

  | @e  | ./avr8/words/fetch-e.asm
  | !e  | ./avr8/words/store-e.asm
  | ehere   | ./avr8/words/ehere.asm
  | eallot  | ./avr8/lib/eallot.frt
  | Evalue  | ./avr8/lib/forth2012/core/avr-values.frt
  | 2@e 2!e 2Evalue | ./avr8/lib/2evalue.frt
  | Eallot Ebuffer  | ./avr8/lib/forth2012/core/eeprom-buffer.frt


So I think, creating an Evalue could help you. There is some
more text here
http://amforth.sourceforge.net/TG/recipes/Values.html

You can then wrap such stuff together with applturnkey
(example):

>  : run-turnkey
>applturnkey \ call the original turnkey first
>  
>init\ add one time stuff here
>  
>starttasker \ start the loop!
>  ;




However, if you want to modify AmForth to be assembled with this
value already, then avr8/amforth-eeprom.inc is the place to
start. Add another label and value in this file, verify that
ehere points to the correct (first empty) location after
assembling, and be sure to add a word, which will retrieve this
EEprom content and place it on the stack.

Well, I have done this before ... /me searches the archives ...

in a project-local copy of amforth-eeprom.inc I added 2 lines to
define a location in eeprom

>  EE_UBRRVAL:
>  .dw UBRR_VAL ; BAUDRATE
> +EE_PROMPT_RDY:
> +.dw XT_PROMPTREADY_INT

This label (EE_PROMPT_RDY) is used in a word defined in asm:

>  cat words/prompt-ready.asm
>  ; make prompt_ready a deferred word
>   
>  VE_PROMPTREADY:
>  .dw $ff04
>  .db "p_rd"
>  .dw VE_HEAD
>  .set VE_HEAD = VE_PROMPTREADY
>  XT_PROMPTREADY:
>  .dw PFA_DODEFER1
>  PFA_PROMPTREADY:
>  .dw EE_PROMPT_RDY  ; < used here
>  .dw XT_EDEFERFETCH
>  .dw XT_EDEFERSTORE

The content of this location is retrieved (edefer@) and should
be on top of the stack then (it is consumed again by edefer! in
this case.)  The defined "p_rd" is used in Forth code later:

: +stationid
  ['] prompt_rd to p_rd
;
: init
  +stationid
  ...
; 

In this particular case I made the ready prompt to be a deferred
word, because I wanted it to print some information (the
stationID). Nowadays all prompt functions are deferred and I
don't need to do this any more. But it should give you an idea
on how to proceed.

There is one more option: the Evalue can live in an external i2c
EEPROM, too. See
http://amforth.sourceforge.net/TG/recipes/I2C-Values.html#i2c-values


So many options!
Hope this helps,

Erich

--
May the Forth be with you ...


___
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel


[Amforth] Read/write from safe known fixed EEPROM address

2019-08-07 Thread Tristan Williams
Hello,

I would like to modify my AVR build of AmForth to read/write a byte
from a known fixed EEPROM address, perhaps from applturnkey. This byte
may be written outside of AmForth. Is there a safe area of EEPROM
from which to do this or a way making one? Any pointers as to where to
look appreciated.

Kind regards,
Tristan





___
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel