资源简介
根据STM32F1系列建立固件的步骤,自己建了个F3的固件库模板,方便大家使用。里面附带一个DAC输出例程。
代码片段和文件信息
#include “bsp_dac.h“
TIM_TimebaseInitTypeDef TIM_TimebaseStructure;
DAC_InitTypeDef DAC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
const uint16_t Sine12bit[32] = {
2047 2447 2831 3185 3498 3750 3939 4056 4095 4056
3939 3750 3495 3185 2831 2447 2047 1647 1263 909
599 344 155 38 0 38 155 344 599 909
1263 1647};
const uint8_t Escalator8bit[6] = {0x0 0x33 0x66 0x99 0xCC 0xFF};
uint8_t Idx = 0;
__IO uint8_t SelectedWavesForm = 1;
__IO uint8_t WaveChange = 1;
/* Private function prototypes -----------------------------------------------*/
static void DAC_Config(void);
static void TIM_Config(void);
/**
* @brief TIM2 configuration to trigger DAC conversion
* @param None
* @retval None
*/
static void TIM_Config(void)
{
TIM_TimebaseInitTypeDef TIM_TimebaseStructure;
/* TIM2 Periph clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 ENABLE);
/* Time base configuration */
TIM_TimebaseStructInit(&TIM_TimebaseStructure);
TIM_TimebaseStructure.TIM_Period = 1000-1; //100us*1000
TIM_TimebaseStructure.TIM_Prescaler = 720-1;//7200-1; //100
TIM_TimebaseStructure.TIM_ClockDivision = 0x0;
TIM_TimebaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimebaseInit(TIM2 &TIM_TimebaseStructure);
/* TIM2 TRGO selection */
TIM_SelectOutputTrigger(TIM2 TIM_TRGOSource_Update);
/* TIM2 enable counter */
TIM_Cmd(TIM2 ENABLE);
}
/**
* @brief DAC channels configurations (PA4 and PA5 in analog
* enable DAC clock enable DMA2 clock)
* @param None
* @retval None
*/
static void DAC_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* DMA2 clock enable (to be used with DAC) */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2 ENABLE);
/* DAC Periph clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC ENABLE);
/* GPIOA clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA ENABLE);
/* Configure PA.05 (DAC_OUT1) as analog */
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);
}
void DAC_Test_init(void)
{
TIM_Config();
DAC_Config();
/* DAC channel2 Configuration */
DAC_DeInit(DAC1);
DAC_InitStructure.DAC_Trigger = DAC_Trigger_T2_TRGO;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_Buffer_Switch = DAC_BufferSwitch_Disable;
/* DAC Channel2 Init */
DAC_Init(DAC1 DAC_Channel_2 &DAC_InitStructure);
/* Enable DAC Channel2 */
DAC_Cmd(DAC1 DAC_Channel_2 ENABLE);
/* DMA2 channel3 configurati
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 211 2018-09-08 17:13 STM32F3_Template\bsp\inc\bsp_dac.h
文件 5197 2018-09-09 16:45 STM32F3_Template\bsp\src\bsp_dac.c
文件 726626 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Include\stm32f30x.h
文件 2208 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Include\system_stm32f30x.h
文件 24343 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Release_Notes.html
文件 23799 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\arm\startup_stm32f302x8.s
文件 26343 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\arm\startup_stm32f303xc.s
文件 27310 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\arm\startup_stm32f303xe.s
文件 26339 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\arm\startup_stm32f30x.s
文件 22159 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\arm\startup_stm32f334x8.s
文件 13163 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\gcc_ride7\startup_stm32f30x.s
文件 21190 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\iar\startup_stm32f302x8.s
文件 23551 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\iar\startup_stm32f303xc.s
文件 24856 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\iar\startup_stm32f303xe.s
文件 23547 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\iar\startup_stm32f30x.s
文件 21307 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\iar\startup_stm32f334x8.s
文件 14043 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\system_stm32f30x.c
文件 11442 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\TrueSTUDIO\startup_stm32f302x8.s
文件 12969 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\TrueSTUDIO\startup_stm32f303xc.s
文件 13784 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\TrueSTUDIO\startup_stm32f303xe.s
文件 12967 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\TrueSTUDIO\startup_stm32f30x.s
文件 12054 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\TrueSTUDIO\startup_stm32f334x8.s
文件 8440 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\DSP_Lib\Examples\arm_class_marks_example\ARM\arm_class_marks_example_f32.c
文件 8440 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\DSP_Lib\Examples\arm_class_marks_example\GCC\arm_class_marks_example_f32.c
文件 11097 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\DSP_Lib\Examples\arm_convolution_example\ARM\arm_convolution_example_f32.c
文件 10962 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\DSP_Lib\Examples\arm_convolution_example\ARM\math_helper.c
文件 3085 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\DSP_Lib\Examples\arm_convolution_example\ARM\math_helper.h
文件 11097 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\DSP_Lib\Examples\arm_convolution_example\GCC\arm_convolution_example_f32.c
文件 10962 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\DSP_Lib\Examples\arm_convolution_example\GCC\math_helper.c
文件 3085 2015-07-08 19:34 STM32F3_Template\Libraries\CMSIS\DSP_Lib\Examples\arm_convolution_example\GCC\math_helper.h
............此处省略656个文件信息
- 上一篇:外汇网站整站源码
- 下一篇:二人斗地主-cocs2d-lua
相关资源
- STM32F3参考手册
- lpc1766_Keil工程模板及配套例程
- 基于STM32F303,单芯片方案的3轴云台设
- STM32F302工程模板,包含HAL库和CMSIS-R
- stm32f3标准固件库
- STM32LL库使用指南工程模板
- STM32F412工程模板
- STM32F105_Temp工程模板
- xcode4创建dylib动态库的demo和工程模板
- rt_thread_nano_stm32f30x
- STM32F3使用ADC转换DMA模式传输数据
- STM32F103用IAR编译的工程模板
- stm32F3+LTC6802G_1电池管理系统——的电
- STM32F334数字电源设计
- STM8工程模板史上最完整版
- STM32L151工程模板.rar
- 基于STM32F334同步整流BUCK-BOOST数字电源
- STM32F302_STM32F303数据手册
- GD32F1x0 工程模板v3.1.0.0
- STM32F334数据手册
- MPU6500+QMC5883L驱动程序,基于STM32F3x编
- 软件工程模板.rar
- STM32F303RET6官方例程.zip
- stm32F107模板工程
- Keil.STM32F3xx_DFP.2.1.0.pack
- 基于STM32F3xx 的LSM303DLHC程序
- MSP432工程模板
- 1.stm32f429寄存器工程模板练习
- STM32F427VITx工程模板
评论
共有 条评论