資源簡介
根據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
評論
共有 條評論