MCToolbox for 5643L with CTU

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MCToolbox for 5643L with CTU

ソリューションへジャンプ
818件の閲覧回数
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 解決策
600件の閲覧回数
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 返答(返信)
601件の閲覧回数
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 件の賞賛
600件の閲覧回数
hongjinzeng
Contributor IV

Hi Marius,

  Thanks for your help.

0 件の賞賛