SPI for NBP8

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

SPI for NBP8

Jump to solution
5,697 Views
CaoRq
Contributor II

Hi,NXP

   I need to use pressure sensor NBP8,  but when I try to operate it by spi, I meet some problems

   when I need external host  waking up the NBP8 ,should I pull up  CS_B/WAKE_UP pin then pull down it again after READY/INT pin pull up? if I do it , the response for NBP8 is always 0x1002.

   if I don't pull up and pull down CS_B/WAKE_UP pin ,when I try to operate register by spi , the response is always 0x2002.

   can you tell me how to solve it ?

   Thank you in advance

0 Kudos
1 Solution
5,670 Views
CaoRq
Contributor II

Thank you for you support .

    I find a solution ,before I transfer a command(2 bytes) , I need to pull up and pull down the CS_B pin, then I can get the correct response.  I follow the sequence shown in the image below

 

RunqiangCao_0-1694508252476.png

    I wonder whether I can transfer many commands without pulling up and pulling down the CS_B pin? 

View solution in original post

4 Replies
5,256 Views
Mason2
Contributor I

Mason2_0-1705485274021.png

Mason2_0-1705486306444.png

 

0 Kudos
5,679 Views
JozefKozon
NXP TechSupport
NXP TechSupport

Hi Cao,

please share a scope of the SPI signal when you try communicate with the NBP8. The CS_B pin must be low, when you want to wake up the NBP8 or you want to communicate with. 

JozefKozon_0-1694507096672.png

With Best Regards,

Jozef

5,671 Views
CaoRq
Contributor II

Thank you for you support .

    I find a solution ,before I transfer a command(2 bytes) , I need to pull up and pull down the CS_B pin, then I can get the correct response.  I follow the sequence shown in the image below

 

RunqiangCao_0-1694508252476.png

    I wonder whether I can transfer many commands without pulling up and pulling down the CS_B pin? 

3,915 Views
BillWen
Contributor III
Hi CaoRq:
I have a same problem with you,
if I pull up CS_B/WAKE_UP pin then pull down it again after READY/INT pin pull up, the response for NBP8 is always 0x1002. If not, I always get 0x2002.
The following is my code
void NBP8_WakeupAndCheck(void)
{
uint8_t regval = STD_LOW;
uint8_t result;
uint16_t TxChBuf[1];
uint16_t RxChBuf[1];

Dio_WriteChannel(DioConf_DioChannel_LPSPI5_PCS3, STD_LOW);

regval = Dio_ReadChannel(DioConf_DioChannel_PS_READY);
while(regval == 0)
{
Printf("DioConf_DioChannel_PS_READY = %d\r\n", regval);
}
Printf("DioConf_DioChannel_PS_READY0 = %d\r\n", regval);

Dio_WriteChannel(DioConf_DioChannel_LPSPI5_PCS3, STD_HIGH);

//Osif_Wait(100);

Dio_WriteChannel(DioConf_DioChannel_LPSPI5_PCS3, STD_LOW);
//Osif_Wait(10);

//TxChBuf[0] = NBP8_FW_DER;
TxChBuf[0] = NBP8_SPIOPS;

Spi_SetupEB(SpiConf_SpiChannel_SpiChannel_PressureSensor, TxChBuf, RxChBuf, sizeof(TxChBuf));
result = Spi_SyncTransmit(SpiConf_SpiSequence_SpiSequence_PressureSensor);
//Osif_Wait(10);
Dio_WriteChannel(DioConf_DioChannel_LPSPI5_PCS3, STD_HIGH);

if (result == E_OK) {
Printf("RxChBuf[0] = 0x%x\r\n", RxChBuf[0]);
//Printf("RxChBuf[1] = 0x%x\r\n", RxChBuf[1]);
}
}
Do you know how to fix this?

Thanks
BR, BillWen
0 Kudos
%3CLINGO-SUB%20id%3D%22lingo-sub-1720864%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ESPI%20for%20NBP8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1720864%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%EF%BC%8CNXP%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3BI%20need%20to%20use%20pressure%26nbsp%3Bsensor%20NBP8%2C%26nbsp%3B%20but%20when%20I%20try%20to%20operate%20it%20by%20spi%2C%20I%20meet%20some%20problems%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3Bwhen%20I%20need%20external%20host%26nbsp%3B%20waking%20up%20the%20NBP8%20%2Cshould%20I%20pull%20up%26nbsp%3B%20CS_B%2FWAKE_UP%20pin%20then%20pull%20down%20it%20again%20after%20READY%2FINT%20pin%20pull%20up%3F%20if%20I%20do%20it%20%2C%20the%20response%20for%20NBP8%20is%20always%200x1002.%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3Bif%20I%20don't%20pull%20up%20and%20pull%20down%20CS_B%2FWAKE_UP%20pin%20%2Cwhen%20I%20try%20to%20operate%20register%20by%20spi%20%2C%20the%20response%20is%20always%200x2002.%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3Bcan%20you%20tell%20me%20how%20to%20solve%20it%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3BThank%20you%20in%20advance%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2126724%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20SPI%20for%20NBP8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2126724%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHi%20CaoRq%3A%3CBR%20%2F%3EI%20have%20a%20same%20problem%20with%20you%2C%3CBR%20%2F%3Eif%20I%20pull%20up%20CS_B%2FWAKE_UP%20pin%20then%20pull%20down%20it%20again%20after%20READY%2FINT%20pin%20pull%20up%2C%20the%20response%20for%20NBP8%20is%20always%200x1002.%20If%20not%2C%20I%20always%20get%200x2002.%3CBR%20%2F%3EThe%20following%20is%20my%20code%3CBR%20%2F%3Evoid%20NBP8_WakeupAndCheck(void)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Euint8_t%20regval%20%3D%20STD_LOW%3B%3CBR%20%2F%3Euint8_t%20result%3B%3CBR%20%2F%3Euint16_t%20TxChBuf%5B1%5D%3B%3CBR%20%2F%3Euint16_t%20RxChBuf%5B1%5D%3B%3CBR%20%2F%3E%3CBR%20%2F%3EDio_WriteChannel(DioConf_DioChannel_LPSPI5_PCS3%2C%20STD_LOW)%3B%3CBR%20%2F%3E%3CBR%20%2F%3Eregval%20%3D%20Dio_ReadChannel(DioConf_DioChannel_PS_READY)%3B%3CBR%20%2F%3Ewhile(regval%20%3D%3D%200)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EPrintf(%22DioConf_DioChannel_PS_READY%20%3D%20%25d%5Cr%5Cn%22%2C%20regval)%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3EPrintf(%22DioConf_DioChannel_PS_READY0%20%3D%20%25d%5Cr%5Cn%22%2C%20regval)%3B%3CBR%20%2F%3E%3CBR%20%2F%3EDio_WriteChannel(DioConf_DioChannel_LPSPI5_PCS3%2C%20STD_HIGH)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FOsif_Wait(100)%3B%3CBR%20%2F%3E%3CBR%20%2F%3EDio_WriteChannel(DioConf_DioChannel_LPSPI5_PCS3%2C%20STD_LOW)%3B%3CBR%20%2F%3E%2F%2FOsif_Wait(10)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FTxChBuf%5B0%5D%20%3D%20NBP8_FW_DER%3B%3CBR%20%2F%3ETxChBuf%5B0%5D%20%3D%20NBP8_SPIOPS%3B%3CBR%20%2F%3E%3CBR%20%2F%3ESpi_SetupEB(SpiConf_SpiChannel_SpiChannel_PressureSensor%2C%20TxChBuf%2C%20RxChBuf%2C%20sizeof(TxChBuf))%3B%3CBR%20%2F%3Eresult%20%3D%20Spi_SyncTransmit(SpiConf_SpiSequence_SpiSequence_PressureSensor)%3B%3CBR%20%2F%3E%2F%2FOsif_Wait(10)%3B%3CBR%20%2F%3EDio_WriteChannel(DioConf_DioChannel_LPSPI5_PCS3%2C%20STD_HIGH)%3B%3CBR%20%2F%3E%3CBR%20%2F%3Eif%20(result%20%3D%3D%20E_OK)%20%7B%3CBR%20%2F%3EPrintf(%22RxChBuf%5B0%5D%20%3D%200x%25x%5Cr%5Cn%22%2C%20RxChBuf%5B0%5D)%3B%3CBR%20%2F%3E%2F%2FPrintf(%22RxChBuf%5B1%5D%20%3D%200x%25x%5Cr%5Cn%22%2C%20RxChBuf%5B1%5D)%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3EDo%20you%20know%20how%20to%20fix%20this%3F%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%3CBR%20%2F%3EBR%2C%20BillWen%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1721020%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20SPI%20for%20NBP8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1721020%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20for%20you%20support%20.%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20I%20find%20a%20solution%20%2Cbefore%20I%20transfer%20a%20command(2%20bytes)%20%2C%20I%20need%20to%20pull%20up%20and%20pull%20down%20the%20CS_B%20pin%2C%20then%20I%20can%20get%20the%20correct%20response.%26nbsp%3B%20I%20follow%20the%20sequence%20shown%20in%20the%20image%20below%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22RunqiangCao_0-1694508252476.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22RunqiangCao_0-1694508252476.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240584iDE38037307E7612A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22RunqiangCao_0-1694508252476.png%22%20alt%3D%22RunqiangCao_0-1694508252476.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20I%20wonder%20whether%20I%20can%20transfer%20many%20commands%20without%20pulling%20up%20and%20pulling%20down%20the%20CS_B%20pin%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1720992%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20SPI%20for%20NBP8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1720992%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Cao%2C%3C%2FP%3E%0A%3CP%3Eplease%20share%20a%20scope%20of%20the%20SPI%20signal%20when%20you%20try%20communicate%20with%20the%20NBP8.%20The%20CS_B%20pin%20must%20be%20low%2C%20when%20you%20want%20to%20wake%20up%20the%20NBP8%20or%20you%20want%20to%20communicate%20with.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JozefKozon_0-1694507096672.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22JozefKozon_0-1694507096672.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240578i7071D9D2C4CCD18E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22JozefKozon_0-1694507096672.png%22%20alt%3D%22JozefKozon_0-1694507096672.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWith%20Best%20Regards%2C%3C%2FP%3E%0A%3CP%3EJozef%3C%2FP%3E%3C%2FLINGO-BODY%3E