CAN Init

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

CAN Init

1,941 Views
Michael_Br
Contributor I

Hello,

I have a S32K146 an made a project using the SDK and the processor expert. The project has a timer pal and a CAN pal. I initialize the CAN pal in the main function. One message buffer for receive and one for tranceive messages. I tried to send messages with standard and extended IDs. No problem so far.

Now I want to put the CAN init functions into a "system_init" function. In this function the timer, can, gpios etc will be initalisied. The "system_init" function is called in the main routine. If I send a CAN message with extended ID, there is a message only with standard ID. If I send a message with standard ID, the message is a remote frame.

Am I making some mistakes or is initialisiation of CAN, Timer, etc only possible in the main function?

0 Kudos
Reply
6 Replies

1,904 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Michael_Br

It should be impossible, it may be that you have configured something wrong.

Have you refer to the routines "can_pal_s32k146"?

If it is convenient, you can send your code and I will help you debug it.

BR!

     Jim,

0 Kudos
Reply

1,894 Views
Michael_Br
Contributor I

Hey thank you for your repley.

Unfortunately I don't understand the first part of your reply. Before I add my code here, I would like to show you my two options:

 

Option Nr1 (same option as in can_pal_s32k146)

The CAN Init is done in the main routine. Works without any problems.

Option Nr2

The CAN Init is done in a extern function system_init. The function system_init is called in the main routine. Doesn't work.

Is option Nr 2 a valid option? Or do I have to do the init in the main routine?

0 Kudos
Reply

1,835 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Michael_Br

      please let me know if you have any updated on this issue.

BR!

     Jim,

0 Kudos
Reply

1,826 Views
Michael_Br
Contributor I

I made a simple test project with the problem I have. Every 10ms a CAN message is send. The CAN init is called in the main in two possible ways. If I call all functions directly in the main, everything works as it should. But If I put the CAN init in a function called CAN_Config() and call this in the main, I get a message with a standard ID instead of an extended.

Could you please check if you have the same problem with this project?

0 Kudos
Reply

1,791 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Michale_Br

  I tested the example code you provided,and I also encountered the same problem as you.

But if I modified the code like this,the problem disappeared.

Senlent_0-1638262147319.png

Still looking for the reason, it may be the reason of the variable.

BR!

     Jim,

 

0 Kudos
Reply

1,875 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Michael_Br

       I mean there is no difference between the second option and the first option, and both should working normally.

        and yes,you don't have to the init in the main routine.

 

        I may not be able to reply you in time, I will reply to your question next Monday.

BR!

       Jim,

0 Kudos
Reply