This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Hi teams:
I want to implement reverse addressing through BQ79600. Referring to the example, I cannot collect data correctly. The example is as follows:
My system is 1 MCU plus 1 BQ79600 plus 4 BQ79616
My instructions are as follows
SpiWake79600(); //wake up BQ79600 delay_us(500); delay_ms(3); SpiWriteReg(NULL_BQ, CONTROL1, 0x20, Length_1, FRMWRT_SGL_W); //wake BQ79616 delay_ms(80); SpiWriteReg(NULL_BQ, OTP_ECC_DATAIN1, DummyValue, Length_1, FRMWRT_STK_W); SpiWriteReg(NULL_BQ, OTP_ECC_DATAIN2, DummyValue, Length_1, FRMWRT_STK_W); SpiWriteReg(NULL_BQ, OTP_ECC_DATAIN3, DummyValue, Length_1, FRMWRT_STK_W); SpiWriteReg(NULL_BQ, OTP_ECC_DATAIN4, DummyValue, Length_1, FRMWRT_STK_W); SpiWriteReg(NULL_BQ, OTP_ECC_DATAIN5, DummyValue, Length_1, FRMWRT_STK_W); SpiWriteReg(NULL_BQ, OTP_ECC_DATAIN6, DummyValue, Length_1, FRMWRT_STK_W); SpiWriteReg(NULL_BQ, OTP_ECC_DATAIN7, DummyValue, Length_1, FRMWRT_STK_W); SpiWriteReg(NULL_BQ, OTP_ECC_DATAIN8, DummyValue, Length_1, FRMWRT_STK_W); SpiWriteReg(NULL_BQ, CONTROL1, 0x80, Length_1, FRMWRT_REV_ALL_W); //brdcast Write 0x02 to address 0x308(1) SpiWriteReg(NULL_BQ, COMM_CTRL, 0x02, Length_1, FRMWRT_ALL_W); //brdcast Write 0x81 to address 0x309 (enable BQ7961X-Q1 auto addressing) SpiWriteReg(NULL_BQ, CONTROL1, 0x81, Length_1, FRMWRT_ALL_W); //SET ADDRESSES FOR EVERY BOARD for(currentBoard1=0; currentBoard1<5; currentBoard1++) { SpiWriteReg(NULL_BQ, DIR1_ADDR, currentBoard1, Length_1, FRMWRT_ALL_W); } //BROADCAST WRITE TO SET ALL DEVICES AS STACK DEVICE SpiWriteReg(NULL_BQ, COMM_CTRL, SetStarkDevice, Length_1, FRMWRT_ALL_W); //set base device as base SpiWriteReg(NULL_BQ, COMM_CTRL, 0x00, Length_1, FRMWRT_SGL_W); //SET THE HIGHEST DEVICE IN THE STACK AS BOTH STACK AND TOP OF STACK SpiWriteReg(0x04, COMM_CTRL, SetTopDevice, Length_1, FRMWRT_SGL_W); //SYNCRHONIZE THE DLL WITH A THROW-AWAY READ SpiReadReg(NULL_BQ, OTP_ECC_DATAIN1, autoaddr_response_frame, Length_1, NULL_BQ, FRMWRT_STK_R); SpiReadReg(NULL_BQ, OTP_ECC_DATAIN2, autoaddr_response_frame, Length_1, NULL_BQ, FRMWRT_STK_R); SpiReadReg(NULL_BQ, OTP_ECC_DATAIN3, autoaddr_response_frame, Length_1, NULL_BQ, FRMWRT_STK_R); SpiReadReg(NULL_BQ, OTP_ECC_DATAIN4, autoaddr_response_frame, Length_1, NULL_BQ, FRMWRT_STK_R); SpiReadReg(NULL_BQ, OTP_ECC_DATAIN5, autoaddr_response_frame, Length_1, NULL_BQ, FRMWRT_STK_R); SpiReadReg(NULL_BQ, OTP_ECC_DATAIN6, autoaddr_response_frame, Length_1, NULL_BQ, FRMWRT_STK_R); SpiReadReg(NULL_BQ, OTP_ECC_DATAIN7, autoaddr_response_frame, Length_1, NULL_BQ, FRMWRT_STK_R); SpiReadReg(NULL_BQ, OTP_ECC_DATAIN8, autoaddr_response_frame, Length_1, NULL_BQ, FRMWRT_STK_R); for(currentBoard1=0; currentBoard1<5; currentBoard1++) { SpiReadReg(currentBoard1, DIR1_ADDR, autoaddr_response_frame, Length_1, NULL_BQ, FRMWRT_SGL_R); } //OPTIONAL: read register address 0x2001 and verify that the value is 0x14 SpiReadReg(NULL_BQ, Bridge_DEV_CONF1, autoaddr_response_frame, Length_1, NULL_BQ, FRMWRT_SGL_R);
The data cannot be collected normally. Please help me find out where the problem is.
Hello Xi,
Mind sharing a logic-analyzer capture of this command sequence?
I can also test things from my side as well to check your sequence.
Best Regards,
Luis Hernandez Salomon
void ReverseAddressing() { uint16_t test_response_frame[(1+6)*TOTALBOARDS] ; //CHANGE BASE DEVICE DIRECTION SpiWriteReg(0, CONTROL1, 0x80, 1, FRMWRT_SGL_W); //CHANGE REST OF STACK DIRECTION SpiWriteReg(0, CONTROL1, 0x80, 1, FRMWRT_REV_ALL_W); //DO NORMAL AUTO ADDRESS SEQUENCE, BUT FOR DIR1_ADDR //DUMMY WRITE TO SNCHRONIZE ALL DAISY CHAIN DEVICES DLL (IF A DEVICE RESET OCCURED PRIOR TO THIS) SpiWriteReg(0, OTP_ECC_DATAIN1, 0X00, 1, FRMWRT_ALL_W); SpiWriteReg(0, OTP_ECC_DATAIN2, 0X00, 1, FRMWRT_ALL_W); SpiWriteReg(0, OTP_ECC_DATAIN3, 0X00, 1, FRMWRT_ALL_W); SpiWriteReg(0, OTP_ECC_DATAIN4, 0X00, 1, FRMWRT_ALL_W); SpiWriteReg(0, OTP_ECC_DATAIN5, 0X00, 1, FRMWRT_ALL_W); SpiWriteReg(0, OTP_ECC_DATAIN6, 0X00, 1, FRMWRT_ALL_W); SpiWriteReg(0, OTP_ECC_DATAIN7, 0X00, 1, FRMWRT_ALL_W); SpiWriteReg(0, OTP_ECC_DATAIN8, 0X00, 1, FRMWRT_ALL_W); //ENABLE AUTO ADDRESSING MODE, WHILE KEEPING REVERSE DIRECTION SpiWriteReg(0, CONTROL1, 0X81, 1, FRMWRT_ALL_W); //SET ADDRESSES FOR EVERY BOARD (REVERSE DIRECTION) for(currentBoard=0; currentBoard<TOTALBOARDS; currentBoard++) { SpiWriteReg(0, DIR1_ADDR, currentBoard, 1, FRMWRT_ALL_W); } SpiWriteReg(0, COMM_CTRL, 0x02, 1, FRMWRT_ALL_W); //set everything as a stack device first if(TOTALBOARDS==1) //if there's only 1 board, it's the base AND top of stack, so change it to those { SpiWriteReg(0, COMM_CTRL, 0x01, 1, FRMWRT_SGL_W); } else //otherwise set the base and top of stack individually { SpiWriteReg(0, COMM_CTRL, 0x00, 1, FRMWRT_SGL_W); SpiWriteReg(TOTALBOARDS-1, COMM_CTRL, 0x03, 1, FRMWRT_SGL_W); } //SYNCRHONIZE THE DLL WITH A THROW-AWAY READ SpiReadReg(0, OTP_ECC_DATAIN1, test_response_frame, 1, 0, FRMWRT_ALL_R); SpiReadReg(0, OTP_ECC_DATAIN2, test_response_frame, 1, 0, FRMWRT_ALL_R); SpiReadReg(0, OTP_ECC_DATAIN3, test_response_frame, 1, 0, FRMWRT_ALL_R); SpiReadReg(0, OTP_ECC_DATAIN4, test_response_frame, 1, 0, FRMWRT_ALL_R); SpiReadReg(0, OTP_ECC_DATAIN5, test_response_frame, 1, 0, FRMWRT_ALL_R); SpiReadReg(0, OTP_ECC_DATAIN6, test_response_frame, 1, 0, FRMWRT_ALL_R); SpiReadReg(0, OTP_ECC_DATAIN7, test_response_frame, 1, 0, FRMWRT_ALL_R); SpiReadReg(0, OTP_ECC_DATAIN8, test_response_frame, 1, 0, FRMWRT_ALL_R); ////OPTIONAL: read back all device addresses //for(currentBoard=0; currentBoard<TOTALBOARDS; currentBoard++) //{ // ReadReg(currentBoard, DIR0_ADDR, response_frame2, 1, 0, FRMWRT_SGL_R); // printf("board %d\n",response_frame2[4]); //} //RESET ANY COMM FAULT CONDITIONS FROM STARTUP SpiWriteReg(0, FAULT_RST2, 0x03, 1, FRMWRT_ALL_W); }
hello,I transplanted the reverse addressing code in the routine into my code, and the logic analyzer waveform of the test is as follows:
Before calling the ReverseAddressing function, all I did was wake up the BQ79600, and then wake up the BQ79616 with the command SpiWriteReg(NULL_BQ, CONTROL1, 0x20, Length_1, FRMWRT_SGL_W)
(1) wake BQ79616
90 00 03 09 20 13 95
(2) change base device direction
90 00 03 09 80 13 ED
(3) change stack device direction
E0 03 09 80 C0 14
(4) After this, all the commands I send will show 0x32
(Theoretically it should be a dummy write to synchronize all daisy chained device DLLs)
Could you help me figure out why this is?
Hello Xi,
That is rather strange. MOSI is what is being sent by your MCU, so is there something going on in the MCU to cause this?
Have you tried using an EVM or USB2ANY to run this test using the command sequence?
Best Regards,
Luis Hernandez Salomom
Hello Luis,
Thanks for your patience. I have found the cause of the problem and solved it.
Hello Xi,
Glad to hear that . What was the problem?
Best Regards,
Luis Hernandez Salomon