芯片是rt1062, 我想使用eflexpwm外设来给ws2812发送数据波形,
配置如下:
* pwm频率设定为800khz
* initializationControl = kPWM_Initialize_LocalSync
* forceTrigger = kPWM_Force_Local
* reloadSelect = kPWM_LocalReload
* reloadLogic = kPWM_ReloadImmediate
数据波形的发生如下代码:
static void ws2812_ratio_update(uint8_t val)
{
uint16_t val_tran = 0;
/* 四舍五入,以提高准确性 */
val_tran = ((65535U * val) + 50U) / 100U;
PWM_UpdatePwmDutycycleHighAccuracy(PWM_BASE_WS2812, WS2812_PWM_SUBMODULE, WS2812_PWM_CHANNEL, kPWM_SignedCenterAligned, val_tran);
}
/**
* @author
* @brief
* @Param strip
* @return
* @note 每次调用color_flush的事件都应大于280us
*/
static ws2812_status_t color_flush(ws2812_strip_t *strip)
{
ws2812_status_t res = ws2812_ok;
for(uint8_t i = 0; i < WS2812_LED_NUM; i++)
{
for(uint8_t j = 0; j < TRI_COLOR_BITS; j++)
{
// 等待pwm重载完成
while(1)
{
if(PWM_GetStatusFlags(PWM_BASE_WS2812, WS2812_PWM_SUBMODULE) & kPWM_ReloadFlag)
{
break;
}
}
if((strip->out_color_data[i] >> (TRI_COLOR_BITS -1 - j)) & (0x01))
{
ws2812_ratio_update(WS2812_T1H_RATIO);
}
else
{
ws2812_ratio_update(WS2812_T0H_RATIO);
}
}
}
return res;
}
但是数据波形一直不能正确输出, 请问我该怎么做呢?
已解决! 转到解答。
HI @5angxr
I hope you are doing great, where you able play with the eflexPWM priority ? It seems that it is the lowest priority level in your system. You may want to increase its level.
There is documentation from ARM on interrupt handling techniques, for example this post that may help> https://developer.arm.com/documentation/dui0646/a/The-Cortex-M7-Processor/Exception-model/Interrupt-...
Try to isolate the issue, test without any other interrupts, see if we are really seing issues due to the interrupt being preempted.
On the other hand, If the eflexPWM interrupt needs to occur very often and all the time, you may opt for another way to configure the module, so that does need to operate with a interrupt method, in example combine it with PWM.
All the best,
Diego
现在已可以使用eFLEXPWM模块生成数据波形. 实现方式是在完成一个周期之后进入PWM的中断, 然后改变占空比.
不过, 现在遇到的问题是:
------
English:
Thank you for your reply @diego_charles
The eFLEXPWM module can now be used to generate data waveforms. This is achieved by entering a PWM interrupt after one cycle, and then changing the duty cycle.
However, here's the problem:
@diego_charles any commont on that?
Hi @5angxr
Thanks for your reply!
From which other modules are this other interrupts ?However, it could be the case that higher priority interrupt is wining over the eFlexPWM one. Try to increase the priority of eFlexPWM.
Btw, Is you application running an RTOS or bare-metal ?
All the best,
Diego
hello, @diego_charles
Thank you for your reply, and sorry for the late response.
There're timer(priority 3), lcdif(priority 3), gpio(priority 4), spi master(priority 1), spi slave(priority 1), another spi slave(priority 0), pit(priority 3), uart(priority 3), usb(priority 1) and eflexpwm(priority 5) interrupts.
my application is running an bare-metal.
It seems that my current interrupt priority configuration is a bit confusing, I'm wondering, how to set interrupt priority properly.
HI @5angxr
I hope you are doing great, where you able play with the eflexPWM priority ? It seems that it is the lowest priority level in your system. You may want to increase its level.
There is documentation from ARM on interrupt handling techniques, for example this post that may help> https://developer.arm.com/documentation/dui0646/a/The-Cortex-M7-Processor/Exception-model/Interrupt-...
Try to isolate the issue, test without any other interrupts, see if we are really seing issues due to the interrupt being preempted.
On the other hand, If the eflexPWM interrupt needs to occur very often and all the time, you may opt for another way to configure the module, so that does need to operate with a interrupt method, in example combine it with PWM.
All the best,
Diego
Hi @5angxr
I hope that you are doing excellent.
From what I translated to English it seems that the eflexpwm perihpheral is not generating the expected PWM output signal, when configured as you show.
However, could you provide more descriptions on your issue? Also, SDK version and if you are using our evaluation board are useful.
If my understanding is correct , I still recommend you to use our RT1062 eflexpwm example to see if we can replicate this issue.
All the best,
Diego.