Dear All
I am trying to implement FlexCAN Communication and I wanted to implement and handle errors on CAN bus. When we view on any CAN analyzer we observe bus errors. I wanted to implement the same.
CAN_ESR1 register for MPC5744P information
Question
How can we read the register and how can we configure CAN_CTRL1 register and get ISR?
BOFFMSK Interrupt
ERRMSK Interrupt
TWRNMSK Interrupt
RWRNMSK Interrupt
We need this ti fully implement CAN communication.
Best Regards,
Abhishek
mariuslucianandrei ext-rafael.barbosa@chassisbrakes.com
Solved! Go to Solution.
Hello abhishek.kumar@chassisbrakes.com,
You'll have to go to the root directory of the toolbox and run from there the mbd_mpc_path script. After you run it succesfuly, you'll no longer have the other problem.
Kind regards,
Razvan.
Hello abhishek.kumar@chassisbrakes.com,
You could use read/write register blocks (that you can find in the Utilities part of our library):
You can use these blocks to configure every peripheral, every register that you'd like to (not limited to CAN only). Note that you must be careful for other prerequisites peripherals might have (such as enabling the clocks for it - disregarded, will cause the application to crash). What I want to point out is that although this block gives you full control, you must be wary of other (peripheral dependent) aspects.
In your case, if you want to set CTRL1 register, you could use the write register block inside a Initialize function block,
but make sure to set the priority is set accordingly (you write to CTRL1 after the CAN configuration blocks writes to it) - otherwise your settings would be overwritten.
As for the error handling, we currently do not support it - all other events besides the errors are handled by our toolbox. I'll get back to you on how we can work around this issue in a few days - maybe we'll consider adding support for it in our next release.
Kind regards,
Razvan.
Dear mariuslucianandrei,
Thanks for the input but I get the error when I get the Write_Register block.
Somehow, It looks into MPC5748G folder instead of MPC5744P folder. It fails to find a mat file.
Best Regards
Abhishek
Hello again abhishek.kumar@chassisbrakes.com,
I understand from gabriela_catana that this issue might be fixed by resetting the path for our toolbox - could you do that and let us know if it fixes it? We're going to investigate this issue nonetheless.
For resetting the path:
restoredefaultpath;
mbd_mpc_path();
Kind regards,
Razvan.
Hello abhishek.kumar@chassisbrakes.com,
It seems now it does not see the functions - did you run mbd_mpc_path as well? If yes, could you run again the same 3 commands as before (and write the values of devicePath, deviceName and peripheralList)?
Kind regards,
Razvan.
Dear constantinrazvan.chivu
Please see, I think restoredefaultpath somehow changed the target path.
>> restoredefaultpath
>> mbd_mpc_path
Undefined function or variable 'mbd_mpc_path'.
>> mbd_mpc_path()
Undefined function or variable 'mbd_mpc_path'.
>> mbd_mpc_path();
Undefined function or variable 'mbd_mpc_path'.
>> devicePath = mbd_mpc_find_target_path(fullfile('mbdtbx_mpc', 'devices'))
Undefined function or variable 'mbd_mpc_find_target_path'.
Hello abhishek.kumar@chassisbrakes.com,
You'll have to go to the root directory of the toolbox and run from there the mbd_mpc_path script. After you run it succesfuly, you'll no longer have the other problem.
Kind regards,
Razvan.
Dear constantinrazvan.chivu
It works
Hello abhishek.kumar@chassisbrakes.com,
That is a strange behavior indeed - can you run some commands in the MATLAB terminal and share the output with us?
devicePath = mbd_mpc_find_target_path(fullfile('mbdtbx_mpc', 'devices'));
deviceName = mbd_mpc574x_get_target_mcu();
peripheralList = dir(fullfile(devicePath, deviceName, 'registers', '*.mat'));
If you could let us know what values these 3 variables have would be helpful in debugging this issue.
Kind regards,
Razvan.
p.s.: mariuslucianandrei is the guy you usually talk to; I'm the guy you sometimes talk to :smileyhappy:
Dear constantinrazvan.chivu
Please see the results
deviceName : 'MPC5744P'
devicePath: C:\Users\XXXXXX\Documents\MATLAB\AddOns\Toolboxes\NXP_MBDToolbox_MPC57xx\mbdtbx_mpc\devices\MPC5748G\registers
peripheralList is empty
peripheralList =
0×1 empty struct array with fields:
name
folder
date
bytes
isdir
datenum
Beat Regards,
Abhishek