SPI Read Returns Empty String

12 views
Skip to first unread message

Chris Blowfield

unread,
Jul 24, 2014, 7:51:43 AM7/24/14
to solde...@googlegroups.com

I’m trying to use the hardware SPI on the SolderCore board using the "SPI-DEVICE" driver. Writes are performed correctly, but reads return an empty string (I would expect a number). For Example:

 

>10 INSTALL "SPI-DEVICE" USING CORE.D10 AS MPU  ' for select

>20 MPU.SPEED = 1000000 ' 1 MHz

>30 SPI MPU WRITE 0xff READ 2 TO D 'Read 2 bytes into D

>40 PRINT D

>50 END

> 

>run

 

> 

 

The following pins are used. The the correct output waveforms are produced on the output pins.

D10       CS

D11       SPI MOSI

D12       SPI MISO

D13       SPI SCK

 

I have tried connecting the SPI MISO to 0v, +3.3v, and left floating. All these configurations return the same result.

 

I have tried performing the read without the write:

10 INSTALL "SPI-DEVICE" USING CORE.D10 AS MPU  ' for select

20 MPU.SPEED = 1000000 ' 1 MHz

30 SPI MPU READ 2 TO D 'Read 2 bytes into D

40 PRINT D

50 END

>run

 

> 

 

I have tried running the program in calculator mode.

>INSTALL "SPI-DEVICE" USING CORE.D10 AS MPU  ' for select

>MPU.SPEED = 1000000 ' 1 MHz

>SPI MPU WRITE 0xff READ 2 TO D 'Read 2 bytes into D

>PRINT D

 

> 
 

Converting D to a number returns a NaN error as if D is a blank string.

>PRINT VAL D

nan

>PRINT VAL ""

nan

 

I have tried using the SenseCore board:

>10 INSTALL "SOLDERCORE-SENSECORE ADDR=0x42" AS SENSECORE

>20 ' Install a generic SPI device.  We're using SenseCore slot D

>40 INSTALL "SPI-DEVICE" USING SENSECORE.D AS MPU

>50 MPU.SPEED = 1000000 ' 1 MHz

>60 SPI MPU WRITE 0xff READ 2 TO D 'Read 2 bytes into D

>70 PRINT D

>80 END

>run

 

> 

I have tried reverting back from firmware version 1.3.5 to 1.0.0, a second soldercore board,  different clock speeds, different SeXI sites on the SenseCore, Number of read bytes (2, 10, 100, 1000), Variable names for the read bytes to be deposited in etc (From D to DOP etc). The result is always the same? Has anyone else had similar problems?

Paul Curtis

unread,
Jul 24, 2014, 9:45:17 AM7/24/14
to solde...@googlegroups.com
Hi,

No.  It’s returned as a 2-byte string, so you can use

PRINT HEX EXPAND D

This will show you, printable, what the two bytes are.

 
I have tried using the SenseCore board:
>10 INSTALL "SOLDERCORE-SENSECORE ADDR=0x42" AS SENSECORE
>20 ' Install a generic SPI device.  We're using SenseCore slot D
>40 INSTALL "SPI-DEVICE" USING SENSECORE.D AS MPU
>50 MPU.SPEED = 1000000 ' 1 MHz
>60 SPI MPU WRITE 0xff READ 2 TO D 'Read 2 bytes into D
>70 PRINT D
>80 END
>run
 
> 
I have tried reverting back from firmware version 1.3.5 to 1.0.0, a second soldercore board,  different clock speeds, different SeXI sites on the SenseCore, Number of read bytes (2, 10, 100, 1000), Variable names for the read bytes to be deposited in etc (From D to DOP etc). The result is always the same? Has anyone else had similar problems?


Use PRINT HEX EXPAND D to see what’s received!

— Paul.

Chris Blowfield

unread,
Jul 24, 2014, 10:43:45 AM7/24/14
to solde...@googlegroups.com
Thanks Paul!
That works for me. Chris
 

>10 INSTALL "SPI-DEVICE" USING CORE.D10 AS MPU  ' for select

>20 MPU.SPEED = 1000000 ' 1 MHz

>30 SPI MPU WRITE 0xff READ 2 TO D 'Read 2 bytes into D

>40 PRINT HEX EXPAND D

>50 END

>run

["00", "00"] -When MISO connected to 0V

>run

["FF", "FF"] -When MISO connected to +3.3V

Reply all
Reply to author
Forward
0 new messages