Page 1 of 1
SPI.Transfer a string
Posted: Sat Dec 26, 2020 3:49 pm
by garryp4
I would like to transfer a byte as a string from an eeprom memory. I can transfer a byte in and out with no problem, but can not figure out how to read the byte as a string or convert it to a string.
Thanks!
Re: SPI.Transfer a string
Posted: Sat Dec 26, 2020 9:20 pm
by garryp4
Figured it out. I was not declaring the the string variable with an extra byte for the null character.
Code: Select all
Public Function READ_STRING(p_addr As LongWord) As String * 4
OPEN_SPI()
Low(mem_cs)
SPI.Transfer(read_data) ' Read instruction
SPI.Transfer(p_addr.byte2) ' Address byte 2
SPI.Transfer(p_addr.byte1) ' Address byte 1
SPI.Transfer(p_addr.byte0) ' Address byte 0
result(3) = SPI.Transfer()
result(2) = SPI.Transfer()
result(1) = SPI.Transfer()
result(0) = SPI.Transfer()
High(mem_cs)
SPI.Close
End Function
and
I originally had my_id As String(4).