Hello members,
Working on Linux, but i might be no difference for other platform, I stumbled on this case.
This is just a snippet.
#chip 12F1840,32#DEFINE OK_OUT 512 ' value where is permitted to light up#DEFINE MAXTIME [WORD]20 ' value to count how many seconds to stay on#DEFINE ONTIME 1800 ' how many seconds to stay on by serial cmd#DEFINE NIGHTTIME 43200 ' period to disable the LDR input (12 hours)'8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------DimADCthsldAsWord' variable to store the current thresholdDimnsValAsWord' current night value dividerDimADCreadAsWord' variable analog reading averageEPread6,nsVal' reload the reduction value for night timeEPread0,ADCthsld' Read the threshold from eepromADCread=OK_OUT' default value, until new readingTableeepromdataStoreDataOK_OUT' low byteOK_OUTH' high byteMAXTIMEMAXTIMEH' high byteNIGHTTIMENIGHTTIMEH' high byteNIGHTSENSENIGHTSENSEH' high byteTableEnd
Then the compiler gives me this error
Aborting due to runtime error 14 ("abnormal termination" signal) in /tmp/GreatCowBASIC/sources/utils.bi::LINKEDLISTDELETE()
Besides I should address my EPRead as Tableread, but I wasn't able to complete the compilation for the initial attempts.
There could be an error of mine to expect to put a set of words in EEPROM to be set during the firmware writing .
The purpose is to contain on the header all constant settings, rather than digging all the source if I will plan to make modifications.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you assigning a WORD variable to a BYTE variable then the compiler will only address the BYTE component of the WORD.
If you assigning a WORD variable to a BYTE variable and you want to assign the HIGH BYTE then the compiler will only address the HIGH BYTE component of the WORD with suffix _H.
wordvar = 0x12
bytevar = wordvar -> result of bytevar = 0x02
bytevar = wordvar_h -> result of bytevar = 0x01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have not tried this before... but, always good to learn the compiler.
I am using a word variable to read a word table (if you just read one value then the optimiser will not use a table.
In the table, defined as a Word, just use the Word values.
Evan
#chip 12F1840,32#DEFINE OK_OUT 512 ' value where is permitted to light up#DEFINE MAXTIME [WORD]20 ' value to count how many seconds to stay on#DEFINE ONTIME 1800 ' how many seconds to stay on by serial cmd#DEFINE NIGHTTIME 43200 ' period to disable the LDR input (12 hours)'8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------DimADCthsldAsWord' variable to store the current thresholdDimnsValAsWord' current night value dividerDimADCreadAsWord' variable analog reading averageEPread6,nsVal' reload the reduction value for night timeEPread0,ADCthsld' Read the threshold from eepromADCread=OK_OUT' default value, until new readingDimtableindexasWordReadtableeepromdata,tableindex,tabledataFortableindex=1totabledataReadtableeepromdata,tableindex,tabledataNextTableeepromdataStoreDataasWordOK_OUT' low byte//OK_OUTH' high byteMAXTIME//MAXTIMEH' high byteNIGHTTIME//NIGHTTIMEH' high byte//!NIGHTSENSE//NIGHTSENSEH' high byteTableEnd
ASM looks correct.
TableEEPROMDATAequ0de3,512,20,43200END
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is the second day of life with GCbasic, the learning curve is pretty steep :-)
I was looking at the idea to set the table as word, and also the read table, but try and fail got 90% of failures.
So I will add this tip to my know-how baggage ;-)
On the other hand, it was only the attempt to set the EEPROM with pre-defined values. So I have only to modify things in one place. As shown the data would be loaded on the variable with the even and fixed addressing.
May there's the way to get the value of each displacement by the command sizeof(). It's looking like a Cish way.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
SizeOf() on the array, I think I got it, but to have the way to know where it could be the next variable saved somewhere in the memory I probably would make something like:
Sub EEreadSavedData()
' the routine intent is to save data in a structure fashion
' where the memBank is what determine the number of block
' to be written
pntr = numblock * SavedDataSPACE + memBank
ReadEEdata:
EPRead pntr,SavedDataWr
tmpl = SizeOf(SavedDataWr)
pntr = pntr + tmpl
EPRead pntr,SavedDataSize
tmpl = SizeOf(SavedDataSize)
pntr = pntr + tmpl
EPRead pntr,SavedDataTotLen
tmpl = SizeOf(SavedDataTotLen)
pntr = pntr + tmpl
EPRead pntr,SavedDataRep
EndSub
This is what a developer wish to have. The reason is that a certain point the data may need to be changed on the source to some different cast, then to preserve the same functionality the compiler should help out to recover the position on that Table and load the reshaped variable.
I learned to write in C/C++ and that offers more things as I'm telling here, but I like the concept to have a broader number of MCU that can use the same language to compile, like GCbasic.
My apologies for such ambitious design, I'm understanding that is a lot of things to add more features, therefore it's just my intention to share some idea, not to ask for more.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello members,
Working on Linux, but i might be no difference for other platform, I stumbled on this case.
This is just a snippet.
Then the compiler gives me this error
Besides I should address my EPRead as Tableread, but I wasn't able to complete the compilation for the initial attempts.
There could be an error of mine to expect to put a set of words in EEPROM to be set during the firmware writing .
The purpose is to contain on the header all constant settings, rather than digging all the source if I will plan to make modifications.
Is that a valid name for a table?
Try:
Table eepromdataStoreData
You will also need to access the High/Low bytes in the correct format:
OK_OUT ' low byte
OK_OUT_H ' high byte
AFAIK the assembler would accept the following statement:
But still doesn't go.
Then I don't know how the compiler will load into variable, as little endian or big endian.
Last edit: Fulvio _ 2023-02-02
Why are using #asmraw ?
If you assigning a WORD variable to a BYTE variable then the compiler will only address the BYTE component of the WORD.
If you assigning a WORD variable to a BYTE variable and you want to assign the HIGH BYTE then the compiler will only address the HIGH BYTE component of the WORD with suffix _H.
wordvar = 0x12
bytevar = wordvar -> result of bytevar = 0x02
bytevar = wordvar_h -> result of bytevar = 0x01
I have not tried this before... but, always good to learn the compiler.
I am using a word variable to read a word table (if you just read one value then the optimiser will not use a table.
In the table, defined as a Word, just use the Word values.
Evan
ASM looks correct.
This is the second day of life with GCbasic, the learning curve is pretty steep :-)
I was looking at the idea to set the table as word, and also the read table, but try and fail got 90% of failures.
So I will add this tip to my know-how baggage ;-)
On the other hand, it was only the attempt to set the EEPROM with pre-defined values. So I have only to modify things in one place. As shown the data would be loaded on the variable with the even and fixed addressing.
May there's the way to get the value of each displacement by the command sizeof(). It's looking like a Cish way.
Re sizeof(). For tables read the address 0.
In the code below. I have read the number items in the table. (My code above did not do this... my err).
Evan
SizeOf() on the array, I think I got it, but to have the way to know where it could be the next variable saved somewhere in the memory I probably would make something like:
This is what a developer wish to have. The reason is that a certain point the data may need to be changed on the source to some different cast, then to preserve the same functionality the compiler should help out to recover the position on that Table and load the reshaped variable.
I learned to write in C/C++ and that offers more things as I'm telling here, but I like the concept to have a broader number of MCU that can use the same language to compile, like GCbasic.
My apologies for such ambitious design, I'm understanding that is a lot of things to add more features, therefore it's just my intention to share some idea, not to ask for more.