PWM调光
1、使用有pwm波输出的引脚,本例子使用timer0,PA0引脚;

2、由于timer时钟的原因,mcu不能进入休眠;
3、主控使用EFM32,代码实现如下:
#define MAX_PULSE (CPU_FREQ/1000-1)
#define UNIT_PULSE MAX_PULSE/100 //单位脉宽
void pwminit(void)
{
GPIO_PinModeSet(gpioPortA,0,gpioModePushPull,0); //PA0
CMU_ClockEnable(cmuClock_TIMER0, true); //timer0时钟使能
TIMER_InitCC_TypeDef timerCCInit =
{
.eventCtrl = timerEventEveryEdge,
.edge = timerEdgeBoth,
.prsSel = timerPRSSELCh0,
.cufoa = timerOutputActionNone,
.cofoa = timerOutputActionNone,
.cmoa = timerOutputActionToggle,
.mode = timerCCModePWM,
.filter = true,
.prsInput = false,
.coist = false,
.outInvert = false,
};
TIMER_InitCC(TIMER0, 0, &timerCCInit); //初始
6538



被折叠的 条评论
为什么被折叠?



