From: Tristan W. <ho...@tj...> - 2019-08-07 08:19:21
|
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 |
From: Erich W. <ew....@na...> - 2019-08-07 11:01:48
|
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 ... |
From: Tristan W. <ho...@tj...> - 2019-08-07 15:27:30
|
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/ > Amf...@li... > https://lists.sourceforge.net/lists/listinfo/amforth-devel > |
From: Erich W. <ew....@na...> - 2019-08-08 18:34:07
|
Hello Tristan, > > 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. If my memory serves me well, some toolchains keep track of the number of erase cycles they did, or something such. I do not know why Matthias has chosen to not use addr 0. But I do not use it either. Once I have defined an new label at the end, and used it somewhere else, I tend to forget, where it was. Because I never have do deal with this address again. So, imho not important. Cheers, and good luck! Erich -- May the Forth be with you ... |
From: Tristan W. <ho...@tj...> - 2019-08-13 20:53:34
|
Hello Erich, Thanks again for your help. I managed to modify applturnkey to read from internal EEPROM, which was the missing part of my project to have AmForth use the RC oscillator as a clock source. kind regards, Tristan On 08Aug19 19:47, Erich Wälde wrote: > Hello Tristan, > > > > > > 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. > > If my memory serves me well, some toolchains keep track of the > number of erase cycles they did, or something such. I do not > know why Matthias has chosen to not use addr 0. But I do not use > it either. Once I have defined an new label at the end, and > used it somewhere else, I tend to forget, where it was. Because > I never have do deal with this address again. > > So, imho not important. > > Cheers, and good luck! > Erich > > > -- > May the Forth be with you ... > > > _______________________________________________ > Amforth-devel mailing list for http://amforth.sf.net/ > Amf...@li... > https://lists.sourceforge.net/lists/listinfo/amforth-devel > |
From: Erich W. <ew....@na...> - 2019-08-14 07:02:41
|
Hello Tristan, > Thanks again for your help. You are welcome! > I managed to modify applturnkey to read from internal EEPROM, > which was the missing part of my project to have AmForth use > the RC oscillator as a clock source. Glad I could help. It is often only a tiny piece of information, which opens the door. Happy hacking! Please consider to share more details of your project, we are all eager to learn from others, aren't we? Cheers, Erich -- May the Forth be with you ... |
From: Tristan W. <ho...@tj...> - 2019-08-16 16:32:49
|
Hello Erich, Project was probably too grand a word! I have made a few notes below, though they are not of cookbook standard. https://www.mostlymostly.uk/post/2019.08.09/ kind regards, Tristan On 14Aug19 08:39, Erich Wälde wrote: > Hello Tristan, > > > Thanks again for your help. > You are welcome! > > > I managed to modify applturnkey to read from internal EEPROM, > > which was the missing part of my project to have AmForth use > > the RC oscillator as a clock source. > Glad I could help. It is often only a tiny piece of information, > which opens the door. > > Happy hacking! > Please consider to share more details of your project, > we are all eager to learn from others, aren't we? > > Cheers, > Erich > > > -- > May the Forth be with you ... > > > _______________________________________________ > Amforth-devel mailing list for http://amforth.sf.net/ > Amf...@li... > https://lists.sourceforge.net/lists/listinfo/amforth-devel > |