NBP8s integration with Vector system

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NBP8s integration with Vector system

161 Views
goodguy94
Contributor I

Hello evreyone ,

I am trying to integrate NBP8s pressure sensor with vector system. VT2710 sensor module has SPI interface.

Has anyone tried this integration before ? Would love to know your suggestions. I am not able to get proper and valid response from the sensor. 

CAPL script i wrote :

/*@!Encoding:1252*/

variables
{
/* IO buffers, timers */
byte txBuffer[2];
msTimer tMain, tSpi, tDelay;

/* Main state machine */
int mainState = 0;
word curFrame;
int intAsserted, b_INTF;
int s4, s3, s2, s1, s0;

/* Micro-FSM for SPI transaction */
enum Spiop {OP_NONE = 0, OP_RD=1, OP_WR=2};
enum Spisub {IDLE=0, TX1=10, RX1=11, TX2=12, RX2=13};
int tr_op , spiSub;

word tr_addr = 0;
byte tr_wdata = 0;
byte tr_rdata = 0;
int tr_retry = 0; // bounded retry count (faults)
int needDummy = 1; // after WAKE/CS glitch or any detected fault

/* SPI response */
byte misoHi = 0, misoLo = 0;
word spiResp = 0;

/* Cached registers (live mirror) */
byte regSPIOPS = 0;
byte spiops_base = 0;
int spiops_base_valid = 0;

/* INT edge auto-detect */
int lastIntLevel = -1;
int Idle;
int active_IntPol = 0; // bit 5 of INTTRIG
int intLevel = 0;
int USE_READY_GATE = 1; // 0 - off (default) , 1 - on (real HW)

/* device asserts READY when it s safe to transact. */
int startupWaitDone = 0;

/* Optional: last decoded flags */
byte status, data;
word msb, lsb, msb_addr, lsb_addr;

/* Register Addresses */
word ADDR_SPIOPS = 0x0038; // [2]=CORE_TR_HOLD, [1:0]=FLASH_RANGE ; [7:3] reserved

/* Firmware/HW derivative/version windows (via SPIOPS) */
word ADDR_FW_DERIV = 0x0805; // valid when SPIOPS FLASH_RANGE == 00 (0x04)
word ADDR_FW_VER = 0x0804;
word ADDR_HW_DERIV = 0x1542; // valid when SPIOPS FLASH_RANGE == 11 (0x07)
word ADDR_HW_VER = 0x1543;
}

/* SPI frame builder
p1 covers bits b15..b9, p0 covers b8..b2, both even parity. */
/* Build a 16-bit SPI frame per NBP8S protocol:
- bit15: R/W (1=write, 0=read)
- bits14..2: address / data field
- bits1..0: parity bits (even parity on bits15..9 and bits8..2) */

word makeNbp8sFrame(int rw, word addr_or_data)
{
word f = 0;
int group1, group2, p1, p0;

if (spiSub == TX1) {
/* TX1: Address frame 13-bit address */
f = ((rw & 1) << 15) | ((addr_or_data & 0x1FFF) << 2);

} else {
/* TX2: Data frame or dummy 8-bit data in bits9..2 */
f = ((rw & 1) << 15) | ((addr_or_data & 0xFF) << 2);
}

write("[makeFrame] RAW Frame (no parity) = 0x%04X", f);

/* --- Inline parity logic (same as computeParity, no countBits) --- */
group1 = (f >> 9) & 0x7F; // bits 15..9
group2 = (f >> 2) & 0x7F; // bits 8..2

// count ones manually
p1 = 0; p0 = 0;
while (group1) { if (group1 & 1) p1++; group1 >>= 1; }
while (group2) { if (group2 & 1) p0++; group2 >>= 1; }

p1 = (p1 & 1) ; // even parity for group1
p0 = (p0 & 1) ; // even parity for group2

f &= 0xFFFC; // clear bits1..0
f |= ((p1 << 1) | p0); // set parity bits

write("[makeFrame] Final frame = 0x%04X", f);
return f;
}

/* Status & fault logging */
void logSpiStatus(word r)
{
s4 = (r >> 14) & 1;
s3 = (r >> 13) & 1;
s2 = (r >> 12) & 1;
s1 = (r >> 11) & 1;
s0 = (r >> 10) & 1;

status = (r >> 10) & 0x1F;
data = (r >> 2) & 0xFF;

write("[SPI Status Bits] s4=%d s3=%d s2=%d s1=%d s0=%d | Full Response=0x%04X", s4, s3, s2, s1, s0, r);
write("[SPI Decoded] Status=0x%02X Data=0x%02X", status, data);

if (s4) write("Fault: Reserved fault (undefined)");
if (s3) write("Fault: Ignored command or invalid previous read");
if (s2) write("Fault: Clock error");
if (s1) write("Fault: Parity error");
if (s0) write("Fault: Bus contention or illegal access");
}


/* (s4..s0 any non-zero indicates an issue). */
int hasFault(word r)
{
return (((r >> 14) & 1) || ((r >> 13) & 1) || ((r >> 12) & 1) || ((r >> 11) & 1) || ((r >> 10) & 1));
}

/* Queue a 16-bit frame on MOSI (CS low is driven here) */


void sendFrame(word frame16)
{
txBuffer[0] = (byte)(frame16 >> 8);
txBuffer[1] = (byte)(frame16 & 0xFF);
sensorQueueMosiData("SENSOR::SPI::Master_Port::NBP_Sensor", txBuffer, 16);
}

/* High-level: schedule a READ/WRITE op */

void spiReadByte(word addr)
{
tr_addr = addr;
tr_op = OP_RD;
tr_retry= 0;
spiSub = TX1;
setTimer(tSpi, 1);
}

void spiWriteByte(word addr, byte data)
{
tr_addr = addr;
tr_wdata = data;
tr_op = OP_WR;
tr_retry= 0;
spiSub = TX1;
setTimer(tSpi, 1);
}


/* SPI Micro-FSM */
on timer tSpi
{
switch (spiSub)
{

/* TX1 */
case TX1:

@VTS::VT2710_1_DIO_Ch2::DigitalOutput6 = 0 ; // CS low

if (USE_READY_GATE && (tr_addr != ADDR_SPIOPS))
{
intAsserted = (active_IntPol ? (intLevel == 1) : (intLevel == 0));
if( b_INTF && !intAsserted)
{
write("[SPI] Waiting for READY before first TX1 - Sensor initiated");
setTimer(tSpi, 1);
break;
}
}


curFrame = needDummy ? makeNbp8sFrame(0, 0x0000): makeNbp8sFrame((tr_op == OP_WR) ? 1 : 0, tr_addr);

write("[TX1] Master --> Sensor: Frame = 0x%04X (R/W=%d Addr=0x%04X)",curFrame, (curFrame >> 15) & 1, (curFrame >> 2) & 0x1FFF);
sendFrame(curFrame);
spiSub = RX1;
setTimer(tSpi, 1);
break;

/* RX1 (R0 after TX1) */
case RX1:
misoHi = @sensor::SPI::Master_Port::NBP_Sensor::Frame1.MISO_Signals.MISO_High_byte;
misoLo = @sensor::SPI::Master_Port::NBP_Sensor::Frame1.MISO_Signals.MISO_Low_byte;
spiResp = ((word)misoHi << | misoLo;
write("[RX1] Sensor --> Master: Response = 0x%04X (Status=0x%02X Data=0x%02X)",spiResp, (spiResp >> 10) & 0x1F, (spiResp >> 2) & 0xFF);
if (needDummy) {
needDummy = 0;
spiSub = TX1;
setTimer(tSpi, 1);
break;
}

// correct fault handling
logSpiStatus(spiResp);
if(tr_addr != ADDR_SPIOPS)
{
s4 = (spiResp >> 14) & 1;
s3 = (spiResp >> 13) & 1;
s2 = (spiResp >> 12) & 1;
s1 = (spiResp >> 11) & 1;
s0 = (spiResp >> 10) & 1;

if (s2) { // Clock fault
if (tr_retry < 4) {
write("[SPI] Clock fault: dummy+retry");
needDummy = 1; tr_retry++;
spiSub = TX1; setTimer(tSpi, 5);
break;
}

tr_op = OP_NONE;
spiSub = IDLE;
break;
}

if (s3 || s4) {
write("[SPI] Fatal fault (Reserved/Previous read/write) error, aborting transfer");

tr_op = OP_NONE;
spiSub = IDLE;
break;
}

if (s1 || s0) {
if (tr_retry < 4) {
write("[SPI] SPI fault (s1/s0) : dummy+retry");
needDummy = 1;
tr_retry++;
spiSub = TX1;
setTimer(tSpi, 1);
break;
}

tr_op = OP_NONE;
spiSub = IDLE;
break;
}
}

if (tr_op == OP_WR) {
curFrame = makeNbp8sFrame(1, tr_wdata);
write("[TX2] Master --> Sensor: Data Frame = 0x%04X", curFrame);
sendFrame(curFrame);
spiSub = RX2;
setTimer(tSpi, 5);
break;
}

/* For READs send dummy frame */
else if (tr_op == OP_RD) {
curFrame = makeNbp8sFrame(0, 0x0000);
write("[TX2] Master --> Sensor: Dummy Frame = 0x%04X", curFrame);
sendFrame(curFrame);
spiSub = RX2;
setTimer(tSpi, 1);
break;
}

/* TX2 */
case TX2:
spiSub = RX2;
setTimer(tSpi, 1);
break;

/* RX2 (R1: DATA for READ, STATUS for WRITE) */
case RX2:

misoHi = @sensor::SPI::Master_Port::NBP_Sensor::Frame1.MISO_Signals.MISO_High_byte;
misoLo = @sensor::SPI::Master_Port::NBP_Sensor::Frame1.MISO_Signals.MISO_Low_byte;
spiResp = ((word)misoHi << | misoLo;
@VTS::VT2710_1_DIO_Ch2::DigitalOutput6 = 1 ; // CS high
setTimer(tDelay, 10);
write("[RX2] Sensor --> Master: Response = 0x%04X (Status=0x%02X Data=0x%02X)",spiResp, (spiResp >> 10) & 0x1F, (spiResp >> 2) & 0xFF);

logSpiStatus(spiResp); // correct fault handling */
if(tr_addr != ADDR_SPIOPS)
{
s4 = (spiResp >> 14) & 1;
s3 = (spiResp >> 13) & 1;
s2 = (spiResp >> 12) & 1;
s1 = (spiResp >> 11) & 1;
s0 = (spiResp >> 10) & 1;

if (s2) { // Clock fault
if (tr_retry < 4) {
write("[SPI] Clock fault: dummy+retry");
needDummy = 1;
tr_retry++;
spiSub = TX1;
setTimer(tSpi, 1);
break;
}
tr_op = OP_NONE;
spiSub = IDLE;
break;
}

if (s3 || s4) {
write("[SPI] Fatal fault (parity/contend), aborting transfer");
tr_op = OP_NONE;
spiSub = IDLE;
break;
}

if (s1 || s0) {
if (tr_retry < 4) {
write("[SPI] SPI fault (s1/s0) : dummy+retry");
needDummy = 1;
tr_retry++;
spiSub = TX1;
setTimer(tSpi, 1);
break;
}
tr_op = OP_NONE;
spiSub = IDLE;
break;
}
}
if (tr_op == OP_RD)
tr_rdata = (spiResp >> 2) & 0xFF;

tr_op = OP_NONE;
spiSub = IDLE;
setTimer(tDelay, 1);
break;
}
}

/* Utility */
int spiBusy() { return (tr_op != OP_NONE) || (spiSub != IDLE); }

/* Start */
on start
{
write("NBP8s Evaluation");
setTimer(tDelay,38);

needDummy = 1; /* first transfer dummy after WAKE/CS glitch */
mainState = 0;
tr_op = OP_NONE;
spiSub = IDLE;
startupWaitDone = 1;
setTimer(tMain, 35);
}

/* tDelay yields back to main */
on timer tDelay
{
setTimer(tMain, 5);
}

/* Main FSM */
on timer tMain
{
setTimer(tMain, 1);

/* State machine */
switch (mainState)
{
/* SPIOPS handshake */
case 0:
if (spiBusy()) break;
// If a dummy is pending (e.g. after reset/fault), consume it
write("SPIOPS - Dummy frame to clear start up");

// @VTS::VT2710_1_DIO_Ch2::DigitalOutput6 = 0; // CS low
// setTimer(tDelay, 2);
// @VTS::VT2710_1_DIO_Ch2::DigitalOutput6 = 1; // CS high
// setTimer(tDelay, 5);

spiReadByte(0x0000); // dummy frame (ignored by device)
setTimer(tDelay,5);

needDummy = 0;
setTimer(tDelay,5);
mainState = 1;
break;

case 1:
if (spiBusy()) break;
write("SPIOPS - SENSOR Ready , proceeding to write");
spiWriteByte(ADDR_SPIOPS, 0x04); // write SPIOPS = 0x04
setTimer(tDelay,5);
mainState = 2;
break;

case 2:
if (spiBusy()) break;
spiReadByte(ADDR_SPIOPS); // read back SPIOPS
setTimer(tDelay, 5);
mainState = 3;
break;

case 3:
if (spiBusy()) break;
mainState = 4;
break;

case 4:
if (spiBusy()) break;

// Use tr_rdata (captured byte) instead of spiResp bits
regSPIOPS = (byte)(tr_rdata & 0x07);

// If HOLD active and range 00 -> SPIOPS must be 0x04
if (regSPIOPS == 0x04) {
write("SPIOPS: SET OK (0x%02X)", regSPIOPS);
mainState = 10; // go to FW/HW read
}
else {
write("SPIOPS NOT READY (SPIOPS = 0x%02X) --> retrying", regSPIOPS);
needDummy = 1;
setTimer(tDelay,5);
mainState = 1 ;
}
break;

/* FW / HW READ SEQUENCE */
case 10:
if (spiBusy()) break;
write("SPIOPS already set to 0x04 --> Firmware window active");
write("Reading FW_DERIV (0x0805)...");
spiReadByte(ADDR_FW_DERIV);
setTimer(tDelay, 5);
mainState = 11;
break;

case 11:
if (spiBusy()) break;
write("FW_DERIV = 0x%02X", tr_rdata);
write("Reading FW_VER (0x0804)...");
spiReadByte(ADDR_FW_VER);
setTimer(tDelay, 5);
mainState = 12;
break;

case 12:
if (spiBusy()) break;
write("FW_VER = 0x%02X", tr_rdata);
setTimer(tDelay, 5);
mainState = 13;
break;

case 13:
if (spiBusy()) break;
write("Clearing SPIOPS (0x0038) to release NBP8s CPU");
spiWriteByte(ADDR_SPIOPS, 0x00);
setTimer(tDelay, 5);
mainState = 14;
break;

case 14:
if (spiBusy()) break;
write("FW read complete");
mainState = 99;
break;

case 99:
// Idle / stop
break;
}}

any suggestions and feedback would be helpful for further progress.

Best regards

Labels (1)
Tags (1)
0 Kudos
Reply
2 Replies

142 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hello Rajvishnu,

The NBP8 sensor uses SPI Mode 0 (CPOL=0, CPHA=0) with 16-bit frames and even parity on two groups of bits. Ensure your Vector VT2710 SPI settings match this. After WAKEUP or any CS_B glitch, the first SPI command is ignored due to a clock fault -> send a dummy frame first to clear the error. Always wait for the READY pin to assert before starting SPI transfers. This indicates the sensor is ready and its CPU is halted. Check that CS_B stays low for all 16 clock cycles per frame and that parity bits are correct. Handle fault bits (s4..s0) properly. If any are set, retry with a dummy frame. s3 (ignored command) also requires a retry. Clear the SPIOPS register at the end of the session to resume normal sensor operation. These steps usually resolve invalid responses during integration.

BRs, Tomas

0 Kudos
Reply

139 Views
goodguy94
Contributor I
Hi Tomas
Thanks a lot for the quick response. The configuration is exactly the same as defined in datasheet and i am following the same steps as you have outlined.

I try to set SPIOPS and the response from the sensor is 0x0220 and it stays the same for subsequent responses.
i am not sure if i am missing something.
Any thoughts on this ?

Best regards,'
Rajvishnu
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2246790%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ENBP8s%20integration%20with%20Vector%20system%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2246790%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20evreyone%20%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI%20am%20trying%20to%20integrate%20NBP8s%20pressure%20sensor%20with%20vector%20system.%20VT2710%20sensor%20module%20has%20SPI%20interface.%3CBR%20%2F%3E%3CBR%20%2F%3EHas%20anyone%20tried%20this%20integration%20before%20%3F%20Would%20love%20to%20know%20your%20suggestions.%20I%20am%20not%20able%20to%20get%20proper%20and%20valid%20response%20from%20the%20sensor.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3ECAPL%20script%20i%20wrote%20%3A%3C%2FP%3E%3CP%3E%2F*%40!Encoding%3A1252*%2F%3C%2FP%3E%3CP%3Evariables%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%2F*%20IO%20buffers%2C%20timers%20*%2F%3CBR%20%2F%3Ebyte%20txBuffer%5B2%5D%3B%3CBR%20%2F%3EmsTimer%20tMain%2C%20tSpi%2C%20tDelay%3B%3C%2FP%3E%3CP%3E%2F*%20Main%20state%20machine%20*%2F%3CBR%20%2F%3Eint%20mainState%20%3D%200%3B%3CBR%20%2F%3Eword%20curFrame%3B%3CBR%20%2F%3Eint%20intAsserted%2C%20b_INTF%3B%3CBR%20%2F%3Eint%20s4%2C%20s3%2C%20s2%2C%20s1%2C%20s0%3B%3C%2FP%3E%3CP%3E%2F*%20Micro-FSM%20for%20SPI%20transaction%20*%2F%3CBR%20%2F%3Eenum%20Spiop%20%7BOP_NONE%20%3D%200%2C%20OP_RD%3D1%2C%20OP_WR%3D2%7D%3B%3CBR%20%2F%3Eenum%20Spisub%20%7BIDLE%3D0%2C%20TX1%3D10%2C%20RX1%3D11%2C%20TX2%3D12%2C%20RX2%3D13%7D%3B%3CBR%20%2F%3Eint%20tr_op%20%2C%20spiSub%3B%3C%2FP%3E%3CP%3Eword%20tr_addr%20%3D%200%3B%3CBR%20%2F%3Ebyte%20tr_wdata%20%3D%200%3B%3CBR%20%2F%3Ebyte%20tr_rdata%20%3D%200%3B%3CBR%20%2F%3Eint%20tr_retry%20%3D%200%3B%20%2F%2F%20bounded%20retry%20count%20(faults)%3CBR%20%2F%3Eint%20needDummy%20%3D%201%3B%20%2F%2F%20after%20WAKE%2FCS%20glitch%20or%20any%20detected%20fault%3C%2FP%3E%3CP%3E%2F*%20SPI%20response%20*%2F%3CBR%20%2F%3Ebyte%20misoHi%20%3D%200%2C%20misoLo%20%3D%200%3B%3CBR%20%2F%3Eword%20spiResp%20%3D%200%3B%3C%2FP%3E%3CP%3E%2F*%20Cached%20registers%20(live%20mirror)%20*%2F%3CBR%20%2F%3Ebyte%20regSPIOPS%20%3D%200%3B%3CBR%20%2F%3Ebyte%20spiops_base%20%3D%200%3B%3CBR%20%2F%3Eint%20spiops_base_valid%20%3D%200%3B%3C%2FP%3E%3CP%3E%2F*%20INT%20edge%20auto-detect%20*%2F%3CBR%20%2F%3Eint%20lastIntLevel%20%3D%20-1%3B%3CBR%20%2F%3Eint%20Idle%3B%3CBR%20%2F%3Eint%20active_IntPol%20%3D%200%3B%20%2F%2F%20bit%205%20of%20INTTRIG%3CBR%20%2F%3Eint%20intLevel%20%3D%200%3B%3CBR%20%2F%3Eint%20USE_READY_GATE%20%3D%201%3B%20%2F%2F%200%20-%20off%20(default)%20%2C%201%20-%20on%20(real%20HW)%3C%2FP%3E%3CP%3E%2F*%20device%20asserts%20READY%20when%20it%20s%20safe%20to%20transact.%20*%2F%3CBR%20%2F%3Eint%20startupWaitDone%20%3D%200%3B%3C%2FP%3E%3CP%3E%2F*%20Optional%3A%20last%20decoded%20flags%20*%2F%3CBR%20%2F%3Ebyte%20status%2C%20data%3B%3CBR%20%2F%3Eword%20msb%2C%20lsb%2C%20msb_addr%2C%20lsb_addr%3B%3C%2FP%3E%3CP%3E%2F*%20Register%20Addresses%20*%2F%3CBR%20%2F%3Eword%20ADDR_SPIOPS%20%3D%200x0038%3B%20%2F%2F%20%5B2%5D%3DCORE_TR_HOLD%2C%20%5B1%3A0%5D%3DFLASH_RANGE%20%3B%20%5B7%3A3%5D%20reserved%3C%2FP%3E%3CP%3E%2F*%20Firmware%2FHW%20derivative%2Fversion%20windows%20(via%20SPIOPS)%20*%2F%3CBR%20%2F%3Eword%20ADDR_FW_DERIV%20%3D%200x0805%3B%20%2F%2F%20valid%20when%20SPIOPS%20FLASH_RANGE%20%3D%3D%2000%20(0x04)%3CBR%20%2F%3Eword%20ADDR_FW_VER%20%3D%200x0804%3B%3CBR%20%2F%3Eword%20ADDR_HW_DERIV%20%3D%200x1542%3B%20%2F%2F%20valid%20when%20SPIOPS%20FLASH_RANGE%20%3D%3D%2011%20(0x07)%3CBR%20%2F%3Eword%20ADDR_HW_VER%20%3D%200x1543%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%2F*%20SPI%20frame%20builder%3CBR%20%2F%3Ep1%20covers%20bits%20b15..b9%2C%20p0%20covers%20b8..b2%2C%20both%20even%20parity.%20*%2F%3CBR%20%2F%3E%2F*%20Build%20a%2016-bit%20SPI%20frame%20per%20NBP8S%20protocol%3A%3CBR%20%2F%3E-%20bit15%3A%20R%2FW%20(1%3Dwrite%2C%200%3Dread)%3CBR%20%2F%3E-%20bits14..2%3A%20address%20%2F%20data%20field%3CBR%20%2F%3E-%20bits1..0%3A%20parity%20bits%20(even%20parity%20on%20bits15..9%20and%20bits8..2)%20*%2F%3C%2FP%3E%3CP%3Eword%20makeNbp8sFrame(int%20rw%2C%20word%20addr_or_data)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eword%20f%20%3D%200%3B%3CBR%20%2F%3Eint%20group1%2C%20group2%2C%20p1%2C%20p0%3B%3C%2FP%3E%3CP%3Eif%20(spiSub%20%3D%3D%20TX1)%20%7B%3CBR%20%2F%3E%2F*%20TX1%3A%20Address%20frame%2013-bit%20address%20*%2F%3CBR%20%2F%3Ef%20%3D%20((rw%20%26amp%3B%201)%20%26lt%3B%26lt%3B%2015)%20%7C%20((addr_or_data%20%26amp%3B%200x1FFF)%20%26lt%3B%26lt%3B%202)%3B%3C%2FP%3E%3CP%3E%7D%20else%20%7B%3CBR%20%2F%3E%2F*%20TX2%3A%20Data%20frame%20or%20dummy%208-bit%20data%20in%20bits9..2%20*%2F%3CBR%20%2F%3Ef%20%3D%20((rw%20%26amp%3B%201)%20%26lt%3B%26lt%3B%2015)%20%7C%20((addr_or_data%20%26amp%3B%200xFF)%20%26lt%3B%26lt%3B%202)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Ewrite(%22%5BmakeFrame%5D%20RAW%20Frame%20(no%20parity)%20%3D%200x%2504X%22%2C%20f)%3B%3C%2FP%3E%3CP%3E%2F*%20---%20Inline%20parity%20logic%20(same%20as%20computeParity%2C%20no%20countBits)%20---%20*%2F%3CBR%20%2F%3Egroup1%20%3D%20(f%20%26gt%3B%26gt%3B%209)%20%26amp%3B%200x7F%3B%20%2F%2F%20bits%2015..9%3CBR%20%2F%3Egroup2%20%3D%20(f%20%26gt%3B%26gt%3B%202)%20%26amp%3B%200x7F%3B%20%2F%2F%20bits%208..2%3C%2FP%3E%3CP%3E%2F%2F%20count%20ones%20manually%3CBR%20%2F%3Ep1%20%3D%200%3B%20p0%20%3D%200%3B%3CBR%20%2F%3Ewhile%20(group1)%20%7B%20if%20(group1%20%26amp%3B%201)%20p1%2B%2B%3B%20group1%20%26gt%3B%26gt%3B%3D%201%3B%20%7D%3CBR%20%2F%3Ewhile%20(group2)%20%7B%20if%20(group2%20%26amp%3B%201)%20p0%2B%2B%3B%20group2%20%26gt%3B%26gt%3B%3D%201%3B%20%7D%3C%2FP%3E%3CP%3Ep1%20%3D%20(p1%20%26amp%3B%201)%20%3B%20%2F%2F%20even%20parity%20for%20group1%3CBR%20%2F%3Ep0%20%3D%20(p0%20%26amp%3B%201)%20%3B%20%2F%2F%20even%20parity%20for%20group2%3C%2FP%3E%3CP%3Ef%20%26amp%3B%3D%200xFFFC%3B%20%2F%2F%20clear%20bits1..0%3CBR%20%2F%3Ef%20%7C%3D%20((p1%20%26lt%3B%26lt%3B%201)%20%7C%20p0)%3B%20%2F%2F%20set%20parity%20bits%3C%2FP%3E%3CP%3Ewrite(%22%5BmakeFrame%5D%20Final%20frame%20%3D%200x%2504X%22%2C%20f)%3B%3CBR%20%2F%3Ereturn%20f%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%2F*%20Status%20%26amp%3B%20fault%20logging%20*%2F%3CBR%20%2F%3Evoid%20logSpiStatus(word%20r)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Es4%20%3D%20(r%20%26gt%3B%26gt%3B%2014)%20%26amp%3B%201%3B%3CBR%20%2F%3Es3%20%3D%20(r%20%26gt%3B%26gt%3B%2013)%20%26amp%3B%201%3B%3CBR%20%2F%3Es2%20%3D%20(r%20%26gt%3B%26gt%3B%2012)%20%26amp%3B%201%3B%3CBR%20%2F%3Es1%20%3D%20(r%20%26gt%3B%26gt%3B%2011)%20%26amp%3B%201%3B%3CBR%20%2F%3Es0%20%3D%20(r%20%26gt%3B%26gt%3B%2010)%20%26amp%3B%201%3B%3C%2FP%3E%3CP%3Estatus%20%3D%20(r%20%26gt%3B%26gt%3B%2010)%20%26amp%3B%200x1F%3B%3CBR%20%2F%3Edata%20%3D%20(r%20%26gt%3B%26gt%3B%202)%20%26amp%3B%200xFF%3B%3C%2FP%3E%3CP%3Ewrite(%22%5BSPI%20Status%20Bits%5D%20s4%3D%25d%20s3%3D%25d%20s2%3D%25d%20s1%3D%25d%20s0%3D%25d%20%7C%20Full%20Response%3D0x%2504X%22%2C%20s4%2C%20s3%2C%20s2%2C%20s1%2C%20s0%2C%20r)%3B%3CBR%20%2F%3Ewrite(%22%5BSPI%20Decoded%5D%20Status%3D0x%2502X%20Data%3D0x%2502X%22%2C%20status%2C%20data)%3B%3C%2FP%3E%3CP%3Eif%20(s4)%20write(%22Fault%3A%20Reserved%20fault%20(undefined)%22)%3B%3CBR%20%2F%3Eif%20(s3)%20write(%22Fault%3A%20Ignored%20command%20or%20invalid%20previous%20read%22)%3B%3CBR%20%2F%3Eif%20(s2)%20write(%22Fault%3A%20Clock%20error%22)%3B%3CBR%20%2F%3Eif%20(s1)%20write(%22Fault%3A%20Parity%20error%22)%3B%3CBR%20%2F%3Eif%20(s0)%20write(%22Fault%3A%20Bus%20contention%20or%20illegal%20access%22)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%2F*%20(s4..s0%20any%20non-zero%20indicates%20an%20issue).%20*%2F%3CBR%20%2F%3Eint%20hasFault(word%20r)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Ereturn%20(((r%20%26gt%3B%26gt%3B%2014)%20%26amp%3B%201)%20%7C%7C%20((r%20%26gt%3B%26gt%3B%2013)%20%26amp%3B%201)%20%7C%7C%20((r%20%26gt%3B%26gt%3B%2012)%20%26amp%3B%201)%20%7C%7C%20((r%20%26gt%3B%26gt%3B%2011)%20%26amp%3B%201)%20%7C%7C%20((r%20%26gt%3B%26gt%3B%2010)%20%26amp%3B%201))%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%2F*%20Queue%20a%2016-bit%20frame%20on%20MOSI%20(CS%20low%20is%20driven%20here)%20*%2F%3C%2FP%3E%3CP%3E%3CBR%20%2F%3Evoid%20sendFrame(word%20frame16)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EtxBuffer%5B0%5D%20%3D%20(byte)(frame16%20%26gt%3B%26gt%3B%208)%3B%3CBR%20%2F%3EtxBuffer%5B1%5D%20%3D%20(byte)(frame16%20%26amp%3B%200xFF)%3B%3CBR%20%2F%3EsensorQueueMosiData(%22SENSOR%3A%3ASPI%3A%3AMaster_Port%3A%3ANBP_Sensor%22%2C%20txBuffer%2C%2016)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%2F*%20High-level%3A%20schedule%20a%20READ%2FWRITE%20op%20*%2F%3C%2FP%3E%3CP%3Evoid%20spiReadByte(word%20addr)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Etr_addr%20%3D%20addr%3B%3CBR%20%2F%3Etr_op%20%3D%20OP_RD%3B%3CBR%20%2F%3Etr_retry%3D%200%3B%3CBR%20%2F%3EspiSub%20%3D%20TX1%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%201)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Evoid%20spiWriteByte(word%20addr%2C%20byte%20data)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Etr_addr%20%3D%20addr%3B%3CBR%20%2F%3Etr_wdata%20%3D%20data%3B%3CBR%20%2F%3Etr_op%20%3D%20OP_WR%3B%3CBR%20%2F%3Etr_retry%3D%200%3B%3CBR%20%2F%3EspiSub%20%3D%20TX1%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%201)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%2F*%20SPI%20Micro-FSM%20*%2F%3CBR%20%2F%3Eon%20timer%20tSpi%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eswitch%20(spiSub)%3CBR%20%2F%3E%7B%3C%2FP%3E%3CP%3E%2F*%20TX1%20*%2F%3CBR%20%2F%3Ecase%20TX1%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F42252%22%20target%3D%22_blank%22%3E%40VTS%3C%2FA%3E%3A%3AVT2710_1_DIO_Ch2%3A%3ADigitalOutput6%20%3D%200%20%3B%20%2F%2F%20CS%20low%3CBR%20%2F%3E%3CBR%20%2F%3Eif%20(USE_READY_GATE%20%26amp%3B%26amp%3B%20(tr_addr%20!%3D%20ADDR_SPIOPS))%3CBR%20%2F%3E%7B%3CBR%20%2F%3EintAsserted%20%3D%20(active_IntPol%20%3F%20(intLevel%20%3D%3D%201)%20%3A%20(intLevel%20%3D%3D%200))%3B%3CBR%20%2F%3Eif(%20b_INTF%20%26amp%3B%26amp%3B%20!intAsserted)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Ewrite(%22%5BSPI%5D%20Waiting%20for%20READY%20before%20first%20TX1%20-%20Sensor%20initiated%22)%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%201)%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EcurFrame%20%3D%20needDummy%20%3F%20makeNbp8sFrame(0%2C%200x0000)%3A%20makeNbp8sFrame((tr_op%20%3D%3D%20OP_WR)%20%3F%201%20%3A%200%2C%20tr_addr)%3B%3C%2FP%3E%3CP%3Ewrite(%22%5BTX1%5D%20Master%20--%26gt%3B%20Sensor%3A%20Frame%20%3D%200x%2504X%20(R%2FW%3D%25d%20Addr%3D0x%2504X)%22%2CcurFrame%2C%20(curFrame%20%26gt%3B%26gt%3B%2015)%20%26amp%3B%201%2C%20(curFrame%20%26gt%3B%26gt%3B%202)%20%26amp%3B%200x1FFF)%3B%3CBR%20%2F%3EsendFrame(curFrame)%3B%3CBR%20%2F%3EspiSub%20%3D%20RX1%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%201)%3B%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3E%2F*%20RX1%20(R0%20after%20TX1)%20*%2F%3CBR%20%2F%3Ecase%20RX1%3A%3CBR%20%2F%3EmisoHi%20%3D%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F149080%22%20target%3D%22_blank%22%3E%40sensor%3C%2FA%3E%3A%3ASPI%3A%3AMaster_Port%3A%3ANBP_Sensor%3A%3AFrame1.MISO_Signals.MISO_High_byte%3B%3CBR%20%2F%3EmisoLo%20%3D%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F149080%22%20target%3D%22_blank%22%3E%40sensor%3C%2FA%3E%3A%3ASPI%3A%3AMaster_Port%3A%3ANBP_Sensor%3A%3AFrame1.MISO_Signals.MISO_Low_byte%3B%3CBR%20%2F%3EspiResp%20%3D%20((word)misoHi%20%26lt%3B%26lt%3B%20%3CLI-EMOJI%20id%3D%22lia_smiling-face-with-sunglasses%22%20title%3D%22%3Asmiling_face_with_sunglasses%3A%22%3E%3C%2FLI-EMOJI%3E%20%7C%20misoLo%3B%3CBR%20%2F%3Ewrite(%22%5BRX1%5D%20Sensor%20--%26gt%3B%20Master%3A%20Response%20%3D%200x%2504X%20(Status%3D0x%2502X%20Data%3D0x%2502X)%22%2CspiResp%2C%20(spiResp%20%26gt%3B%26gt%3B%2010)%20%26amp%3B%200x1F%2C%20(spiResp%20%26gt%3B%26gt%3B%202)%20%26amp%3B%200xFF)%3B%3CBR%20%2F%3Eif%20(needDummy)%20%7B%3CBR%20%2F%3EneedDummy%20%3D%200%3B%3CBR%20%2F%3EspiSub%20%3D%20TX1%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%201)%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%2F%2F%20correct%20fault%20handling%3CBR%20%2F%3ElogSpiStatus(spiResp)%3B%3CBR%20%2F%3Eif(tr_addr%20!%3D%20ADDR_SPIOPS)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Es4%20%3D%20(spiResp%20%26gt%3B%26gt%3B%2014)%20%26amp%3B%201%3B%3CBR%20%2F%3Es3%20%3D%20(spiResp%20%26gt%3B%26gt%3B%2013)%20%26amp%3B%201%3B%3CBR%20%2F%3Es2%20%3D%20(spiResp%20%26gt%3B%26gt%3B%2012)%20%26amp%3B%201%3B%3CBR%20%2F%3Es1%20%3D%20(spiResp%20%26gt%3B%26gt%3B%2011)%20%26amp%3B%201%3B%3CBR%20%2F%3Es0%20%3D%20(spiResp%20%26gt%3B%26gt%3B%2010)%20%26amp%3B%201%3B%3C%2FP%3E%3CP%3Eif%20(s2)%20%7B%20%2F%2F%20Clock%20fault%3CBR%20%2F%3Eif%20(tr_retry%20%26lt%3B%204)%20%7B%3CBR%20%2F%3Ewrite(%22%5BSPI%5D%20Clock%20fault%3A%20dummy%2Bretry%22)%3B%3CBR%20%2F%3EneedDummy%20%3D%201%3B%20tr_retry%2B%2B%3B%3CBR%20%2F%3EspiSub%20%3D%20TX1%3B%20setTimer(tSpi%2C%205)%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Etr_op%20%3D%20OP_NONE%3B%3CBR%20%2F%3EspiSub%20%3D%20IDLE%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Eif%20(s3%20%7C%7C%20s4)%20%7B%3CBR%20%2F%3Ewrite(%22%5BSPI%5D%20Fatal%20fault%20(Reserved%2FPrevious%20read%2Fwrite)%20error%2C%20aborting%20transfer%22)%3B%3C%2FP%3E%3CP%3Etr_op%20%3D%20OP_NONE%3B%3CBR%20%2F%3EspiSub%20%3D%20IDLE%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Eif%20(s1%20%7C%7C%20s0)%20%7B%3CBR%20%2F%3Eif%20(tr_retry%20%26lt%3B%204)%20%7B%3CBR%20%2F%3Ewrite(%22%5BSPI%5D%20SPI%20fault%20(s1%2Fs0)%20%3A%20dummy%2Bretry%22)%3B%3CBR%20%2F%3EneedDummy%20%3D%201%3B%3CBR%20%2F%3Etr_retry%2B%2B%3B%3CBR%20%2F%3EspiSub%20%3D%20TX1%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%201)%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Etr_op%20%3D%20OP_NONE%3B%3CBR%20%2F%3EspiSub%20%3D%20IDLE%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Eif%20(tr_op%20%3D%3D%20OP_WR)%20%7B%3CBR%20%2F%3EcurFrame%20%3D%20makeNbp8sFrame(1%2C%20tr_wdata)%3B%3CBR%20%2F%3Ewrite(%22%5BTX2%5D%20Master%20--%26gt%3B%20Sensor%3A%20Data%20Frame%20%3D%200x%2504X%22%2C%20curFrame)%3B%3CBR%20%2F%3EsendFrame(curFrame)%3B%3CBR%20%2F%3EspiSub%20%3D%20RX2%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%205)%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%2F*%20For%20READs%20send%20dummy%20frame%20*%2F%3CBR%20%2F%3Eelse%20if%20(tr_op%20%3D%3D%20OP_RD)%20%7B%3CBR%20%2F%3EcurFrame%20%3D%20makeNbp8sFrame(0%2C%200x0000)%3B%3CBR%20%2F%3Ewrite(%22%5BTX2%5D%20Master%20--%26gt%3B%20Sensor%3A%20Dummy%20Frame%20%3D%200x%2504X%22%2C%20curFrame)%3B%3CBR%20%2F%3EsendFrame(curFrame)%3B%3CBR%20%2F%3EspiSub%20%3D%20RX2%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%201)%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%2F*%20TX2%20*%2F%3CBR%20%2F%3Ecase%20TX2%3A%3CBR%20%2F%3EspiSub%20%3D%20RX2%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%201)%3B%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3E%2F*%20RX2%20(R1%3A%20DATA%20for%20READ%2C%20STATUS%20for%20WRITE)%20*%2F%3CBR%20%2F%3Ecase%20RX2%3A%3CBR%20%2F%3E%3CBR%20%2F%3EmisoHi%20%3D%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F149080%22%20target%3D%22_blank%22%3E%40sensor%3C%2FA%3E%3A%3ASPI%3A%3AMaster_Port%3A%3ANBP_Sensor%3A%3AFrame1.MISO_Signals.MISO_High_byte%3B%3CBR%20%2F%3EmisoLo%20%3D%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F149080%22%20target%3D%22_blank%22%3E%40sensor%3C%2FA%3E%3A%3ASPI%3A%3AMaster_Port%3A%3ANBP_Sensor%3A%3AFrame1.MISO_Signals.MISO_Low_byte%3B%3CBR%20%2F%3EspiResp%20%3D%20((word)misoHi%20%26lt%3B%26lt%3B%20%3CLI-EMOJI%20id%3D%22lia_smiling-face-with-sunglasses%22%20title%3D%22%3Asmiling_face_with_sunglasses%3A%22%3E%3C%2FLI-EMOJI%3E%20%7C%20misoLo%3B%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F42252%22%20target%3D%22_blank%22%3E%40VTS%3C%2FA%3E%3A%3AVT2710_1_DIO_Ch2%3A%3ADigitalOutput6%20%3D%201%20%3B%20%2F%2F%20CS%20high%3CBR%20%2F%3EsetTimer(tDelay%2C%2010)%3B%3CBR%20%2F%3Ewrite(%22%5BRX2%5D%20Sensor%20--%26gt%3B%20Master%3A%20Response%20%3D%200x%2504X%20(Status%3D0x%2502X%20Data%3D0x%2502X)%22%2CspiResp%2C%20(spiResp%20%26gt%3B%26gt%3B%2010)%20%26amp%3B%200x1F%2C%20(spiResp%20%26gt%3B%26gt%3B%202)%20%26amp%3B%200xFF)%3B%3C%2FP%3E%3CP%3ElogSpiStatus(spiResp)%3B%20%2F%2F%20correct%20fault%20handling%20*%2F%3CBR%20%2F%3Eif(tr_addr%20!%3D%20ADDR_SPIOPS)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Es4%20%3D%20(spiResp%20%26gt%3B%26gt%3B%2014)%20%26amp%3B%201%3B%3CBR%20%2F%3Es3%20%3D%20(spiResp%20%26gt%3B%26gt%3B%2013)%20%26amp%3B%201%3B%3CBR%20%2F%3Es2%20%3D%20(spiResp%20%26gt%3B%26gt%3B%2012)%20%26amp%3B%201%3B%3CBR%20%2F%3Es1%20%3D%20(spiResp%20%26gt%3B%26gt%3B%2011)%20%26amp%3B%201%3B%3CBR%20%2F%3Es0%20%3D%20(spiResp%20%26gt%3B%26gt%3B%2010)%20%26amp%3B%201%3B%3C%2FP%3E%3CP%3Eif%20(s2)%20%7B%20%2F%2F%20Clock%20fault%3CBR%20%2F%3Eif%20(tr_retry%20%26lt%3B%204)%20%7B%3CBR%20%2F%3Ewrite(%22%5BSPI%5D%20Clock%20fault%3A%20dummy%2Bretry%22)%3B%3CBR%20%2F%3EneedDummy%20%3D%201%3B%3CBR%20%2F%3Etr_retry%2B%2B%3B%3CBR%20%2F%3EspiSub%20%3D%20TX1%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%201)%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3Etr_op%20%3D%20OP_NONE%3B%3CBR%20%2F%3EspiSub%20%3D%20IDLE%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Eif%20(s3%20%7C%7C%20s4)%20%7B%3CBR%20%2F%3Ewrite(%22%5BSPI%5D%20Fatal%20fault%20(parity%2Fcontend)%2C%20aborting%20transfer%22)%3B%3CBR%20%2F%3Etr_op%20%3D%20OP_NONE%3B%3CBR%20%2F%3EspiSub%20%3D%20IDLE%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Eif%20(s1%20%7C%7C%20s0)%20%7B%3CBR%20%2F%3Eif%20(tr_retry%20%26lt%3B%204)%20%7B%3CBR%20%2F%3Ewrite(%22%5BSPI%5D%20SPI%20fault%20(s1%2Fs0)%20%3A%20dummy%2Bretry%22)%3B%3CBR%20%2F%3EneedDummy%20%3D%201%3B%3CBR%20%2F%3Etr_retry%2B%2B%3B%3CBR%20%2F%3EspiSub%20%3D%20TX1%3B%3CBR%20%2F%3EsetTimer(tSpi%2C%201)%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3Etr_op%20%3D%20OP_NONE%3B%3CBR%20%2F%3EspiSub%20%3D%20IDLE%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3Eif%20(tr_op%20%3D%3D%20OP_RD)%3CBR%20%2F%3Etr_rdata%20%3D%20(spiResp%20%26gt%3B%26gt%3B%202)%20%26amp%3B%200xFF%3B%3C%2FP%3E%3CP%3Etr_op%20%3D%20OP_NONE%3B%3CBR%20%2F%3EspiSub%20%3D%20IDLE%3B%3CBR%20%2F%3EsetTimer(tDelay%2C%201)%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%2F*%20Utility%20*%2F%3CBR%20%2F%3Eint%20spiBusy()%20%7B%20return%20(tr_op%20!%3D%20OP_NONE)%20%7C%7C%20(spiSub%20!%3D%20IDLE)%3B%20%7D%3C%2FP%3E%3CP%3E%2F*%20Start%20*%2F%3CBR%20%2F%3Eon%20start%3CBR%20%2F%3E%7B%3CBR%20%2F%3Ewrite(%22NBP8s%20Evaluation%22)%3B%3CBR%20%2F%3EsetTimer(tDelay%2C38)%3B%3C%2FP%3E%3CP%3EneedDummy%20%3D%201%3B%20%2F*%20first%20transfer%20dummy%20after%20WAKE%2FCS%20glitch%20*%2F%3CBR%20%2F%3EmainState%20%3D%200%3B%3CBR%20%2F%3Etr_op%20%3D%20OP_NONE%3B%3CBR%20%2F%3EspiSub%20%3D%20IDLE%3B%3CBR%20%2F%3EstartupWaitDone%20%3D%201%3B%3CBR%20%2F%3EsetTimer(tMain%2C%2035)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%2F*%20tDelay%20yields%20back%20to%20main%20*%2F%3CBR%20%2F%3Eon%20timer%20tDelay%3CBR%20%2F%3E%7B%3CBR%20%2F%3EsetTimer(tMain%2C%205)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%2F*%20Main%20FSM%20*%2F%3CBR%20%2F%3Eon%20timer%20tMain%3CBR%20%2F%3E%7B%3CBR%20%2F%3EsetTimer(tMain%2C%201)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%2F*%20State%20machine%20*%2F%3CBR%20%2F%3Eswitch%20(mainState)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%2F*%20SPIOPS%20handshake%20*%2F%3CBR%20%2F%3Ecase%200%3A%3CBR%20%2F%3Eif%20(spiBusy())%20break%3B%3CBR%20%2F%3E%2F%2F%20If%20a%20dummy%20is%20pending%20(e.g.%20after%20reset%2Ffault)%2C%20consume%20it%3CBR%20%2F%3Ewrite(%22SPIOPS%20-%20Dummy%20frame%20to%20clear%20start%20up%22)%3B%3C%2FP%3E%3CP%3E%2F%2F%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F42252%22%20target%3D%22_blank%22%3E%40VTS%3C%2FA%3E%3A%3AVT2710_1_DIO_Ch2%3A%3ADigitalOutput6%20%3D%200%3B%20%2F%2F%20CS%20low%3CBR%20%2F%3E%2F%2F%20setTimer(tDelay%2C%202)%3B%3CBR%20%2F%3E%2F%2F%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F42252%22%20target%3D%22_blank%22%3E%40VTS%3C%2FA%3E%3A%3AVT2710_1_DIO_Ch2%3A%3ADigitalOutput6%20%3D%201%3B%20%2F%2F%20CS%20high%3CBR%20%2F%3E%2F%2F%20setTimer(tDelay%2C%205)%3B%3CBR%20%2F%3E%3CBR%20%2F%3EspiReadByte(0x0000)%3B%20%2F%2F%20dummy%20frame%20(ignored%20by%20device)%3CBR%20%2F%3EsetTimer(tDelay%2C5)%3B%3C%2FP%3E%3CP%3EneedDummy%20%3D%200%3B%3CBR%20%2F%3EsetTimer(tDelay%2C5)%3B%3CBR%20%2F%3EmainState%20%3D%201%3B%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3Ecase%201%3A%3CBR%20%2F%3Eif%20(spiBusy())%20break%3B%3CBR%20%2F%3Ewrite(%22SPIOPS%20-%20SENSOR%20Ready%20%2C%20proceeding%20to%20write%22)%3B%3CBR%20%2F%3EspiWriteByte(ADDR_SPIOPS%2C%200x04)%3B%20%2F%2F%20write%20SPIOPS%20%3D%200x04%3CBR%20%2F%3EsetTimer(tDelay%2C5)%3B%3CBR%20%2F%3EmainState%20%3D%202%3B%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3Ecase%202%3A%3CBR%20%2F%3Eif%20(spiBusy())%20break%3B%3CBR%20%2F%3EspiReadByte(ADDR_SPIOPS)%3B%20%2F%2F%20read%20back%20SPIOPS%3CBR%20%2F%3EsetTimer(tDelay%2C%205)%3B%3CBR%20%2F%3EmainState%20%3D%203%3B%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3Ecase%203%3A%3CBR%20%2F%3Eif%20(spiBusy())%20break%3B%3CBR%20%2F%3EmainState%20%3D%204%3B%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3Ecase%204%3A%3CBR%20%2F%3Eif%20(spiBusy())%20break%3B%3C%2FP%3E%3CP%3E%2F%2F%20Use%20tr_rdata%20(captured%20byte)%20instead%20of%20spiResp%20bits%3CBR%20%2F%3EregSPIOPS%20%3D%20(byte)(tr_rdata%20%26amp%3B%200x07)%3B%3C%2FP%3E%3CP%3E%2F%2F%20If%20HOLD%20active%20and%20range%2000%20-%26gt%3B%20SPIOPS%20must%20be%200x04%3CBR%20%2F%3Eif%20(regSPIOPS%20%3D%3D%200x04)%20%7B%3CBR%20%2F%3Ewrite(%22SPIOPS%3A%20SET%20OK%20(0x%2502X)%22%2C%20regSPIOPS)%3B%3CBR%20%2F%3EmainState%20%3D%2010%3B%20%2F%2F%20go%20to%20FW%2FHW%20read%3CBR%20%2F%3E%7D%3CBR%20%2F%3Eelse%20%7B%3CBR%20%2F%3Ewrite(%22SPIOPS%20NOT%20READY%20(SPIOPS%20%3D%200x%2502X)%20--%26gt%3B%20retrying%22%2C%20regSPIOPS)%3B%3CBR%20%2F%3EneedDummy%20%3D%201%3B%3CBR%20%2F%3EsetTimer(tDelay%2C5)%3B%3CBR%20%2F%3EmainState%20%3D%201%20%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3E%2F*%20FW%20%2F%20HW%20READ%20SEQUENCE%20*%2F%3CBR%20%2F%3Ecase%2010%3A%3CBR%20%2F%3Eif%20(spiBusy())%20break%3B%3CBR%20%2F%3Ewrite(%22SPIOPS%20already%20set%20to%200x04%20--%26gt%3B%20Firmware%20window%20active%22)%3B%3CBR%20%2F%3Ewrite(%22Reading%20FW_DERIV%20(0x0805)...%22)%3B%3CBR%20%2F%3EspiReadByte(ADDR_FW_DERIV)%3B%3CBR%20%2F%3EsetTimer(tDelay%2C%205)%3B%3CBR%20%2F%3EmainState%20%3D%2011%3B%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3Ecase%2011%3A%3CBR%20%2F%3Eif%20(spiBusy())%20break%3B%3CBR%20%2F%3Ewrite(%22FW_DERIV%20%3D%200x%2502X%22%2C%20tr_rdata)%3B%3CBR%20%2F%3Ewrite(%22Reading%20FW_VER%20(0x0804)...%22)%3B%3CBR%20%2F%3EspiReadByte(ADDR_FW_VER)%3B%3CBR%20%2F%3EsetTimer(tDelay%2C%205)%3B%3CBR%20%2F%3EmainState%20%3D%2012%3B%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3Ecase%2012%3A%3CBR%20%2F%3Eif%20(spiBusy())%20break%3B%3CBR%20%2F%3Ewrite(%22FW_VER%20%3D%200x%2502X%22%2C%20tr_rdata)%3B%3CBR%20%2F%3EsetTimer(tDelay%2C%205)%3B%3CBR%20%2F%3EmainState%20%3D%2013%3B%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3Ecase%2013%3A%3CBR%20%2F%3Eif%20(spiBusy())%20break%3B%3CBR%20%2F%3Ewrite(%22Clearing%20SPIOPS%20(0x0038)%20to%20release%20NBP8s%20CPU%22)%3B%3CBR%20%2F%3EspiWriteByte(ADDR_SPIOPS%2C%200x00)%3B%3CBR%20%2F%3EsetTimer(tDelay%2C%205)%3B%3CBR%20%2F%3EmainState%20%3D%2014%3B%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%3CBR%20%2F%3Ecase%2014%3A%3CBR%20%2F%3Eif%20(spiBusy())%20break%3B%3CBR%20%2F%3Ewrite(%22FW%20read%20complete%22)%3B%3CBR%20%2F%3EmainState%20%3D%2099%3B%3CBR%20%2F%3Ebreak%3B%3C%2FP%3E%3CP%3Ecase%2099%3A%3CBR%20%2F%3E%2F%2F%20Idle%20%2F%20stop%3CBR%20%2F%3Ebreak%3B%3CBR%20%2F%3E%7D%7D%3C%2FP%3E%3CP%3Eany%20suggestions%20and%20feedback%20would%20be%20helpful%20for%20further%20progress.%3CBR%20%2F%3E%3CBR%20%2F%3EBest%20regards%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2246790%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EPressure%20Sensors%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2247154%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20NBP8s%20integration%20with%20Vector%20system%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2247154%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHi%20Tomas%3CBR%20%2F%3EThanks%20a%20lot%20for%20the%20quick%20response.%20The%20configuration%20is%20exactly%20the%20same%20as%20defined%20in%20datasheet%20and%20i%20am%20following%20the%20same%20steps%20as%20you%20have%20outlined.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20try%20to%20set%20SPIOPS%20and%20the%20response%20from%20the%20sensor%20is%200x0220%20and%20it%20stays%20the%20same%20for%20subsequent%20responses.%3CBR%20%2F%3Ei%20am%20not%20sure%20if%20i%20am%20missing%20something.%3CBR%20%2F%3EAny%20thoughts%20on%20this%20%3F%3CBR%20%2F%3E%3CBR%20%2F%3EBest%20regards%2C'%3CBR%20%2F%3ERajvishnu%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2246835%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20NBP8s%20integration%20with%20Vector%20system%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2246835%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3BRajvishnu%2C%3C%2FP%3E%0A%3CP%3EThe%20NBP8%20sensor%20uses%20SPI%20Mode%200%20(CPOL%3D0%2C%20CPHA%3D0)%20with%2016-bit%20frames%20and%20even%20parity%20on%20two%20groups%20of%20bits.%20Ensure%20your%20Vector%20VT2710%20SPI%20settings%20match%20this.%26nbsp%3BAfter%20WAKEUP%20or%20any%20CS_B%20glitch%2C%20the%20first%20SPI%20command%20is%20ignored%20due%20to%20a%20clock%20fault%20-%26gt%3B%20send%20a%20dummy%20frame%20first%20to%20clear%20the%20error.%26nbsp%3BAlways%20wait%20for%20the%20READY%20pin%20to%20assert%20before%20starting%20SPI%20transfers.%20This%20indicates%20the%20sensor%20is%20ready%20and%20its%20CPU%20is%20halted.%26nbsp%3BCheck%20that%20CS_B%20stays%20low%20for%20all%2016%20clock%20cycles%20per%20frame%20and%20that%20parity%20bits%20are%20correct.%26nbsp%3BHandle%20fault%20bits%20(s4..s0)%20properly.%20If%20any%20are%20set%2C%20retry%20with%20a%20dummy%20frame.%20s3%20(ignored%20command)%20also%20requires%20a%20retry.%26nbsp%3BClear%20the%20SPIOPS%20register%20at%20the%20end%20of%20the%20session%20to%20resume%20normal%20sensor%20operation.%26nbsp%3BThese%20steps%20usually%20resolve%20invalid%20responses%20during%20integration.%3C%2FP%3E%0A%3CP%3EBRs%2C%20Tomas%3C%2FP%3E%3C%2FLINGO-BODY%3E