TJK1145 module read device number error

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

TJK1145 module read device number error

915 Views
gm2010ustc
Contributor I

I recently debugged the TJK1145 module and used the spi interface to read the device ID. The data read is the same as the data written. Is there a problem with my driver? The comment in the code is the interface function written by the register. This function is no problem. The following is what I wrote with the sdk interface function. Is this correct?

u8 TJA1145_WriteByte(u8 u8Data)
{
#if 0
u8 u8DataReadBack;
DSPI_0.PUSHR.PUSHR.R = (u32)((u32)u8Data + 0x08010000);
//DSPI_0.PUSHR.PUSHR.B.PCS = 0;
while (DSPI_0.SR.B.TCF != 1){}

DSPI_0.SR.B.TCF = 1;

while (DSPI_0.SR.B.RFDF != 1){}
u8DataReadBack = (u8)DSPI_0.POPR.R;
DSPI_0.SR.R = 0xFCFE0000; /* Clear ALL status flags by writing 1 to them */
return u8DataReadBack;
#endif
uint8_t receive_data[4] = {0x0};
uint8_t send_buff[4] = {u8Data, 0X00, 0x00, 0x00};
uint8_t  i = 0;
send_buff[0] = u8Data;
for(i = 0; i < 3; i++)
{
send_buff[3 - i] = (uint8_t)((0x08010000 & (0x0000FF << (8 * i))) >> (8 * i));
}
LPSPI_DRV_MasterTransferBlocking(LPSPICOM1, send_buff, receive_data, 4, 100UL);
return receive_data[0];
}

Labels (1)
0 Kudos
Reply
1 Reply

826 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

what is your EVB? It seems that you are using SDK, in this case there is no reason to use registers directly. 

Jiri 

0 Kudos
Reply