FUTEK QIA128 SPI Communication Instructions

June 10, 2024
FUTEK

FUTEK QIA128 SPI Communication

General Description

The QIA128 is a single channel ultra-low power digital controller with UART and SPI outputs. The QIA128 (slave device) can be used to communicate with any master devices through an SPI bus.

Pin Configurations and Function Descriptions for QIA128

FUTEK-QIA128-SPI-Communication-1 Table 1

__

#

| __

Pin

| __

Description

| __

J1 #

---|---|---|---
| RESET| Active low reset pin.| –
2| TMS| JTAG TMS (Test Mode Select). Input pin used for debug and download.| –
3| TX| Transmit Asynchronous Data output.| 7
4| RX| Receive Asynchronous Data input.| 6
5| GND| Ground pins are connected to each other internally.| 1
---|---|---|---
6| -Excitation| Sensor excitation return (connected to Ground).| 2
7| -Signal| Sensor negative Input.| 5
8| +Excitation| Sensor excitation.| 3
9| +Signal| Sensor positive Input.| 4
10| VIN| Voltage input 3 − 5| 9
11| CS| __

Active low chip-select. Do not drive the line low until the device has booted up

completely. Also ensure that the line is not driven low unless the � **** is low.

| 14
12| SCLK| Serial clock generated by master.| 13
13| MISO| Master-In-Slave-Out.| 12
14| MOSI| Master-Out-Slave-In.| 11
__

__

__

__

15

| __

__

__

__

DRDY

| __

Active low pin is used to keep all communication synchronized. It notifies the master device when new data from the sampling system is ready. This ensures that the master is always collecting the latest data. When the pin goes low, it indicates that the data is ready to be clocked out. This pin can be used to externally interrupt the master. The pin returns high when the system is in a conversion state and returns low once new data is ready.

* _Note:_** The pin does not return high once data is read—it will only return high once the system enters a conversion

state.

| __

__

__

__

16| VDD| Digital rail (2.5V).| –
17| NTRST| JTAG NTRST/BM Reset/Boot Mode. Input pin used for debug and download only and boot mode (��� ).| –
18| TDO| JTAG TDO (Data Out). Input pin used for debug and download.| –
19| TDI| JTAG TDI (Data In). Input pin used for debug and download.| –
20| TCK| JTAG TCK (Clock Pin). Input pin used for debug and download.| –

QIA128 SPI Configuration
TABLE 2
Serial Word Length 8-Bit
SPI Mode Mode 0 (CPOL = 0, CPHA = 0)
SCLK Frequency Min
Internal Clock Frequency of MCU 10.24 MHz
Operation Mode Slave
Voltage Level 1.8 VDC (compatible with 3.3 VDC)
QIA128 Internal Design Algorithm

When the DRDY pin goes high, it means the device is in the process of A/D conversion, calculating the CRC8 (See CRC Calculations and References) and generating the packet that needs to be sent per the master device’s request. DRDY goes low as soon as it fills out the SPI TX buffer. The following algorithm is being executed while DRDY is high:

  • Receives the latest ADC data from the highest interrupt priority
  • Slave Service Function
    • Keeps reading the RX FIFO until it is empty
    • Saves all the bytes in a software buffer
    • If the buffer is empty, creates a mock-up GADC command to go to the default state
    • Checks the CRC8 byte and CMD byte
    • If either the CRC8 or the CMD are incorrect
  • Goes to the default state
    • Else
  • Replies with the corresponding packet (See Table 5.)
    • Default State:
  • Restarts the SPI module
  • Calculates the CRC8
  • Loads 4 bytes of data (including the latest ADC data and the CRC8 byte) into the TX FIFO buffer
  • DRDY goes low

It is important to note that when a packet is clocked into the QIA128 via the MOSI line, the response to that packet must be clocked out in the very next DRDY period. If it is not clocked out in the next DRDY period, the response will be lost, and the system will go back to clocking out the ADC data.

SPI Packet Structure

The packet structure stays consistent during all transactions and always includes four bytes of data for both receiving and transmitting.

“Continuous Read” Mode

GADC Command may be sent for each DRDY period to continuously get the ADC data.

  • Note : If the CRC or the CMD bytes are incorrect, the device still fills out the buffer with the ADC data followed by the CRC8.

Timing Diagrams

Packet Structure (Get ADC Data):

FUTEK-QIA128-SPI-Communication-3 * Note : Each clock in Figure 3. represents 8-bits.

  • Note : Each word (8-bits) can be clocked out with or without delay, but the entire transaction must be completed within a single DRDY period.

DRDY Period:

FUTEK-QIA128-SPI-Communication-4 Table 3.

(µ) () (µ) Description
  240   4 SPS
  55   20 SPS
  19   50 SPS
0 to …* 9 125 100 SPS
4.5   200 SPS
  1.5   500 SPS
  1.1   850 SPS
  0.6   1300 SPS
  • Note : No delay or any delay as long as all 4 bytes are clocked out prior to DRDY going high. (See 2 )

System Behavior

Start-up
When the system powers ON, it starts reading data from the internal flash and the solid green LED lights up; this
represents normal operation mode.

  • Note : Do not drive the line low until the device has booted up completely. Also ensure that the line is not driven low unless the DRDY is low. The DRDY line goes low as soon as the first data is ready to be clocked out.

Sampling Rate Change
When a sampling rate change is requested, it will take certain amount of time (depends on the requested sampling rate) to
see the change in the DRDY period. (See Table 4.)

Table 4.

Maximum Approximate data rate change timing ()| SR Code| Sampling Rate
---|---|---
__

__

__

__

250

| 0x00| 4 SPS
0x01| 20 SPS
0x02| 50 SPS
0x03| 100 SPS
0x04| 200 SPS
0x05| 500 SPS
0x06| 850 SPS
0x07| 1300 SPS

Command-Set List

Table 5.

__

__

__

__

Type

| __

__

__

__

Name

| __

__

__

__

Description

| MOSI Line Packet Structure (Master to QIA128)| MISO Line Packet Structure (QIA128 to Master)
---|---|---|---|---
 |  | __

CMD

| __

CRC

| __

Payload

| __

Payload

| __

Payload

| __

CRC

__

Byte 0

| __

Byte 1

| __

Byte 2

| __

Byte 3

| __

Byte 0

| __

Byte 1

| __

Byte 2

| __

Byte 3

__

Get

| __

GADC

| __

Get ADC Data

| __

0xXX

| __

0xXX

| __

0x00

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP0

| __

Get Calibration Point Zero

| __

0xXX

| __

0xXX

| __

0x01

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP1

| __

Get Calibration Point One

| __

0xXX

| __

0xXX

| __

0x02

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP2

| __

Get Calibration Point Two

| __

0xXX

| __

0xXX

| __

0x03

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP3

| __

Get Calibration Point Three

| __

0xXX

| __

0xXX

| __

0x04

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP4

| __

Get Calibration Point Four

| __

0xXX

| __

0xXX

| __

0x05

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP5

| __

Get Calibration Point Five

| __

0xXX

| __

0xXX

| __

0x06

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP6

| __

Get Calibration Point Six

| __

0xXX

| __

0xXX

| __

0x07

| __

CRC8

| __

ADC MSB

| __

ADC Byte 1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP7

| __

Get Calibration Point Seven

| __

0xXX

| __

0xXX

| __

0x08

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

---|---|---|---|---|---|---|---|---|---|---
__

Get

| __

GCP8

| __

Get Calibration Point Eight

| __

0xXX

| __

0xXX

| __

0x09

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP9

| __

Get Calibration Point Nine

| __

0xXX

| __

0xXX

| __

0x0A

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP10

| __

Get Calibration Point Ten

| __

0xXX

| __

0xXX

| __

0x0B

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP11

| __

Get Calibration Point Eleven

| __

0xXX

| __

0xXX

| __

0x0C

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP12

| __

Get Calibration Point Twelve

| __

0xXX

| __

0xXX

| __

0x0D

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP13

| __

Get Calibration Point Thirteen

| __

0xXX

| __

0xXX

| __

0x0E

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP14

| __

Get Calibration Point Fourteen

| __

0xXX

| __

0xXX

| __

0x0F

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP15

| __

Get Calibration Point Fifteen

| __

0xXX

| __

0xXX

| __

0x10

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP16

| __

Get Calibration Point Sixteen

| __

0xXX

| __

0xXX

| __

0x11

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP17

| __

Get Calibration Point Seventeen

| __

0xXX

| __

0xXX

| __

0x12

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP18

| __

Get Calibration Point Eighteen

| __

0xXX

| __

0xXX

| __

0x13

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP19

| __

Get Calibration Point Nineteen

| __

0xXX

| __

0xXX

| __

0x14

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

__

Get

| __

GCP20

| __

Get Calibration Point Twenty

| __

0xXX

| __

0xXX

| __

0x15

| __

CRC8

| __

ADC MSB

| __

ADC Byte1

| __

ADC LSB

| __

CRC8

Get

|

GCP21

|

Get Calibration Point Twenty-One

|

0xXX

|

0xXX

|

0x16

|

CRC8

|

ADC MSB

|

ADC Byte1

|

ADC LSB

|

CRC8

---|---|---|---|---|---|---|---|---|---|---

Get

|

GCP22

|

Get Calibration Point Twenty-Two

|

0xXX

|

0xXX

|

0x17

|

CRC8

|

ADC MSB

|

ADC Byte1

|

ADC LSB

|

CRC8

Get

|

GSSN

|

Get Sensor Serial Number

|

0xXX

|

0xXX

|

0x18

|

CRC8

|

SSN MSB

|

SSN Byte1

|

SSN LSB

|

CRC8

Get

|

GISN

|

Get Instrument Serial Number

|

0xXX

|

0xXX

|

0x19

|

CRC8

|

ISN MSB

|

ISN Byte1

|

ISN LSB

|

CRC8

Get

|

GFRN

|

Get Firmware Revision Number

|

0xXX

|

0xXX

|

0x1A

|

CRC8

|

Major

|

Minor

|

Patch

|

CRC8

Get

|

GDR

|

Get Data Rate

|

0xXX

|

0xXX

|

0x1B

|

CRC8

|

0x00

|

0x00

| SR Code (See

Table 4 .)

|

CRC8

Set

|

S4SPS

|

Set 4 Sample Per Second

|

0xXX

|

0xXX

|

0x1C

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S20SPS

|

Set 20 Sample Per Second

|

0xXX

|

0xXX

|

0x1D

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S50SPS

|

Set 50 Sample Per Second

|

0xXX

|

0xXX

|

0x1E

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S100SPS

|

Set 100 Sample Per Second

|

0xXX

|

0xXX

|

0x1F

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S200SPS

|

Set 200 Sample Per Second

|

0xXX

|

0xXX

|

0x20

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S500SPS

|

Set 500 Sample Per Second

|

0xXX

|

0xXX

|

0x21

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S850SPS

|

Set 850 Sample Per Second

|

0xXX

|

0xXX

|

0x22

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Get

|

GCP21

|

Get Calibration Point Twenty-One

|

0xXX

|

0xXX

|

0x16

|

CRC8

|

ADC MSB

|

ADC Byte1

|

ADC LSB

|

CRC8

---|---|---|---|---|---|---|---|---|---|---

Get

|

GCP22

|

Get Calibration Point Twenty-Two

|

0xXX

|

0xXX

|

0x17

|

CRC8

|

ADC MSB

|

ADC Byte1

|

ADC LSB

|

CRC8

Get

|

GSSN

|

Get Sensor Serial Number

|

0xXX

|

0xXX

|

0x18

|

CRC8

|

SSN MSB

|

SSN Byte1

|

SSN LSB

|

CRC8

Get

|

GISN

|

Get Instrument Serial Number

|

0xXX

|

0xXX

|

0x19

|

CRC8

|

ISN MSB

|

ISN Byte1

|

ISN LSB

|

CRC8

Get

|

GFRN

|

Get Firmware Revision Number

|

0xXX

|

0xXX

|

0x1A

|

CRC8

|

Major

|

Minor

|

Patch

|

CRC8

Get

|

GDR

|

Get Data Rate

|

0xXX

|

0xXX

|

0x1B

|

CRC8

|

0x00

|

0x00

| SR Code (See

Table 4 .)

|

CRC8

Set

|

S4SPS

|

Set 4 Sample Per Second

|

0xXX

|

0xXX

|

0x1C

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S20SPS

|

Set 20 Sample Per Second

|

0xXX

|

0xXX

|

0x1D

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S50SPS

|

Set 50 Sample Per Second

|

0xXX

|

0xXX

|

0x1E

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S100SPS

|

Set 100 Sample Per Second

|

0xXX

|

0xXX

|

0x1F

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S200SPS

|

Set 200 Sample Per Second

|

0xXX

|

0xXX

|

0x20

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S500SPS

|

Set 500 Sample Per Second

|

0xXX

|

0xXX

|

0x21

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

Set

|

S850SPS

|

Set 850 Sample Per Second

|

0xXX

|

0xXX

|

0x22

|

CRC8

|

0x00

|

0x00

|

0x00

|

CRC8

  • Note : 0xXX = Don’t care
  • Note : All pre-defined responses from each command that is sent on the MOSI line should be expected in the next DRDY period.

Packet and CRC Examples

The following transaction is the response to the GSSN command (Get Sensor Serial Number) that is being clocked out with the GADC command (Get ADC Data):

FUTEK-QIA128-SPI-Communication-5u8 crc8(u8 *p, u8 len); function (See CRC Calculations and References) has been used as a reference to calculate the CRC for the example above:
// CRC calculation for the MISO transaction, MSB = 0x01 and LSB = 0x40
u8 BUFFER[] = {MSB,…,LSB} »»» u8 BUFFER[] = {0x01, 0xE2, 0x40};
u8 crc8(BUFFER, 3);
then function returns 0xC5

ADC Data Conversion

The following formula could be used to convert the raw ADC data:

FUTEK-QIA128-SPI-Communication-6Here are the variables:

  • DCVALUE= = the most recent analog-to-digital conversion value.
  • OFFSETVALUE= = the analog-to-digital conversion value stored during calibration that corresponds to the offset (zero physical load).
  • FULLSCALEVALUE= the analog-to-digital conversion value stored during calibration that corresponds to the full scale (maximum physical load)
  • FULL SCA LOAD= the numeric value stored during calibration for the maximum physical load.
ADC Data Conversion Example

Calibration Data:
OffsetValue = Get Calibration Point Zero (GCP0): 8000000 (0x7A1200)
FullScaleValue = Get Calibration Point Five (GCP5): 12000000 (0xB71B00)
FullScaleLoad = 20 lb
ADCValue: Get ADC Data (GADC): 10552731 (0xA1059B)

FUTEK-QIA128-SPI-Communication-7

Firmware Revision

Firmware Notes

New Features

  • Added new commands
    • GND (Get Number of Directions)
    • GNLP (Get Number of Loading Points)
  • Replaced CRC16 by CRC8
  • Package length has been decreased from 6 to 4

Changes

  • LED indicator is changed from blinking to solid
  • SPI command numbers are changed

Fixes: N/A

CRC Calculations and References

crc8.h example:

  • extern uint8_t const crc_table[256];
  • uint8_t crc8(uint8_t *p, uint8_t len);

crc8.c example:

uint8_t const crc_table[256] = { 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xd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d, 0xf4, 0xf3
};
// ————————————————————————————————-
uint8_t crc8(uint8_t p, uint8_t len){
uint16_t i;
uint16_t crc = 0x0;
while (len–) {
i = (crc ^
p++) & 0xFF;
crc = (crc_table[i] ^ (crc << 8)) & 0xFF;
}
return crc & 0xFF;
}//end crc8()

Sensor Solution Source
Load • Torque • Pressure • Multi Axis • Calibration • Instruments • Software

www.futek.com

Read User Manual Online (PDF format)

Read User Manual Online (PDF format)  >>

Download This Manual (PDF format)

Download this manual  >>

Related Manuals