The TI E2E™ design support forums will undergo maintenance from Sept. 28 to Oct. 2. If you need design support during this time, contact your TI representative or open a new support request with our customer support center.

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.

LP87745-Q1: Sample code for reading and writing data into PMIC

Part Number: LP87745-Q1
Other Parts Discussed in Thread: IWR6843, , LP8764-Q1, USB2ANY

Hello Community,

We are using LP87745 PMIC for our custom board with IWR6843. I want to communicate with this PMIC via SPI. Is there any sample code available that I can use for reference.?

In the datasheet of this IC, not much information is available so it's difficult to communicate with this PMIC.

Thanks and Regards,

Neil

  • Hi Neil,

    You can make a request for the full datasheet from LP87745-Q1 product page. The SPI frame format is nearly identical to SPI frame in LP8764-Q1. Only differences are in the SPI_STATUS bytes from PMIC to host.

    Here is a Python sample I have been using with USB2ANY to communicate with SPI.

        def formSpiFrame(self, command, page, address, data):
            cArray=c_ubyte*4
            cFrame=cArray(0,0,0,0)
            cFrame[0]=address&0xFF
            cFrame[1]=((page&0x7)<<5)|((command&0x1)<<4)
            cFrame[2]=data&0xFF
            if (self.CRC and command==0):
                cFrame[3]=self.calcCrc(cFrame,3)
            return cFrame
        
        # Returns the read value
        def spiRegisterRead(self, page, address):
            spiFrame=self.formSpiFrame(1, page, address, 0)
            ADDR=spiFrame[0]
            PAGE_OTHER=spiFrame[1]
            nBytes=3
            if self.CRC:
                nBytes=4
            self.u2a_.u2aSPI_WriteAndReadEx(self.HANDLE, self.SPI_CS, nBytes, ctypes.byref(spiFrame))
            if self.CRC:
                RDATA=spiFrame[2]
                CRC=spiFrame[3]
                self.crcCompare([ADDR, PAGE_OTHER, RDATA], 3, CRC)
            print(spiFrame[0], spiFrame[1])
            if spiFrame[0]!=(spiFrame[1]^0xFF):
                print("Device is not responding to SPI.")
            return spiFrame[2]
        
        # Returns the number of bytes read
        def spiRegisterWrite(self, page, address, value):
            spiFrame=self.formSpiFrame(0, page, address, value)
            nBytes=3
            if self.CRC:
                nBytes=4
            bytesRead=self.u2a_.u2aSPI_WriteAndReadEx(self.HANDLE, self.SPI_CS, nBytes, ctypes.byref(spiFrame))
            if spiFrame[0]!=(spiFrame[1]^0xFF):
                print("Device is not responding to SPI.")
            return bytesRead

    BR,

    Samuli

  • Hello Samuli,

    Thank you for your reply, I could read now LP87745 PMIC with IWR6843. But I have to keep chip select on hold until all the data is sent ( params.csHold = 1) or else I couldn't receive complete data.

    When  params.csHold = 0 and params.dataSize = 16, I could receive 0x10ef and when params.dataSize = 8, I receive 0x10 because CS signal goes high.

    But with keeping params.csHold = 1 during total transmission I receive total data. For example, while reading the DEV_REV register at address 0x01, I read 0x10ef96. 

    Thanks and Regards,

    Neil

  • Hi Neil,

    Yep, CS must be kept low for the whole duration of the SPI frame. Rising edge of CS is interpreted as end of the transfer.

    BR,

    Samuli