请教各位大神,我在用STM32F302R8 Nucleo板的TIM2定时器更新DAC时,LED2总是不亮,反复看了好几遍也不知道哪里出了问题,求大神们看一下,本人是枚菜鸟 static void TriangleWave_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure); } /************************************************************* *************************************************************/ static void TriangleWave_TIM_Init(void) { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);//???TIM2??? TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);//???????? TIM_TimeBaseStructure.TIM_Period = 10000-1;//????100 TIM_TimeBaseStructure.TIM_Prescaler = 720-1;//???? TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;//????? TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;//??? TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);//???TIM2 TIM_SelectOutputTrigger(TIM2, TIM_TRGOSource_Update);//??????????,??????,?????DAC?? TIM_Cmd(TIM2, ENABLE);//????? } /************************************************************* *************************************************************/ static void TriangleWave_DAC_Init(void) { DAC_InitTypeDef DAC_InitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);//???DAC?? DAC_InitStructure.DAC_Buffer_Switch=DAC_BufferSwitch_Disable; //?????,??? DAC_InitStructure.DAC_Trigger=DAC_Trigger_T2_TRGO; //???2???? DAC_InitStructure.DAC_WaveGeneration=DAC_WaveGeneration_None; //??? DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bits2_0;//???????????,?????? DAC_Init(DAC1,DAC_Channel_2,&DAC_InitStructure); DAC_Cmd(DAC1, DAC_Channel_2, ENABLE); } /************************************************************* *************************************************************/ void TriangleWave_Init(void) { TriangleWave_GPIO_Init(); TriangleWave_TIM_Init(); TriangleWave_DAC_Init(); } 以下是main()函数内容 int main(void) { TriangleWave_Init(); while(1) { DAC_SetChannel2Data(DAC1,DAC_Align_12b_R,4000); } } 我感觉是DAC设置得有问题,但是又找不出哪里的问题 |
STM32F3 硬件I2C 驱动OLED 求助!!
STM32F303使用定时器触发双ADC常规同步采样模式
哪位大哥传下STM32F334 Nucleo的工程模板给我下
STM32F334 不能串口下载
关于STM32F334的HRTIM分辨率问题
STM32F303+LCD1602程序问题,不只为什么点不亮?
STM32F334的ADC使用问题
STM32F334 HRTIM形成移相全桥波形问题
有用过STM32F373VC的板子么 iic 例程不好使
STM32F3 ADC外部触发采样达不到7.2MSPS
D13呼吸灯
#include "mbed.h"
AnalogOut led(D13);//DAC
float ledvalue=1.0;
int main()
{
while (1)
{
while(1)
{
led.write(ledvalue);
wait (0.5);
ledvalue=ledvalue-0.1;
if (ledvalue<0.1)
break;
}
}
}
评分
查看全部评分
https://www.stmcu.org.cn/module/forum/thread-601838-1-1.html
评分
查看全部评分