hi
Thanks for the replies.
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src
Sub Process_Globals
Public Serial1 As Serial
Public CSPin As Pin
Dim n As Byte
Dim ab As Byte 'address byte
ab=0x0C
Dim hb As Byte 'high byte
Dim mb As Byte 'mid byte
Dim lb As Byte 'low byte
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
CSPin.Initialize(10, CSPin.MODE_OUTPUT) 'I am using pin 10 for CS
SPI.CSPinDeActivate(CSPin)
'CSPin.DigitalWrite(True)
For n=1 To 255
CommunicateThroughSPI
Delay(1000)
Next
End Sub
Private Sub CommunicateThroughSPI
Delay(10)
SPI.CSPinActivate(CSPin)
'CSPin.DigitalWrite(False)
SPI.Begin_Transaction(2000000, SPI.MSBFIRST, SPI.SPI_MODE0)
Delay(10)
SPI.Transfer_Byte(ab) 'Address byte
Delay(10)
hb = SPI.Transfer_Byte(0) 'HB SPI.Transfer_Byte(x) tried x=0 to x=255
Delay(10)
mb = SPI.Transfer_Byte(0) 'MB
Delay(10)
lb = SPI.Transfer_Byte(0) 'LB
Delay(10)
Log("Returned:")
Log(hb)
Log(mb)
Log(lb)
'CSPin.DigitalWrite(True)
SPI.End_Transaction
SPI.CSPinDeActivate(CSPin)
End Sub
Boards I have tried :-
Arduino uno ) For Arduino boards I stuck with the H/W pins which I know work with other BASICS and Adafruit library
Arduino nano )
SS/CS=10 MOSI=11 MISO=12 CLK=13
Wemos ESP8266 D1 R1 )
Wemos ESP32 D1 R32 )
ESP WROOM 32 ) this board has VSPI & HSPI (TRIED BOTH)
Tried:-
SS/CS =5 MOSI=23 MISO=19 SCK =14
SS/CS =10 MOSI=11 MISO=12 SCK =13
SS/CS =15 MOSI=13 MISO=12 SCK =14
SS/CS =10 MOSI= 7 MISO=6 SCK =3
And many other combinations and also tried different pins for CS - Does CS need to be held low with a pull down resister?
Yes I tried SPI.CSPinDeActivate(CSPin) in appstart. I have also tried setting CS directly CSPin.DigitalWrite(False)/CSPin.DigitalWrite(True)
I need to read 3x bytes the response from the MAX31856 is Send byte 0x0C (register address) returns HB (127) MID(255) LOW (255)
I have tried setting a loop to try different delays with each MODE but MODE change returns 0 .
I have not sent a bunch of bytes but will try.
I am using a purpose built breakout board suitable for 5v - as I mentioned the uno works fine with Adafruit_MAX31856.h library and Arduino IDE. To make sure I have just tried it again, working fine.
Thanks again