Hello,
I am trying to implement LIN functionality in the S12 BLDC Sensorless Motor control code. Upon start-up the motor should spin at 1000RPM. When integrating the LIN portion of the code the motor can no longer be controlled. From my testing the problem appears to be the Timer initialization through LIN in lin_lld_timesrv.c, specifically with channel 2:
If Channel 2 is enabled as an output compare with interrupts the motor functionality is lost. Commenting out either line of the code resolves the issue so my best guess is that an interrupt is flagged which never exits, hanging the program. I would like to debug further in codewarrior and check the registers and see if any interrupts are active. However, the debugger seems to not be able to handle the LIN module, as incorporating it causes a CRC issue when attempting to initiate a debug session so I'm at a bit of an impasse.
For reference, I have generated the LIN configuration(ldf and npf) portion following the reference from 'AN5122-Using NXP’s LIN Driver with the MagniV Family' and taken the LIN source code from the example code from "Develop LIN-based Actuator Applications with Mixed-signal MCUs" webinar
If anyone has questions or suggestions please reach out. Thanks.
Solved! Go to Solution.
Hi @blukacs,
I'm sorry for the delay.
Hard to say why the debugger crashers with that error, seems like this is not a runtime error after all.
Maybe you can start over with this application note:
Integrating the LIN driver with BLDC sensorless motor controller
https://www.nxp.com/docs/en/application-note/AN5201.pdf
AN5201SW attached
Regards,
Daniel
Hi @blukacs,
The BLDC demo uses Tim_Ch0 and Tim_Ch3, while the LIN driver Tim_Ch0 by default.
I understand you moved the LIN scheduler to Tim_Ch2, there should be no problem.
Can you test the Tim_Ch2 configuration stand-alone in a new project, or just the LIN driver with the Tim_Ch2 without the BLDC demo SW?
If I would guess based on the description, the execution runs away.
Can you implement something like this interrupt catcher to see if there is a machine exception, SPARE, TRAP, SWI, Spurious interrupt, etc instead of the Tim_Ch2?
Regards,
Daniel
Hi Daniel,
Thanks for the feedback and apologies for the late response.
I would take credit but the LIN scheduler came configured on Timer channel 2. It's the same story for the timer channels of the BLDC demo code.
I have tested a simple program that is only using the LIN driver (no BLDC control) to to read an up_down signal and report the status. In this case the program executes without issue.
I can try implementing the interrupt catcher code provided, though won't I still need the debugger to test? I haven't been able to use the debugger with the LIN drivers, thought I haven't tested it on a standalone LIN application yet.
Hi @blukacs,
I'm sorry for the delay.
Hard to say why the debugger crashers with that error, seems like this is not a runtime error after all.
Maybe you can start over with this application note:
Integrating the LIN driver with BLDC sensorless motor controller
https://www.nxp.com/docs/en/application-note/AN5201.pdf
AN5201SW attached
Regards,
Daniel
Hi Daniel,
This example worked for me. Now to figure out the differences between my implementation. Thanks very much.