本文整理汇总了C++中TIM_SelectOutputTrigger函数的典型用法代码示例。如果您正苦于以下问题:C++ TIM_SelectOutputTrigger函数的具体用法?C++ TIM_SelectOutputTrigger怎么用?C++ TIM_SelectOutputTrigger使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIM_SelectOutputTrigger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TIM6_Config
/**
* @brief TIM6 Configuration
* @note TIM6 configuration is based on CPU @144MHz and APB1 @36MHz
* @note TIM6 Update event occurs each 36MHz/219 = 164.38 KHz
* @param None
* @retval None
*/
static void TIM6_Config(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
//NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the TIM6 gloabal Interrupt */
//NVIC_InitStructure.NVIC_IRQChannel = TIM6_DAC_IRQn;
//NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
//NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
//NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
//NVIC_Init(&NVIC_InitStructure);
/* TIM6 Periph clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
/* Time base configuration */
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
//TIM_TimeBaseStructure.TIM_Period = 750*2;
TIM_TimeBaseStructure.TIM_Period = 1125;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure);
/* TIM6 TRGO selection */
TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);
//TIM_ITConfig(TIM6, TIM_IT_Update, ENABLE);
/* TIM6 enable counter */
//TIM_Cmd(TIM6, ENABLE);
}
示例2: TIM2_Config
/**
* @brief Configures TIM2.
* @param None
* @retval None
*/
void TIM2_Config(void)
{
/* Enable TIM2 clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
TIM_DeInit(TIM2);
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 0xFF;
TIM_TimeBaseStructure.TIM_Prescaler = 0x1;
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);
/* Enable TIM2 Update Interrupt*/
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable TIM2 */
TIM_Cmd(TIM2,ENABLE);
}
示例3: timInit
void timInit() {
NVIC_InitTypeDef NVIC_InitStructure ;
NVIC_InitStructure . NVIC_IRQChannel = TIM3_IRQn;
NVIC_InitStructure . NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure . NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure . NVIC_IRQChannelCmd = ENABLE ;
NVIC_Init (& NVIC_InitStructure );
RCC_APB1PeriphClockCmd ( RCC_APB1Periph_TIM3 , ENABLE );
// configure timer TIM3 for tick every 1ms
// frequency = 100 hz with 168,000,000 hz system clock
// 168,000,000/16800 = 10000
// 10000/1000 = 10
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure ;
TIM_TimeBaseStructInit (& TIM_TimeBaseStructure );
TIM_TimeBaseStructure.TIM_Prescaler = 16800 -1; ; //10KHz
TIM_TimeBaseStructure.TIM_Period = 1000 -1; //10Hz
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up ;
TIM_TimeBaseInit (TIM3 , & TIM_TimeBaseStructure );
TIM_SelectOutputTrigger (TIM3 , TIM_TRGOSource_Update );
TIM_Cmd (TIM3 , ENABLE ); // Enable the tick timer
TIM_ITConfig (TIM3 , TIM_IT_Update , ENABLE ); // Enable Timer Interrupt , enable timer
}
示例4: tim2_config
static void tim2_config(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
/* TIM2 Periph clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
/* --------------------------------------------------------
TIM2 input clock (TIM2CLK) is set to 2 * APB1 clock (PCLK1), since
APB1 prescaler is different from 1 (see system_stm32f4xx.c and Fig
13 clock tree figure in DM0031020.pdf).
Sample rate Fs = 2*PCLK1/TIM_ClockDivision
= (HCLK/2)/TIM_ClockDivision
----------------------------------------------------------- */
/* Time base configuration */
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Period = 5250;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
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);
}
示例5: _TIM_Init
void _TIM_Init(void){
TIM_TimeBaseInitTypeDef TIM_BaseInitStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
//Enabling TIM clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); //to moze byc zle
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
//TIM1 configuration
TIM_BaseInitStructure.TIM_ClockDivision = 0;
TIM_BaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_BaseInitStructure.TIM_Period = 49999; //
TIM_BaseInitStructure.TIM_Prescaler = 5599; //5600 = 15 kHZ
TIM_BaseInitStructure.TIM_RepetitionCounter = 0x0000;
TIM_TimeBaseInit(TIM1, &TIM_BaseInitStructure);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Timing;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 49999;
TIM_OC1Init(TIM1, &TIM_OCInitStructure);
//Enabling TIM
TIM_ITConfig(TIM1, TIM_IT_CC1, ENABLE);
TIM_Cmd(TIM1, ENABLE);
TIM_BaseInitStructure.TIM_Prescaler = 5599;;
TIM_BaseInitStructure.TIM_Period = 1000;
TIM_BaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_BaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM6, &TIM_BaseInitStructure);
// TIM6 TRGO selection
TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);
// TIM6 enable counter
TIM_Cmd(TIM6, ENABLE);
}
示例6: TIM6_Config
/**
* @brief TIM6 Configuration
* @note TIM6 configuration is based on APB1 frequency
* @note TIM6 Update event occurs each TIM6CLK/256
* @param None
* @retval None
*/
static void TIM6_Config(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
/* TIM6 Periph clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
/* --------------------------------------------------------
TIM3 input clock (TIM6CLK) is set to 2 * APB1 clock (PCLK1),
since APB1 prescaler is different from 1.
TIM6CLK = 2 * PCLK1
TIM6CLK = HCLK / 2 = SystemCoreClock /2
TIM6 Update event occurs each TIM6CLK/256
Note:
SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file.
Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate()
function to update SystemCoreClock variable value. Otherwise, any configuration
based on this variable will be incorrect.
----------------------------------------------------------- */
/* Time base configuration */
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Period = 0xFF;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure);
/* TIM6 TRGO selection */
TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);
/* TIM6 enable counter */
TIM_Cmd(TIM6, ENABLE);
}
示例7: TIM_Config
/**
* @brief TIM3 configuration
* @param None
* @retval None
*/
static void TIM_Config(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
/* ADC1 Peripheral clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
TIM_DeInit(TIM3);
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_OCStructInit(&TIM_OCInitStructure);
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 0xFF;
TIM_TimeBaseStructure.TIM_Prescaler = 0x0;
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
/* TIM3 TRGO selection */
TIM_SelectOutputTrigger(TIM3, TIM_TRGOSource_Update);
/* TIM3 enable counter */
TIM_Cmd(TIM3, ENABLE);
}
示例8: main
int main(void) {
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_InitStructure;
ADC_InitTypeDef ADC_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOA | RCC_APB2Periph_ADC1, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
TIM_TimeBaseStructInit(&TIM_InitStructure);
TIM_InitStructure.TIM_Prescaler = 10000;
TIM_InitStructure.TIM_Period = 100;
TIM_InitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_InitStructure);
TIM_SelectOutputTrigger(TIM3, TIM_TRGOSource_Update);
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T3_TRGO;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 1, ADC_SampleTime_55Cycles5);
ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE);
ADC_ExternalTrigConvCmd(ADC1, ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = ADC1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
ADC_Cmd(ADC1, ENABLE);
while(ADC_GetResetCalibrationStatus(ADC1));
ADC_StartCalibration(ADC1);
while(ADC_GetCalibrationStatus(ADC1));
TIM_Cmd(TIM3, ENABLE);
if (SysTick_Config(SystemCoreClock / 1000))
while (1);
while(1);
}
示例9: SINE_4_EMS
void SINE_4_EMS(void) {
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructur;
/* TIM6 Configuration */
/* Time base configuration */
// 8kHz
TIM_TimeBaseStructInit(&TIM_TimeBaseStructur); ///Таймер для генерации синуса 4 KHz
TIM_TimeBaseStructur.TIM_Period = 200;
TIM_TimeBaseStructur.TIM_Prescaler = 0x0;
TIM_TimeBaseStructur.TIM_ClockDivision = 0;
TIM_TimeBaseStructur.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructur);
/* TIM7 TRGO selection */
TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);
/* DAC channel1 Configuration */
DAC_InitStructur.DAC_Trigger = DAC_Trigger_T6_TRGO;
DAC_InitStructur.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructur.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
DAC_Init(DAC_Channel_1, &DAC_InitStructur);
/* DMA2 channel3 configuration */
DMA_DeInit(DMA2_Channel3);
DMA_InitStructur.DMA_PeripheralBaseAddr = DAC_DHR8R1_Address;
DMA_InitStructur.DMA_MemoryBaseAddr = (uint32_t)&Sine12bit;
DMA_InitStructur.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructur.DMA_BufferSize = 90;
DMA_InitStructur.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructur.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructur.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructur.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructur.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructur.DMA_Priority = DMA_Priority_High;
DMA_InitStructur.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA2_Channel3, &DMA_InitStructur);
DMA_Cmd(DMA2_Channel3, ENABLE);
DAC_Cmd(DAC_Channel_1, ENABLE); // включить синус
DAC_DMACmd(DAC_Channel_1, ENABLE);
TIM_Cmd(TIM6, ENABLE);
}
示例10: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
/* System Clocks Configuration */
RCC_Configuration();
/* Once the DAC channel is enabled, the corresponding GPIO pin is automatically
connected to the DAC converter. In order to avoid parasitic consumption,
the GPIO pin should be configured in analog */
GPIO_Configuration();
/* TIM2 Configuration */
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Period = 0xF;
TIM_TimeBaseStructure.TIM_Prescaler = 0xF;
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);
/* DAC channel1 Configuration */
DAC_InitStructure.DAC_Trigger = DAC_Trigger_T2_TRGO;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_Triangle;
DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude = DAC_TriangleAmplitude_2047;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
/* DAC channel2 Configuration */
DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude = DAC_TriangleAmplitude_1023;
DAC_Init(DAC_Channel_2, &DAC_InitStructure);
/* Enable DAC Channel1: Once the DAC channel1 is enabled, PA.04 is
automatically connected to the DAC converter. */
DAC_Cmd(DAC_Channel_1, ENABLE);
/* Enable DAC Channel2: Once the DAC channel2 is enabled, PA.05 is
automatically connected to the DAC converter. */
DAC_Cmd(DAC_Channel_2, ENABLE);
/* Set DAC dual channel DHR12RD register */
DAC_SetDualChannelData(DAC_Align_12b_R, 0x100, 0x100);
/* TIM2 enable counter */
TIM_Cmd(TIM2, ENABLE);
while (1)
{
}
}
示例11: adc_injected
void adc_injected(int adc_trigger){
uint32_t injected_trigger = 0;
if(adc_trigger == ADC_TRIGGER_NONE){
adc_init_injected(DONT_USE_TRIGGER,injected_trigger);
}else{
if(adc_trigger == ADC_TRIGGER_TIMER2){
injected_trigger = ADC_ExternalTrigInjecConvEvent_2;
TIM_SelectOutputTrigger(TIM2,TIM_TRGOSource_Update);//OTRIG : Update
}else if(adc_trigger == ADC_TRIGGER_TIMER6){
injected_trigger = ADC_ExternalTrigInjecConvEvent_14;
TIM_SelectOutputTrigger(TIM6,TIM_TRGOSource_Update);//OTRIG : Update
}else if(adc_trigger == ADC_TRIGGER_TIMER15){
injected_trigger = ADC_ExternalTrigInjecConvEvent_15;
TIM_SelectOutputTrigger(TIM15,TIM_TRGOSource_Update);//OTRIG : Update
}
adc_init_injected(USE_TRIGGER,injected_trigger);
}
ADC_StartInjectedConversion(ADC1);
}
示例12: DAC_Config
void DAC_Config(void)
{
DAC_RCC_Configuration();
/* Once the DAC channel is enabled, the corresponding GPIO pin is automatically
connected to the DAC converter. In order to avoid parasitic consumption,
the GPIO pin should be configured in analog */
DAC_GPIO_Configuration();
/* TIM6 Configuration */
TIM_PrescalerConfig(TIM6, 0x3, TIM_PSCReloadMode_Update);
TIM_SetAutoreload(TIM6, 0xF);
/* TIM6 TRGO selection */
TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);
/* DAC channel1 Configuration */
DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
for (int i = 0; i < 128; i++)
{
ModSine12bit[i] = Sine12bit[i] / 2 + 1023;
}
DMA_DeInit(DMA2_Channel3);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) &DAC->DHR12R1;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t) &ModSine12bit;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 128;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA2_Channel3, &DMA_InitStructure);
/* Enable DMA2 Channel3 */
DMA_Cmd(DMA2_Channel3, ENABLE);
/* Enable DAC Channel1: Once the DAC channel1 is enabled, PA.04 is
automatically connected to the DAC converter. */
DAC_Cmd(DAC_Channel_1, ENABLE);
/* Enable DMA for DAC Channel1 */
DAC_DMACmd(DAC_Channel_1, ENABLE);
/* TIM6 enable counter */
TIM_Cmd(TIM6, ENABLE);
}
示例13: main
/**
* @brief Main program.
* @param None
* @retval : None
*/
int main(void)
{
/* System Clocks Configuration */
RCC_Configuration();
/* Once the DAC channel is enabled, the corresponding GPIO pin is automatically
connected to the DAC converter. In order to avoid parasitic consumption,
the GPIO pin should be configured in analog */
GPIO_Configuration();
/* TIM6 Configuration */
TIM_PrescalerConfig(TIM6, 0xF, TIM_PSCReloadMode_Update);
TIM_SetAutoreload(TIM6, 0xFF);
/* TIM6 TRGO selection */
TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);
/* DAC channel1 Configuration */
DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
/* DMA2 channel3 configuration */
DMA_DeInit(DMA2_Channel3);
DMA_InitStructure.DMA_PeripheralBaseAddr = DAC_DHR8R1_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&Escalator8bit;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 6;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA2_Channel3, &DMA_InitStructure);
/* Enable DMA2 Channel3 */
DMA_Cmd(DMA2_Channel3, ENABLE);
/* Enable DAC Channel1: Once the DAC channel1 is enabled, PA.04 is
automatically connected to the DAC converter. */
DAC_Cmd(DAC_Channel_1, ENABLE);
/* Enable DMA for DAC Channel1 */
DAC_DMACmd(DAC_Channel_1, ENABLE);
/* TIM6 enable counter */
TIM_Cmd(TIM6, ENABLE);
while (1)
{
}
}
示例14: TIM2_Config
void TIM2_Config(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Period = 32000000 / 8000;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_SelectOutputTrigger(TIM2, TIM_TRGOSource_Update);
}
示例15: initial_tim8
void initial_tim8(void) {
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8, ENABLE);
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_Prescaler = 1;
TIM_TimeBaseStructure.TIM_Period = 36000;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
TIM_SelectOutputTrigger(TIM8, TIM_TRGOSource_Update);
TIM_SelectOnePulseMode(TIM8, TIM_OPMode_Single);
}