In am trying to write a series of bytes to an EEprom, so I need to extract a single byte at a time from an array.
As an example I am trying to use the code below:
Code: Select all
typedef str as char[64]
Const DStor as str [64] = ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!£"")
Const E_addr = 0xA0 '24C08 base address.
dim L_add, H_add, 'sub addresses
d_cnt, 'position counter
b_cnt, 'byte counter
I2_Add 'actual address byte to send
as byte
'dim Dstor as str[64]
Sub function Get_add() as byte
'returns Base address plus hi byte of subaddress shifted left one bit.
result = (E_addr) OR ((H_add and 0x0F) <<1)
end sub
Sub procedure Send_I2C_dat()
I2_Add = Get_add() 'gets upper byte of sub address into I2Caddress
I2C1_Start()
I2C1_wr(I2_Add)
I2C1_WR(L_add) 'start address
for b_cnt = 0 to 15
****** I2C1_wr(Dstor[d_cnt]) 'gets data & writes to EEprom ***********
inc (d_cnt)
next i
I2C1_stop()
do
nop
loop until I2C_is_idle() = 1 'wait for write
I have tried declaring the data as Char and string but get the same error.
I have tried making the Dstor a variable and loading it with the same string.
The manual suggests that this is OK:
dim s as string[5]
' ...
s = "mik"
' s[0] is char literal "m"
' s[1] is char literal "i"
' s[2] is char literal "k"
' s[3] is zero
' s[4] is undefined
' s[5] is undefined
but I seem unable to get a specific character from the array to write.
Any help would be appreciated.