How to Set TJA1145 CAN active mode

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to Set TJA1145 CAN active mode

3,158 次查看
edt102983
Contributor I

I'm using S32K144 SPI to port the TJA1145 CAN transceiver, but I cannot set TJA1145 to normal mode and active CAN, the CANH and CANL have no 2.5v; the SPI data and clock are sending completely with measurement, following is my code on S32DS:

====================================

#define TIMEOUT 1000UL
#define BUFFER_SIZE 2

int init_master;
int frame_sent=2;
int ret_1;
int ret_2;
int ret_3;
int ret_4;

uint8_t master_send_1[BUFFER_SIZE]={0x01,0x07}; //set Normal Mode from TJA1145 datasheet
uint8_t master_send_2[BUFFER_SIZE]={0x20,0x7A}; //set CAN active from TJA1145 datasheet
uint8_t master_send_3[BUFFER_SIZE]={0x03}; //read Mode status
uint8_t master_send_4[BUFFER_SIZE]={0x22}; //read CAN status
uint8_t master_receive_1[2];
uint8_t master_receive_2[2];
uint8_t master_receive_3[2];
uint8_t master_receive_4[2];

int spi_init(void)
{

CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

init_master=SPI_MasterInit(&spi_pal_1_Instance, &LPSPI_0_MasterInitConfig0);
printf("MasterInit_lspi=%d////",init_master);

ret_1=SPI_MasterTransfer(&spi_pal_1_Instance, master_send_1, master_receive_1, frame_sent);
printf("MasterTransfer_ModeSet=%d////rtn=0x%x\n",ret_1,master_receive_1[0]);

ret_2=SPI_MasterTransfer(&spi_pal_1_Instance, master_send_2, master_receive_2, frame_sent);
printf("MasterTransfer_CANSet=%d////rtn=0x%x\n",ret_2,master_receive_2[0]);

return 0;
}

int spi_main(void)  ////my platform is repeating the main.
{

ret_3=SPI_MasterTransfer(&spi_pal_1_Instance, master_send_3, master_receive_3, frame_sent);
printf("MasterTransfer_MainStatus=%d////Status=%x////",ret_3,master_receive_3[1]);

ret_4=SPI_MasterTransfer(&spi_pal_1_Instance, master_send_4, master_receive_4, frame_sent);
printf("MasterTransfer_CANStatus=%d////Status=%x////",ret_4,master_receive_4[1]);

return 0;
}

log==>

1620378014147.jpg

initializing and command are completed, but the status is always 0, CANH/CANL no 2.5v.

does the procedure I make is wrong? thanks!! 

0 项奖励
回复
4 回复数

3,105 次查看
whotplace
Contributor I

finding the right skills to your startup might be easier with those proven hiring guidelines. 
learn how to attract and maintain gifted human beings. read an interview with exgoogler david
 bizer. highlights: we're a group of startup fans, we've a 、global reach

voip phone 

0 项奖励
回复

3,140 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

try to use transfer blocking function SPI_MasterTransferBlocking().
Or if using non-blocking one then check if present transfer is finished before new can happen; using SPI_GetStatus()

BR, Petr

3,122 次查看
edt102983
Contributor I

Thanks for the advice; otherwise, do I have to do SPI_SlaveInit() for TJA1145? or just sending the SPI data in one hop.

0 项奖励
回复

3,087 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

no you need not it. SPI_SlaveInit() is called if MCU's SPI peripheral is going to be used as slave. This is not a case if communicate with TJA1145, which works as SPI slave and MCU is SPI master.

BR, Petr 

0 项奖励
回复