I'm using S32K344 with MATLAB MBDT. I’ve set up CAN RX and TX using Can_MainFunction_Read/Write, IRQ handler, and CanIf_RxIndication
I do not currently have debugging set up—only flashing is available. So, to confirm RX, I'm transmitting back the received data. However, RX is never triggered—no IRQ hits or loopback response observed on the bench.
Can you confirm:
Required .mex settings for RX HRH in polling mode other than the following?
Any specific interrupt or object mappings needed for RX IRQ to trigger in MBDT?
Hello,
First of all, can you share with me what MATLAB version do you use and what version of the toolbox did you install?
In the Model Based Design Toolbox for S32K3, there are two example that might help you develop your application:
- s32k3xx_can_receive_s32ct: Shows how to receive CAN messages with interrupts. When a message is received, an onboard LED is toggled.
- s32k342_can_transmit_s32ct: Shows how to send CAN messages and increments a counter every time a message is successfully send.
The later example is configured for a S32K342 board, but you can take a look at the example to see the workflow. Further details about these examples can be found inside the help file (html files), located next to the model.
Regarding your screenshots:
An example implementation can look like below. If a CAN message with ID = 10 (decimal) is received, a CAN message with ID = 255 (decimal) is sent back to the CAN bus. Data is echoed.
RECEIVED_ID & FILTER_MASK = FILTER_CODE & FILTER_MASK
Best regards,
Sorin Bancila
I’m using MATLAB 2023a with MBDT v1.5. I’ve already reviewed the provided examples, but without a debugger, I’m unable to verify if CAN RX or the ISR is actually working, and the examples haven’t helped much in this case.
I tried the RX→TX loopback setup shown in your screenshots, but the TX isn't triggering back either. Could you help with possible reasons?
Also, since Simulink doesn’t expose any CanHardwareObject selection, how does the ISR determine which HRH to use internally?
Lastly, how should the Can Hw Filter Code be configured to allow receiving a wide or generic range of extended IDs — for example, all PGNs starting with 0x18, or to receive all messages?
Hello,
1. One way to verify if the ISR is triggered without a debugger is to increment a variable inside the triggered subsystem and visualize it in the FreeMASTER.
2. To test the CAN using the loopback you need to do the following:
3. The ISR block doesn't allow to select which CanHardwareObject to use when triggering an interrupt. All the CanHardwareObject trigger the same interrupt and you need to implement in Simulink the logic to sort them by the HardwareObject ID.
4. To receive all messages, The Can Hw Filter Code and Can Hw Filter mask must be set to 0. If you want to accept only a range of IDs, please check the original reply. Below you have a few examples with the MASK set to 3 and FILTER_CODE to 1. For case 1, 3, 4 the message is received, whereas for the case 2, the message ID isn't received. All the numbers below are represented in binary form to better illustrate the workflow.
Best regards,
Sorin Bancila