MCToolbox for 5643L with CTU

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MCToolbox for 5643L with CTU

跳至解决方案
810 次查看
hongjinzeng
Contributor IV

Hi everyone,

  I use MCToolbox for 5643L establish a model,which contain PWM/CTU/ADC0.The PWM Frequency is 12.5Khz.The CTU has 4 ADC Trigger and trigger the ADC0_1 ADC0_2 ADC0_3 ADC0_4.The model and auto genetrate file is in the accessory.Then I download the elf file to the trk-usb-5643l.When I use Freemaster 1.4 to observe the veriable,the error like this:

206574_206574.pngpastedImage_1.png

If I delete trigger2 and trigger3 ,meanwhile set the trigger1 time to 45,the error disappear.The Freemaster work well.

But My project need 4 ADC trigger,I need help.

0 项奖励
1 解答
592 次查看
mariuslucianand
NXP Employee
NXP Employee

Hello zenghongjin@chegustech.com‌,

The FreeMaster works in polling mode, which means that inside the main loop the code checks if a FreeMaster request was received. If so, the controller sends a response. But if the model treats a lot of interrupts or an interrupt takes a lot of time to execute, it may end with no or less time allocated for the main loop, so no response for the FreeMaster.

After we took a closer look to your source code and your question (everything works if you use only two ADCs) we assume that ADC interrupt function takes too long because beside reading ADC raw values it also computes them.

So what we suggest is to modify the ISR function to just read the raw values, store them in global variables and move the averaging algorithm outside function. You can also add a flag variable that sets when exit the ISR function. In the main model you compute your values only if the flag was set. But not forget to reset it after every computation, to avoid the computation on every step of the model.

Hope this helps, 

Marius

在原帖中查看解决方案

0 项奖励
2 回复数
593 次查看
mariuslucianand
NXP Employee
NXP Employee

Hello zenghongjin@chegustech.com‌,

The FreeMaster works in polling mode, which means that inside the main loop the code checks if a FreeMaster request was received. If so, the controller sends a response. But if the model treats a lot of interrupts or an interrupt takes a lot of time to execute, it may end with no or less time allocated for the main loop, so no response for the FreeMaster.

After we took a closer look to your source code and your question (everything works if you use only two ADCs) we assume that ADC interrupt function takes too long because beside reading ADC raw values it also computes them.

So what we suggest is to modify the ISR function to just read the raw values, store them in global variables and move the averaging algorithm outside function. You can also add a flag variable that sets when exit the ISR function. In the main model you compute your values only if the flag was set. But not forget to reset it after every computation, to avoid the computation on every step of the model.

Hope this helps, 

Marius

0 项奖励
592 次查看
hongjinzeng
Contributor IV

Hi Marius,

  Thanks for your help.

0 项奖励