S32K144 problems with UJA1169 CAN receiving

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

S32K144 problems with UJA1169 CAN receiving

2,675 Views
pekor
Contributor II

Hello,

I decided to put this issue to global, instead of reply only post (put hereS32K144 problems with LPSPI 16bit transmission to UJA1169 )

I'm working with UJA1169 SBC and according to some info (mentioned in discussion link above) it should be in Force Normal Mode. I wanted to use CAN communication only for my purposes. In this mode CAN transceiver should be (always) enabled. But unfortunately it looks like it does work only in one direction - sending. Receiving CAN messages doesn't work at all.

I'm using FLEXCAN library. When FLEXCAN_DRV_Receive is called and I check the the transfer status the answer is always STATUS_BUSY (commented line).

The app is not going through the callback (and so through FLEXCAN_DRV_IRQHandler as well), but when I'm use FLEXCAN_DRV_Send everything seems to work as it should.

Here is a sample code (only FLEXCAN code):

bool canDataReceived = false;

#define RX_MB (1U)
#define TX_MB (0U)
#define MSG_ID_1 0x1B0
#define MSG_ID_2 0x1C0

static void flexcan0_Callback(uint8_t instance,
 flexcan_event_type_t eventType,
 flexcan_state_t *flexcanState)
{
 (void)flexcanState;
 (void)instance;

 switch(eventType)
 {
 case FLEXCAN_EVENT_RX_COMPLETE:
 canDataReceived = true;
 break;
 case FLEXCAN_EVENT_TX_COMPLETE:
 break;
 default:
 break;
 }
}

int main(void)
{
(...)

 FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);
 FLEXCAN_DRV_ConfigTxMb(INST_CANCOM1, TX_MB, &dataInfo, MSG_ID_1);

 FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MB, &dataInfo, MSG_ID_2);
 FLEXCAN_DRV_InstallEventCallback(INST_CANCOM1, flexcan0_Callback, NULL);

 /* Define receive buffer */
 flexcan_msgbuff_t recvBuff;
 FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MB, &recvBuff);

 /* Wait until the previous FlexCAN receive is completed */
 //while(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MB) == STATUS_BUSY);

 for (;;)
 {
 if (canDataReceived)
 {
 FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MB, &recvBuff);
 canDataReceived = false;
 }
 }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Any hint what could possibly go wrong?

4 Replies

1,393 Views
AnaAldescu
NXP Employee
NXP Employee

Hello,

The FLEXCAN driver seems to be correctly configured. Could you please provide more information about the configuration of the communicating FLEXCAN nodes?

Regards,

Ana

0 Kudos

1,393 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

The SBC can't be the root cause of your problem. This is from UJA1169 datasheet: pastedImage_1.png

Are you sure that CAN pins are connected right to SBC/MCU and PinSettings configuration is ok?

Also, you can check the example from SDK with some CAN communication (<SDK>/examples\S32K144\demo_apps\flexcan_encrypted)

Best regards,

Razvan

1,393 Views
pekor
Contributor II

Hello,

thank You for the hint with example code. I've configured this to work with my board and it helped me to realize that to send any CAN frame and that I want to catch with my device I must use ID that configured with FLEXCAN_DRV_ConfigRxMb function. Yes, it's my fault. But if so, what I need to do to catch any frame CAN (with any ID)?

What in fact is the influence of the parameters that comes with ConfigRxMb/ConfigTxMb routine? I see that ID is checked but for example data from flexcan_data_info_t doesn't influence anything.



0 Kudos

1,393 Views
AnaAldescu
NXP Employee
NXP Employee

Hello,

In order to receive all frames, no matter the ID there are two possible configurations:

1. Enable Rx Individual Masking (FLEXCAN_DRV_SetRxMaskType(INSTANCE_NUMBER, FLEXCAN_RX_MASK_INDIVIDUAL)) and set the Rx Individual Mask as "don't care" for the corresponding message buffer (FLEXCAN_DRV_SetRxIndividualMask(INSTANCE_NUMBER, id_type, mb_idx, 0U)). Each bit in the Individual Mask has the following meaning: 0b - "don't care", 1b - filter is checked.

2. Enable global masking scheme (FLEXCAN_DRV_SetRxMaskType(INSTANCE_NUMBER, FLEXCAN_RX_MASK_GLOBAL)) and set the Rx Global Mask (FLEXCAN_DRV_SetRxMbGlobalMask(INSTANCE_NUMBER, id_type, 0U)). The global masking scheme sets a single mask for all MBs except MB14 and MB15 (FLEXCAN_DRV_SetRxMb14Mask(), FLEXCAN_DRV_SetRxMb15Mask).

After initializing the FlexCAN module, the global masking scheme is enabled. FLEXCAN_DRV_ConfigRxMb() configures a MB for reception and an ID for which the configured mask applies. The data from flexcan_data_info_t is used to configure the ID type (standard or extended) and other parameters such as expected payload size and bit rate switch inside CAN FD frames.

Regards,

Ana