Wrong message length reported by MB_LEN_Dyn
While doing an FTM transmission from RF to I2C and reading the MB_LEN_Dyn register, it will always report a length which is 6 bytes more (or 7 after the increase by one in my code) than the actual message length.
Below is the code of the ISR handling this. Can you please let me know what am I doing wrong?
On the mobile side, I am running the NFC Tap and using the FTM - Data Transfer screen.
Thank you,
Nir.
void IOCAF3_ISR(void) {
unsigned char RX_BYTE,i;
unsigned char length;
RX_BYTE= ST25_readbyte(FTM_MEMORY,ST25_DYNAMIC_REG_IT_STS);
if ( ( RX_BYTE & 0x20 ) == ( 0x20 ) )
{
RX_BYTE= ST25_readbyte(FTM_MEMORY,ST25_DYNAMIC_REG_MB_CTRL);
if ( ( RX_BYTE & 0x85 ) == ( 0x85 ) )
{
length= ST25_readbyte(FTM_MEMORY,ST25_DYNAMIC_REG_MB_LEN);
length++;
printf("\nLength %d\n\r",length);
for (i=0;i<length;i++)
{
data_buffer[i] = ST25_readbyte(FTM_MEMORY,ST25_MAILBOX_START+i);
}
for (i=0;i<length;i++)
{
printf("\n %d\n\r",data_buffer[i]);
}
}
}
IOCAFbits.IOCAF3 = 0;
}