Hi All
To drive a BLDC motor, I want to synchronize the PWM and ADC timings as shown in the figure below using MCXpresso Config Tools. I know that there "evkmimxrt1060_mc_pmsm" sample code but this code not works, so I want to setup peripheral using Config Tools.
The current problem is that the PWM output works well, but the ADC interrupt does not works.
So I would like to know how to set up ADC, ADC‗ETC, XBAR1 using Config Tools.
I don't know how to do it because there is almost no information on how to synchronize and how to set using Config Tools.
It would be helpful if there YouTube, online training and documents like STMicroelectronics.
I post my code below. In addition, the code that cannot be disclosed has been deleted.
Solved! Go to Solution.
Hi,
When start PWM, you set the output trig as
PWM_ActivateOutputTrigger(PWM1_PERIPHERAL, kPWM_Module_0, kPWM_ValueRegister_4);
I think is is not correct. TCTRL[OUT_TRIG_EN] has 6 bit. Each bit control a VALx comparator output. So, this function should be
PWM_ActivateOutputTrigger(PWM1_PERIPHERAL, kPWM_Module_0, 1<<kPWM_ValueRegister_4);
After the change, you can see the double trig disappear.
Regards,
Jing
Hi @kenji ,
Please refer to AN12200.
https://www.nxp.com/docs/en/nxp/application-notes/AN12200.pdf
And you can also refer to this topic.
https://community.nxp.com/t5/i-MX-RT/Trigger-ADC-with-PWM-on-IMX1064/m-p/1273086
Regards,
Jing
Thank you for the information. For now I could trigger ADC interrupt. But not work properly. I want to do 4CH ADC, synchronized with PWM's VAL4 compare.
Below is the ADC and PWM timing signals.
I want to do ADC for 4 -CH, once within one PWM cycle.
However, the ADC is doing the ADC regardless of the timing of VAL4 Compare.
High level period of the "ADC1 IRQ" signal in below figure, means that ADC1 IRQ Handler(void) function called.
My setting is like below, and I post my project.
Is there anything wrong with it?
[PWM1]
[ADC]
[ADC_ETC]
[ADC1_IRQHanler]
volatile uint32_t adcConversionValue[4];
void ADC1_IRQHandler(void)
{
DBG_OUT_CH1_SET_HIGH();
adcConversionValue[0] = ADC_GetChannelConversionValue(ADC1, 0U);
adcConversionValue[1] = ADC_GetChannelConversionValue(ADC1, 1U);
adcConversionValue[2] = ADC_GetChannelConversionValue(ADC1, 2U);
adcConversionValue[3] = ADC_GetChannelConversionValue(ADC1, 3U);
DBG_OUT_CH1_SET_LOW();
SDK_ISR_EXIT_BARRIER;
}
Hi,
AN12200 has software package. You can use its driver directly. It seems the ADC_ETC usage are same.
https://www.nxp.com/webapp/Download?colCode=AN12200SW&location=null
Regards,
Jing
Hi.
I have already referred to the AN12200 documentation and code, but synchronization of PWM and ADC doesn't work. ADC interrupt does not work. I get into ADC_ETC_ERROR_IRQ_IRQHandler.
Hi,
When start PWM, you set the output trig as
PWM_ActivateOutputTrigger(PWM1_PERIPHERAL, kPWM_Module_0, kPWM_ValueRegister_4);
I think is is not correct. TCTRL[OUT_TRIG_EN] has 6 bit. Each bit control a VALx comparator output. So, this function should be
PWM_ActivateOutputTrigger(PWM1_PERIPHERAL, kPWM_Module_0, 1<<kPWM_ValueRegister_4);
After the change, you can see the double trig disappear.
Regards,
Jing