Hello,When I tested MTRCKTSBNZVM128_CW11 software,I found that when CAN receiveing a new data in interrupt,Sometimes the bldc will be stopped,and the fault is overcurrent,I wonder if the interruption time is too long,so I remove it to main() function,this is my change:
After I changed the code,bldc can work stable when receive datas,No fualt happened。but I found the data I receive from CAN0RXDLR_DLC and CAN0RXDSR_ARR was not correctly enough,I sent data five times,only one data is right。
Hello Monke,
could you please let me know how did you set up the CAN interrupt priority? See initInt(void) function.
As you mentioned the critical is the execution of motor control routines at the exact time.
Therefore the interrupts with longer execution times and lower priority are designed as nested interrupts - could be interrupted by interrupts with higher priority.
For example, the TIMchan3_ISR(void) contains the command EnableInterrupts; right on the beginning of ISR - that will allow interrupting by higher priority ISRs.
So, the implementation of the right interrupt level and interrupt nesting might help you to tune the application.
Please be also careful with the commands like CAN0RFLG_RXF=1;. This type of command will do the read-modify-write operation and automatically clear all pending flags in this register. Including Overrun Interrupt Flag. This isn't typically issued in the case of CAN but could be quite painful e.g. in the case of timer flag registers.
The right command for flag clearing is for example CAN0RFLG_RXF = 0x01; or CAN0RFLG_RXF = CAN0RFLG_RXF_MASK;
See AN2554 for more details about clearing flags.
interrupt priority:
INT_CFADDR = 0x50;
INT_CFDATA4 = 0x04;
INT_CFDATA5 = 0x04;