Can not enter the CAN Tx/Rx Interrupt.

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

Can not enter the CAN Tx/Rx Interrupt.

Jump to solution
892 Views
liufei
Contributor III

Hello,

I make very simple CAN TX test used board with S32K148 144pin.can write function return OK,But Can not enter the CAN Tx/Rx Interrupt.

I set MCAL by EB 24.0.1,Can Rx Processing Type,Can Tx Processing Type and Can BusOff Processing Type set all to interrupt.Then I also set interrupt setting in my test code beacuse without OS,like this:

/*
* can_test.c
*
* Created on: 2022年6月9日
* Author: liu-fei
*/
#include "Mcu.h"
#include "Port.h"
#include "Mcl.h"
#include "Spi.h"
#include "Dio.h"
#include "S32K148.h"
#include "startup.h"
#include "string.h"
#include "Can.h"
#include "stdio.h"
#include "Os_Hal_ContextInt.h"
#include "CanIf_Cbk.h"

#define MCAL_CAN_TEST
#ifdef MCAL_CAN_TEST

Can_PduType PduInfo_test;

/**< Variables which contains Can PDU data used in Can transmission */
uint8 CanApp_InputData[16U] =
{0xA1, 0x1A, 0xFF, 0xFF, 0xC1, 0x1C, 0xB1, 0x1B,
//0xA2, 0x2A, 0xFF, 0xFF, 0xC2, 0x2C, 0xB2, 0x2B,
//0xA3, 0x3A, 0xFF, 0xFF, 0xC3, 0x3C, 0xB3, 0x3B,
//0xA4, 0x4A, 0xFF, 0xFF, 0xC4, 0x4C, 0xB4, 0x4B,
//0xA5, 0x5A, 0xFF, 0xFF, 0xC5, 0x5C, 0xB5, 0x5B,
//0xA6, 0x6A, 0xFF, 0xFF, 0xC6, 0x6C, 0xB6, 0x6B,
//0xA7, 0x7A, 0xFF, 0xFF, 0xC7, 0x7C, 0xB7, 0x7B,
0xA8, 0x8A, 0xFF, 0xFF, 0xC8, 0x8C, 0xB8, 0x8B};

//ISR(Can_IsrFCA_BO);
ISR(Can_IsrFCB_MB_00_15);

uint32 counter = 0;
void Device_CAN_TEST(void)
{

Can_ReturnType canRet;
isr_t func_p;


Dio_LevelType channel_PTE_25;

Dio_WriteChannel(DioConf_DioChannel_PTE_25,1);//CANTRCV_TRCVMODE_NORMAL:TJA1043_EN

channel_PTE_25 = Dio_ReadChannel(DioConf_DioChannel_PTE_25);

Dio_LevelType channel_PTA_11;

Dio_WriteChannel(DioConf_DioChannel_PTA_11,1);//CANTRCV_TRCVMODE_NORMAL:TJA1043_STB_N

channel_PTA_11 = Dio_ReadChannel(DioConf_DioChannel_PTA_11);

 

//Tx/Rx/Fifo Message Buffer Interrupt.
INT_installHandler(CAN1_ORed_0_15_MB_IRQn, Can_IsrFCB_MB_00_15, &func_p);


Os_Hal_NvicEnableIRQ(CAN1_ORed_0_15_MB_IRQn);


Os_Hal_NvicSetPriority(CAN1_ORed_0_15_MB_IRQn, 0x10);


PduInfo_test.length = 16U;

PduInfo_test.sdu = &CanApp_InputData[0U];

PduInfo_test.swPduHandle = 1; //L-PDU handle of CAN L-PDU successfully transmitted.This ID specifies the corresponding CAN L-PDU ID
// and implicitly the CAN Driver instance as well as the
// corresponding CAN controller device.

PduInfo_test.id = 0xA0 | 0x40000000U;//dentifies the HRH and its corresponding CAN Controller

Can_SetControllerMode(0,CAN_T_START);

#if 0
while(1)
{
canRet = Can_Write(0x1U, &PduInfo_test);
delay(5000000);
Can_SetControllerMode(0,CAN_T_START);

if(canRet == CAN_OK)
printf("CAN send OK!");

if(canRet == CAN_BUSY)
printf("CAN send NG!");

}
#else

canRet = Can_Write(0x1U, &PduInfo_test);

if(canRet == CAN_OK)
printf("CAN send OK!");

if(canRet == CAN_BUSY)
printf("CAN send NG!");
#endif

}
#endif

Could you please give me some advise,Thank you!

 

Best regards,

Liufei

0 Kudos
1 Solution
851 Views
cuongnguyenphu
NXP Employee
NXP Employee

Hi @liufei 
As per Reference manual:
1. What dose CanControllerTimeQuanta mean?> Time-Quantum = one Sclock period. CanControllerTimeQuanta means Sclock in below diagram. You can check more detail in Reference manual
2. FreqTq is equal 1/ Tq ? right? > Yes, It's correct
3. CanControllerTimeQuanta is same to Tq? > Yes, It's correct

Additional information: 


cuongnguyenphu_0-1656319314926.png

 

cuongnguyenphu_2-1656319596749.png

 

 

 

View solution in original post

0 Kudos
4 Replies
877 Views
cuongnguyenphu
NXP Employee
NXP Employee

Hi @liufei ,
Can you let us know which platform version you're working on? (you can capture information on Publish Information tab)
Be side of that, can you share me your Can config on EB Tresos?

0 Kudos
875 Views
liufei
Contributor III

Hi cuongnguyenphu,

Thanks for  reply,I have resolved this problem,

but I have some question about Can config setting,like this,

Can Controller Prescaller of description:

Prescaler = FreqCanClk / FreqTq; FreqTq = 1 / CanControllerTimeQuanta .

What dose CanControllerTimeQuanta mean?

FreqTq is equal 1/Tq? right?

CanControllerTimeQuanta is same to Tq?

Could you please answer it,thank you very much.

 

Best Regards,

Liufei

0 Kudos
852 Views
cuongnguyenphu
NXP Employee
NXP Employee

Hi @liufei 
As per Reference manual:
1. What dose CanControllerTimeQuanta mean?> Time-Quantum = one Sclock period. CanControllerTimeQuanta means Sclock in below diagram. You can check more detail in Reference manual
2. FreqTq is equal 1/ Tq ? right? > Yes, It's correct
3. CanControllerTimeQuanta is same to Tq? > Yes, It's correct

Additional information: 


cuongnguyenphu_0-1656319314926.png

 

cuongnguyenphu_2-1656319596749.png

 

 

 

0 Kudos
844 Views
liufei
Contributor III

Hi  cuongnguyenphu,

Thank you very much!

BestRegards,

Liu

 

0 Kudos