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:
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.
Solved! Go to Solution.
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
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
Hi Marius,
Thanks for your help.