I am migrating the code from mikrobasic a gcbasic.
two simple questions:
1) as the keyword to use the mathematical function MOD?
2) how states Lowbyte and Highbyte of a word?
in mikrobasic declare High (word) or Low (word).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks.
but now when the code is fill out this error:
Error: GCASM: Value out of range: Least significant bits used
Part of this code is guilty:
Escribe_Eeprom(0,(vNTC / 256),(vNTC % 256))
SUB Escribe_Eeprom(Address as word,wByte1 as byte,wByte2 as byte)
DIM wAddress As Word Alias Highbyte,Lowbyte
wAddress=Address
Start
TxI2C(160)
TxI2C(Highbyte)
TxI2C(Lowbyte)
TxI2C(wByte1)
TxI2C(Highbyte+1)
TxI2C(Lowbyte+1)
TxI2C(wByte2)
Stop
WAIT 10 ms
END SUB
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
is vNTC dim as word? Here is sub that should send word data to the eeprom:
sub Write16R16D(WriteID,Addr as word,I2Cdata as Word) #NR
Start
TxI2C(WriteID) 'Device ID write byte
TxI2C(Addr_H) 'Send word address high byte
TxI2C(Addr) 'Send word address low byte
TxI2C(I2Cdata_H) 'Send out high data byte
TxI2C(I2Cdata) 'Send out low data byte
Stop
end sub
Kent
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Mod is the rermaider of a devide
How big a number are you deviding
and what are you placing the number into
A word?
often its very small number any way
Lex
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am migrating the code from mikrobasic a gcbasic.
two simple questions:
1) as the keyword to use the mathematical function MOD?
2) how states Lowbyte and Highbyte of a word?
in mikrobasic declare High (word) or Low (word).
1. Use the % for MOD
Dec2HexString = test / 16
convert2Hex
Dec2HexString = test % 16 'Modulo or remainder
convert2Hex
2. To use a word variable it must be declared, so use" dim LargeVar as Word ".
If one wants to freely manipulate the high and low bytes of a word variable, look at this discussion: https://sourceforge.net/forum/forum.php?thread_id=3077406&forum_id=579125
thanks.
but now when the code is fill out this error:
Error: GCASM: Value out of range: Least significant bits used
Part of this code is guilty:
Escribe_Eeprom(0,(vNTC / 256),(vNTC % 256))
SUB Escribe_Eeprom(Address as word,wByte1 as byte,wByte2 as byte)
DIM wAddress As Word Alias Highbyte,Lowbyte
wAddress=Address
Start
TxI2C(160)
TxI2C(Highbyte)
TxI2C(Lowbyte)
TxI2C(wByte1)
TxI2C(Highbyte+1)
TxI2C(Lowbyte+1)
TxI2C(wByte2)
Stop
WAIT 10 ms
END SUB
Not 100% sure, and i don't know if this is the problem, but i think subroutines should be called this way (no brackets):
Escribe_Eeprom 0, (vNTC / 256), (vNTC % 256)
is vNTC dim as word? Here is sub that should send word data to the eeprom:
sub Write16R16D(WriteID,Addr as word,I2Cdata as Word) #NR
Start
TxI2C(WriteID) 'Device ID write byte
TxI2C(Addr_H) 'Send word address high byte
TxI2C(Addr) 'Send word address low byte
TxI2C(I2Cdata_H) 'Send out high data byte
TxI2C(I2Cdata) 'Send out low data byte
Stop
end sub
Kent
I followed everything as I was told.
Always the same result.
thanks.
this code now work
Escribe_Eeprom EE_Cont_Bat,vBateria
SUB Escribe_Eeprom(Address as word,Dato as word)
DIM wAddress As Word Alias Address_H,Address_L
DIM wDato As Word Alias Dato_H,Dato_L
wAddress=Address
wDato=Dato
Start
TxI2C(160) 'Envia el valor del comando de escritura
TxI2C(Address_H) 'Envia el valor alto de la EEPROM
TxI2C(Address_L) 'Envia el valor bajo de la EEPROM
TxI2C(Dato_H) 'Envia el valor alto de la lectura
TxI2C(Address_H+1) 'Envia el valor alto de la EEPROM
TxI2C(Address_L+1) 'Envia el valor bajo de la EEPROM
TxI2C(Dato_L) 'Envia el valor bajo de la lectura
Stop 'Termina la transmiciòn
WAIT 10 ms 'Espera para asegurar la escritura Eeprom
END SUB
thanks,Kent.
If you for example to a transmission code manchester???
Negative. I am sure there are examples on the web like: http://www.winpicprog.co.uk/pic_tutorial12.htm or http://www.embedded.com/design/networking/206500265?pgno=2
thanks.
we will work it.
Mod is the rermaider of a devide
How big a number are you deviding
and what are you placing the number into
A word?
often its very small number any way
Lex