Hello,
Is it possible to send an ACK to the slave using the LPI2C of KL28 ?
I am trying to interface pn532 to KL28. The below line i use to read the response from the pn532.
stat = LPI2C_DRV_MasterReceiveDataBlocking(INST_LPI2C1, rxbuffer, 256, true, OSIF_WAIT_FOREVER);
The above statement works.
Instead of reading 256 bytes every-time i would like to read byte by byte and stop when the read bytes equal to
the length that was received in the response header.
E.g (probed from analyzer) What i would like to do is this - Get length in red and read only those many bytes in black bold
Start, h48 [ h24 | WR ], h00, h00, hFF, h02, hFE, hD4, h02, h2A, h00, Stop [GetFirmwareVersion]
Start, h49 [ h24 | RD ], h01, h00, h00, hFF, h00, hFF NAK, Stop [ACK]
Start, h49 [ h24 | RD ], h01, h00, h00, hFF, h06, hFA, hD5, h03, h32, h01, h06, h07 NAK, Stop [Response]
Instead of reading worst case 256 bytes for every command (from KL28)
Start, h48 [ h24 | WR ], h00, h00, hFF, h02, hFE, hD4, h02, h2A, h00, Stop
Start, h49 [ h24 | RD ], h01, h00, h00, hFF, h00, hFF NAK, Stop
Start, h49 [ h24 | RD ], h01, h00, h00, hFF, h06, hFA, hD5, h03, h32, h01, h06, h07, hE8, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00 NAK, Stop
I do not want to hard code/keep track of the response length of every command as i am going to be using indataexchange where the data length may vary (less than 256B) and reading 256 bytes each time will not be efficient.
I have successfully implemented the same with the IIC peripheral of KW31Z which has ACK bit generation feature. Just wondering if it is possible with LPI2C...
Thanks
Thanks Jing. Also i guess once you program the MTDR with a receive command and number of bytes you cannot change the receive size until after the stop command. right ? I get a fifo error if i try doing so apparently because the master is busy and the lpi2c requires that a start be sent before writing to the MTDR...
Hi,
if you want to stop a polling mode transfer, you can call LPI2C_MasterStop(). If you want to terminate a transfer in non-blocking mode, the LPI2C_MasterTransferAbort() API shall be called.
Regards,
Jing