SPI communication between BX-24 and QT300 Capacitance converter

Started by stoifan.geo November 22, 2003
We have problems reading data from the QT300 to our BX24 over SPI.

We have the following setup:

pin BX24 pin QT300
12 /DRDY 1 /DRDY
SPI SCK 2 SCK
11 /REQ 6 /REQ
SPI MISO 7 SDO

The QT300 have a Max clock rate of 40kHz and data length of 2 bytes.

We use the example code from EasyOpenSPI.bas from the file area here,
and then try to read 2 bytes. Is the setup correct or should we use
other connections? Is the code correct?

Thankful for all help and tips!

' Example of SPI on channel 2 with clock rate no greater than 40 kHz.
Channel = 2
ChipSelectPin = 11
LSBFirst = False
ClockPolarity = False
ClockPhase = False
MaxClockRate = 40000 ' Hz

Call SPIOpenChannel(Channel, ChipSelectPin, LSBFirst, ClockPolarity, _
ClockPhase, MaxClockRate)

Dim PutData as Byte
Dim GetData(1 to 2) as Byte, H as Byte, L as Byte
Dim DRDY as Byte

Do
Debug.Print "Requesting data..."
Call PutPin(11, 0) ' Request data from QT300 with /REQ
Call Sleep(1) ' Sleep 2ms

DRDY = GetPin(12)
Debug.Print "DRDY: ";CStr(DRDY)
If (DRDY = CByte(0)) Then
Debug.Print "2. DRDY"

Call SPICmd(2, 0, PutData, 2, GetData(1))' Get two bytes
H = GetData(1)
L = GetData(2)

Debug.Print "MSB: ";CStr(H)

End If
Loop


We have problems reading data from the QT300 to our BX24 over SPI.

We have the following setup:

pin BX24 pin QT300
12 /DRDY 1 /DRDY
SPI SCK 2 SCK
11 /REQ 6 /REQ
SPI MISO 7 SDO

The QT300 have a Max clock rate of 40kHz and data length of 2 bytes.

We use the example code from EasyOpenSPI.bas from the file area here,
and then try to read 2 bytes. Is the setup correct or should we use
other connections? Is the code correct?

Thankful for all help and tips!

' Example of SPI on channel 2 with clock rate no greater than 40 kHz.
Channel = 2
ChipSelectPin = 11
LSBFirst = False
ClockPolarity = False
ClockPhase = False
MaxClockRate = 40000 ' Hz

Call SPIOpenChannel(Channel, ChipSelectPin, LSBFirst, ClockPolarity, _
ClockPhase, MaxClockRate)

Dim PutData as Byte
Dim GetData(1 to 2) as Byte, H as Byte, L as Byte
Dim DRDY as Byte

Do
Debug.Print "Requesting data..."
Call PutPin(11, 0) ' Request data from QT300 with /REQ
Call Sleep(1) ' Sleep 2ms

DRDY = GetPin(12)
Debug.Print "DRDY: ";CStr(DRDY)
If (DRDY = CByte(0)) Then
Debug.Print "2. DRDY"

Call SPICmd(2, 0, PutData, 2, GetData(1))' Get two bytes
H = GetData(1)
L = GetData(2)

Debug.Print "MSB: ";CStr(H)

End If
Loop