主题中讨论的其他器件:MSPM0L1306、 MSPM0G3507
工具与软件:
尊敬的论坛:
都需要您在一个任务中提供支持。
我想为 LED 0至100%呼吸、我尝试 timx_timer_mode_pwm_edge_sleep 示例、但没有出现任何情况。 然后、我尝试了 timx_timer_mode_periodic_standby_LP_MSPM0L1306_nortos_ticlang 这个示例、但也需要您的帮助。
请建议我如何处理此任务。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具与软件:
尊敬的论坛:
都需要您在一个任务中提供支持。
我想为 LED 0至100%呼吸、我尝试 timx_timer_mode_pwm_edge_sleep 示例、但没有出现任何情况。 然后、我尝试了 timx_timer_mode_periodic_standby_LP_MSPM0L1306_nortos_ticlang 这个示例、但也需要您的帮助。
请建议我如何处理此任务。
以下是来自 MSPM0G3507 adctopwm 示例的代码。 它应该可以让您快速入门。
#define ADC_MINIMUM_VALUE 500 #include "ti_msp_dl_config.h" volatile bool gCheckADC; volatile uint32_t gCCV; volatile uint16_t gAdcResult; int main(void) { SYSCFG_DL_init(); NVIC_EnableIRQ(ADC12_0_INST_INT_IRQN); DL_Timer_setCaptCompUpdateMethod(PWM_0_INST, GPTIMER_CCCTL_01_CCUPD_ZERO_EVT, DL_TIMER_CC_0_INDEX); /* Start our ADC conversion and PWM Timers */ DL_Timer_startCounter(TIMER_0_INST); DL_Timer_startCounter(PWM_0_INST); gCheckADC = false; while (1) { __WFI(); if (gCheckADC) { gCheckADC = false; gAdcResult = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_0); /* Check if the gAdcResult is above the minmum threshold */ if (gAdcResult > ADC_MINIMUM_VALUE) { /* Start counter in case it was previously stopped. */ DL_Timer_startCounter(PWM_0_INST); /* Do necessary ADC-to-PWM scaling here: */ /* Here we just map the ADC Result from 0 to 100% of the Load Value */ gCCV = DL_Timer_getLoadValue(PWM_0_INST)*gAdcResult/4096; /* CC Value will update on the next zero event */ DL_TimerG_setCaptureCompareValue(PWM_0_INST, DL_Timer_getLoadValue(PWM_0_INST)-gCCV, DL_TIMER_CC_0_INDEX); } else { /* If gAdcResult is not above minmum value then disable timer */ DL_TimerG_stopCounter(PWM_0_INST); } } } } void ADC12_0_INST_IRQHandler(void) { switch (DL_ADC12_getPendingInterrupt(ADC12_0_INST)) { case DL_ADC12_IIDX_MEM0_RESULT_LOADED: gCheckADC = true; break; default: break; } DL_ADC12_enableConversions(ADC12_0_INST); }