问答

汇集网友智慧,解决技术难题

21ic问答首页 - TAG - timer
  • 哪位大声有HC32L176的TIMER5+DMA来驱动11个WS2812B灯的程序 sos 赏800家园币

    目前调试了一个版本,DMA更改占空比时会出现第一个占空比丢失的情况,比如占空比位[16,16,16,44,44,16,16,44,44],输出的PWM波形会出现只有[16,16,16,44,16,44]这样的,每次占空比值变化时就会丢失。 求一个可用的程序。

    HC timer ws2812b 11 DMA HC32L176

    5183浏览量 0回复量 关注量
  • GD32F103T8U6配置PWM输出,无输出。

    #define M_G_U GPIOA #define M_G_V GPIOA #define M_G_W GPIOB #define M_G_P_U GPIO_PIN_6 #define M_G_P_V GPIO_PIN_7 #define M_G_P_W GPIO_PIN_0 #define M_G_UN GPIOA #define M_G_VN GPIOA #define M_G_WN GPIOA #define M_G_P_UN GPIO_PIN_3 #define M_G_P_VN GPIO_PIN_4 #define M_G_P_WN GPIO_PIN_5 #define M_G_FAULT GPIOB #define M_G_P_FAULT GPIO_PIN_1 #define M_G_SLEEP GPIOB #define M_G_P_SLEEP GPIO_PIN_2 #define H_G_A GPIOA #define H_G_B GPIOA #define H_G_C GPIOA #define H_G_P_A GPIO_PIN_0 #define H_G_P_B GPIO_PIN_1 #define H_G_P_C GPIO_PIN_2 rcu_periph_clock_enable(RCU_GPIOA); rcu_periph_clock_enable(RCU_AF); timer_parameter_struct timer_initpara; timer_oc_parameter_struct timer_ocintpara; gpio_init(M_G_U, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, M_G_P_U); gpio_init(M_G_V, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, M_G_P_V); gpio_init(M_G_W, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, M_G_P_W); gpio_init(M_G_UN, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, M_G_P_UN); gpio_init(M_G_VN, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, M_G_P_VN); gpio_init(M_G_WN, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, M_G_P_WN); gpio_init(M_G_FAULT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, M_G_P_FAULT); gpio_init(M_G_SLEEP, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, M_G_P_SLEEP); gpio_bit_reset(M_G_UN, M_G_P_UN); gpio_bit_reset(M_G_VN, M_G_P_VN); gpio_bit_reset(M_G_VN, M_G_P_WN); gpio_bit_set(M_G_FAULT, M_G_P_FAULT); gpio_bit_set(M_G_SLEEP, M_G_P_SLEEP); rcu_periph_clock_enable(RCU_TIMER2); timer_deinit(TIMER2); // timer_struct_para_init(&timer_initpara); timer_initpara.prescaler = 1 - 1; timer_initpara.period = 5000 - 1; timer_initpara.alignedmode = TIMER_COUNTER_EDGE; timer_initpara.counterdirection = TIMER_COUNTER_UP; timer_initpara.clockdivision = TIMER_CKDIV_DIV1; timer_initpara.repetitioncounter = 0; timer_init(TIMER2, &timer_initpara); // timer_channel_output_struct_para_init(&timer_ocintpara); timer_ocintpara.ocidlestate = TIMER_CCX_ENABLE; timer_ocintpara.ocpolarity = TIMER_OC_POLARITY_HIGH; timer_ocintpara.outputstate = TIMER_OC_IDLE_STATE_LOW; timer_ocintpara.ocnidlestate = TIMER_CCXN_DISABLE; timer_ocintpara.ocnpolarity = TIMER_OCN_POLARITY_HIGH; timer_ocintpara.outputnstate = TIMER_OCN_IDLE_STATE_LOW; timer_channel_output_config(TIMER2, TIMER_CH_0, &timer_ocintpara); timer_channel_output_config(TIMER2, TIMER_CH_1, &timer_ocintpara); timer_channel_output_config(TIMER2, TIMER_CH_2, &timer_ocintpara); timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_0, 2500 - 1); timer_channel_output_mode_config(TIMER2, TIMER_CH_0, TIMER_OC_MODE_PWM0); timer_channel_output_shadow_config(TIMER2, TIMER_CH_0, TIMER_OC_SHADOW_DISABLE); timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_1, 2500 - 1); timer_channel_output_mode_config(TIMER2, TIMER_CH_1, TIMER_OC_MODE_PWM0); timer_channel_output_shadow_config(TIMER2, TIMER_CH_1, TIMER_OC_SHADOW_DISABLE); timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_2, 2500 - 1); timer_channel_output_mode_config(TIMER2, TIMER_CH_2, TIMER_OC_MODE_PWM0); timer_channel_output_shadow_config(TIMER2, TIMER_CH_2, TIMER_OC_SHADOW_DISABLE); timer_channel_output_fast_config(TIMER2, TIMER_CH_0, TIMER_OC_FAST_ENABLE); timer_channel_output_clear_config(TIMER2, TIMER_CH_0, TIMER_OC_CLEAR_ENABLE); timer_channel_output_polarity_config(TIMER2, TIMER_CH_0, TIMER_OC_POLARITY_HIGH); timer_channel_output_state_config(TIMER2, TIMER_CH_0, TIMER_CCX_ENABLE); timer_automatic_output_enable(TIMER2); timer_primary_output_config(TIMER2, ENABLE); timer_auto_reload_shadow_enable(TIMER2); timer_enable(TIMER2); gpio_init(H_G_A, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, H_G_P_A); gpio_init(H_G_B, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, H_G_P_B); gpio_init(H_G_C, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, H_G_P_C);

    IO pi timer TI PWM输出 gd32F103

    1306浏览量 1回复量 关注量
  • MM32G0001A 2个Timer各出1PWM 设置占空比不同 实际结果确一样

    MM32G0001A 使用两个定时器 TIM14和TIM3 各出一路PWM 设置不一样的占空比 但是实际结果确一样 哪里设置有问题吗? void TIM3_Configure(void) { GPIO_InitTypeDef GPIO_InitStruct; TIM_OCInitTypeDef TIM_OCInitStruct; TIM_TimeBaseInitTypeDef TIM_TimeBaseStruct; /* Compute the value to be set in ARR regiter to generate signal frequency at 100 Khz */ uint32_t TimerPeriod = (TIM_GetTIMxClock(TIM3) / 5000 ) - 1; /* Compute CCR1 value to generate a duty cycle at 80% for channel 1 */ uint32_t Channel1Pulse = ((uint32_t)800 * (TimerPeriod - 1)) / 1000; RCC_APB1PeriphClockCmd(RCC_APB1ENR_TIM3, ENABLE); TIM_TimeBaseStructInit(&TIM_TimeBaseStruct); TIM_TimeBaseStruct.TIM_Prescaler = 0; TIM_TimeBaseStruct.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseStruct.TIM_Period = TimerPeriod; TIM_TimeBaseStruct.TIM_ClockDivision = TIM_CKD_Div1; TIM_TimeBaseStruct.TIM_RepetitionCounter = 0; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStruct); TIM_OCStructInit(&TIM_OCInitStruct); TIM_OCInitStruct.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStruct.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStruct.TIM_Pulse = 0; TIM_OCInitStruct.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OCInitStruct.TIM_OCIdleState = TIM_OCIdleState_Set; TIM_OCInitStruct.TIM_Pulse = Channel1Pulse; TIM_OC1Init(TIM3, &TIM_OCInitStruct); RCC_AHBPeriphClockCmd(RCC_AHBENR_GPIOA, ENABLE); GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_3); /* TIM1_CH1 */ GPIO_StructInit(&GPIO_InitStruct); GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_High; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStruct); TIM_Cmd(TIM3, ENABLE); TIM_CtrlPWMOutputs(TIM3, ENABLE); } /*********************************************************************************************************************** * @brief * [url=home.php?mod=space&uid=536309]@NOTE[/url] none * @param none * @retval none *********************************************************************************************************************/ void TIM14_Configure(void) { GPIO_InitTypeDef GPIO_InitStruct; TIM_OCInitTypeDef TIM_OCInitStruct; TIM_TimeBaseInitTypeDef TIM_TimeBaseStruct; /* Compute the value to be set in ARR regiter to generate signal frequency at 100 Khz */ uint32_t TimerPeriod = (TIM_GetTIMxClock(TIM14) / 5000 ) - 1; /* Compute CCR1 value to generate a duty cycle at 80% for channel 1 */ uint32_t Channel1Pulse = ((uint32_t)500 * (TimerPeriod - 1)) / 1000; RCC_APB1PeriphClockCmd(RCC_APB1ENR_TIM14, ENABLE); TIM_TimeBaseStructInit(&TIM_TimeBaseStruct); TIM_TimeBaseStruct.TIM_Prescaler = 0; TIM_TimeBaseStruct.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseStruct.TIM_Period = TimerPeriod; TIM_TimeBaseStruct.TIM_ClockDivision = TIM_CKD_Div1; TIM_TimeBaseStruct.TIM_RepetitionCounter = 0; TIM_TimeBaseInit(TIM14, &TIM_TimeBaseStruct); TIM_OCStructInit(&TIM_OCInitStruct); TIM_OCInitStruct.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStruct.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStruct.TIM_Pulse = 0; TIM_OCInitStruct.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OCInitStruct.TIM_OCIdleState = TIM_OCIdleState_Set; TIM_OCInitStruct.TIM_Pulse = Channel1Pulse; TIM_OC1Init(TIM14, &TIM_OCInitStruct); RCC_AHBPeriphClockCmd(RCC_AHBENR_GPIOA, ENABLE); GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_3); /* TIM1_CH1 */ GPIO_StructInit(&GPIO_InitStruct); GPIO_InitStruct.GPIO_Pin = GPIO_Pin_9; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_High; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStruct); TIM_Cmd(TIM14, ENABLE); TIM_CtrlPWMOutputs(TIM14, ENABLE); }

    ST 1A MM32G0001 占空比 PWM timer

    1094浏览量 1回复量 关注量
  • HC32F4A0,timer4_1输出U,V,W互补pwm信号的软件demo,有参考的吗? sos

    HC32F4A0,timer4_1输出U,V,W互补pwm信号的软件demo,有参考的吗?

    软件 信号 timer PWM demo HC32F4A0

    1819浏览量 0回复量 关注量
  • GD32F103外部脉冲计数

    参照GD32例程写了一个使用定时器对外部脉冲进行计数,无法正常运行,通一个芯片,使用STM32的库,ETR计数没有问题,求解

    国产芯片 GD32 timer SD32F103

    2336浏览量 1回复量 关注量
  • CCS3.3 编译问题

    我是个初学者,不明白这是怎么错的,请问这个怎么修改呀?----------------------------- Timer.pjt - Debug ----------------------------- [Timer.c] "D:\342G\CCS_3.3.83.20_Platinum\C5400\cgtools\bin\cl500" -g -fr"D:/342G/CCS_3.3.83.20_Platinum/MyProjects/Timer/Debug" -i"D:/342G/CCS_3.3.83.20_Platinum/MyProjects/Timer" -i"D:/342G/CCS_3.3.83.20_Platinum/C5400/csl/include" -d"_DEBUG" -d"CHIP_5441" -v548 -@"Debug.lkf" "Timer.c" [Linking...] "D:\342G\CCS_3.3.83.20_Platinum\C5400\cgtools\bin\cl500" -@"Debug.lkf" undefined first referenced symbol in file --------- ---------------- __GPIO_pinDirection D:\\342G\\CCS_3.3.83.20_Platinum\\MyProjects\\Timer\\Debug\\Timer.obj __GPIO_pinEnable D:\\342G\\CCS_3.3.83.20_Platinum\\MyProjects\\Timer\\Debug\\Timer.obj __PGIO_pinWrite D:\\342G\\CCS_3.3.83.20_Platinum\\MyProjects\\Timer\\Debug\\Timer.obj error: unresolved symbols remain error: errors encountered during linking; "./Debug/Lab2_Timer.out" not built >> Compilation failure Build Complete, 1 Errors, 0 Warnings, 0 Remarks.

    DSP 技术交流 编译 CCS3.3 TI timer

    877浏览量 2回复量 关注量
  • 求GD32E230 PWM互补模式的设置

    TIMER0用于电机驱动的3路PWM互补模式

    PWM GD32E230 timer 电机 电机驱动 TIMER0

    3879浏览量 2回复量 关注量
  • GD32f10x写flash时,程序中断进入

    需要让一些数据可以掉电保存,于使将这些数据写入到flash中,设置一个timer隔一段时间溢出,在写flash期间中断无法进入

    flash GD32F10X gd32f1 timer TI

    2370浏览量 1回复量 关注量
  • 请教新唐M483SIDAE这款芯片的定时器问题

    [img]file:///C:/Users/admin%E3%80%81/Desktop/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202021-09-27%20103333.png[/img]使用TIMER_OPEN(TIMER0,TIMER_PERIODIC_MODE,1); 函数代表初始化TIMER0,周期性模式,每一秒进一次中断,这个1s可否直接更改为1us,或者1ms,如果可以 是否是说要更改预分频与比较寄存器的值来更改,这个1不用动;还是说有其他办法直接修改

    定时器 芯片 新唐 TI timer TIMER0

    5531浏览量 1回复量 关注量
  • 使用GD32F4 高级定时器timer和timer7产生PWM。 sos

    在使用GD32F450单片机中用高级定时器timer0和timer7产生PWM是没有出现pwm信号,到底是什么原因呢?这其中有什么特别需要注意的吗?

    国产芯片 PWM timer 定时器 信号 单片机

    3516浏览量 0回复量 关注量
  • [HDSC][HC32L110B6]advanced timer 做PWM比较输出遇到的问题

    做一个简单的呼吸灯,使用advance Timer的比较输出做PWM来使用,通过调整GCMxR的值来改变PWM的占空比,从而改变灯的亮度。现在遇到的问题是灯偶尔会亮闪一下,请问在其他定时器中断中不能更改GCMxR的值吗??

    HDSC advanced hd hc32l110 timer PWM

    1621浏览量 2回复量 关注量
  • GD32E230使用高级定时器的比较输出 赏100家园币

    [color=#383a42][backcolor=rgb(249, 249, 249)][size=16px][color=#0098dd]初始化的时候就死机了,不知道怎么使用高级定时器的比较输出模式[/color] [color=#0098dd]void[/color] [color=#23974a]b_timer_config[/color][color=#7a82da]([/color][color=#d52753]uint16_t[/color] [color=#40b8c5]__pres[/color][color=#7a82da],[/color] [color=#d52753]uint16_t[/color] [color=#40b8c5]__period[/color][color=#7a82da],[/color] [color=#d52753]uint16_t[/color] [color=#40b8c5]__pulse[/color][color=#7a82da])[/color] [color=#7a82da]{[/color] [color=#a0a1a7]// timer_oc_parameter_struct timer_ocinitpara;[/color] [color=#d52753]timer_parameter_struct[/color] timer_initpara[color=#7a82da];[/color] [color=#d52753]timer_break_parameter_struct[/color] timer_breakpara[color=#7a82da];[/color] [color=#23974a]rcu_periph_clock_enable[/color][color=#7a82da]([/color]RCU_TIMER0[color=#7a82da]);[/color] [color=#23974a]timer_deinit[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da]);[/color] [color=#23974a]timer_struct_para_init[/color][color=#7a82da](&[/color]timer_initpara[color=#7a82da]);[/color] timer_initpara[color=#7a82da].[/color][color=#a05a48]prescaler[/color] [color=#7a82da]=[/color] [color=#40b8c5]__pres[/color][color=#7a82da];[/color] timer_initpara[color=#7a82da].[/color][color=#a05a48]alignedmode[/color] [color=#7a82da]=[/color] [color=#23974a]TIMER_COUNTER_EDGE[/color][color=#7a82da];[/color] timer_initpara[color=#7a82da].[/color][color=#a05a48]counterdirection[/color] [color=#7a82da]=[/color] [color=#23974a]TIMER_COUNTER_UP[/color][color=#7a82da];[/color] timer_initpara[color=#7a82da].[/color][color=#a05a48]period[/color] [color=#7a82da]=[/color] [color=#40b8c5]__period[/color][color=#7a82da];[/color] [color=#a0a1a7]// 10KHz[/color] timer_initpara[color=#7a82da].[/color][color=#a05a48]clockdivision[/color] [color=#7a82da]=[/color] [color=#23974a]TIMER_CKDIV_DIV1[/color][color=#7a82da];[/color] timer_initpara[color=#7a82da].[/color][color=#a05a48]repetitioncounter[/color] [color=#7a82da]=[/color] [color=#ce33c0]0[/color][color=#7a82da];[/color] [color=#23974a]timer_init[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color][color=#23974a] [/color][color=#7a82da]&[/color]timer_initpara[color=#7a82da]);[/color] [color=#a0a1a7]// timer_channel_output_struct_para_init(&timer_ocinitpara);[/color] [color=#a0a1a7]// timer_ocinitpara.outputstate = TIMER_CCX_ENABLE;[/color] [color=#a0a1a7]// timer_ocinitpara.outputnstate = TIMER_CCXN_DISABLE;[/color] [color=#a0a1a7]// timer_ocinitpara.ocpolarity = TIMER_OC_POLARITY_HIGH;[/color] [color=#a0a1a7]// timer_ocinitpara.ocnpolarity = TIMER_OCN_POLARITY_HIGH;[/color] [color=#a0a1a7]// timer_ocinitpara.ocidlestate = TIMER_OC_IDLE_STATE_LOW;[/color] [color=#a0a1a7]// timer_ocinitpara.ocnidlestate = TIMER_OCN_IDLE_STATE_LOW;[/color] [color=#a0a1a7]// timer_channel_output_config(TIMER0, TIMER_CH_0, &timer_ocinitpara);[/color] [color=#23974a]timer_break_struct_para_init[/color][color=#7a82da](&[/color]timer_breakpara[color=#7a82da]);[/color] timer_breakpara[color=#7a82da].[/color][color=#a05a48]runoffstate[/color] [color=#7a82da]=[/color] [color=#23974a]TIMER_ROS_STATE_ENABLE[/color][color=#7a82da];[/color] timer_breakpara[color=#7a82da].[/color][color=#a05a48]ideloffstate[/color] [color=#7a82da]=[/color] [color=#23974a]TIMER_IOS_STATE_ENABLE[/color][color=#7a82da];[/color] timer_breakpara[color=#7a82da].[/color][color=#a05a48]deadtime[/color] [color=#7a82da]=[/color] [color=#ce33c0]164[/color][color=#7a82da];[/color] timer_breakpara[color=#7a82da].[/color][color=#a05a48]breakpolarity[/color] [color=#7a82da]=[/color] [color=#23974a]TIMER_BREAK_POLARITY_LOW[/color][color=#7a82da];[/color] timer_breakpara[color=#7a82da].[/color][color=#a05a48]outputautostate[/color] [color=#7a82da]=[/color] [color=#23974a]TIMER_OUTAUTO_ENABLE[/color][color=#7a82da];[/color] timer_breakpara[color=#7a82da].[/color][color=#a05a48]protectmode[/color] [color=#7a82da]=[/color] [color=#23974a]TIMER_CCHP_PROT_OFF[/color][color=#7a82da];[/color] timer_breakpara[color=#7a82da].[/color][color=#a05a48]breakstate[/color] [color=#7a82da]=[/color] [color=#23974a]TIMER_BREAK_ENABLE[/color][color=#7a82da];[/color] [color=#23974a]timer_break_config[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color][color=#23974a] [/color][color=#7a82da]&[/color]timer_breakpara[color=#7a82da]);[/color] [color=#23974a]timer_channel_output_pulse_value_config[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color][color=#23974a] [/color][color=#23974a]TIMER_CH_0[/color][color=#7a82da],[/color][color=#23974a] [/color][color=#40b8c5]__pulse[/color][color=#7a82da]);[/color] [color=#23974a]timer_channel_output_mode_config[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color][color=#23974a] [/color][color=#23974a]TIMER_CH_0[/color][color=#7a82da],[/color][color=#23974a] [/color][color=#23974a]TIMER_OC_MODE_PWM0[/color][color=#7a82da]);[/color] [color=#a0a1a7]// timer_channel_output_shadow_config(TIMER0, TIMER_CH_0, TIMER_OC_SHADOW_DISABLE);[/color] [color=#a0a1a7]// timer_primary_output_config(TIMER0, ENABLE);[/color] [color=#23974a]nvic_irq_enable[/color][color=#7a82da]([/color]TIMER0_Channel_IRQn[color=#7a82da],[/color][color=#23974a] [/color][color=#ce33c0]1[/color][color=#7a82da]);[/color] [color=#23974a]timer_interrupt_enable[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color][color=#23974a] [/color][color=#23974a]TIMER_INT_CH0[/color][color=#7a82da]);[/color] [color=#23974a]timer_interrupt_disable[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color][color=#23974a] [/color][color=#23974a]TIMER_INT_BRK[/color][color=#7a82da]);[/color] [color=#23974a]timer_auto_reload_shadow_enable[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da]);[/color] [color=#23974a]timer_enable[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da]);[/color] [color=#7a82da]}[/color] [color=#0098dd]void[/color] [color=#23974a]TIMER0_IRQHandler[/color][color=#7a82da]([/color][color=#0098dd]void[/color][color=#7a82da])[/color] [color=#7a82da]{[/color] [color=#0098dd]static[/color] [color=#d52753]uint8_t[/color] status [color=#7a82da]=[/color] [color=#ce33c0]0[/color][color=#7a82da];[/color] [color=#0098dd]if[/color] [color=#7a82da]([/color]SET [color=#7a82da]==[/color] [color=#23974a]timer_interrupt_flag_get[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color][color=#23974a] [/color][color=#23974a]TIMER_INT_CH0[/color][color=#7a82da]))[/color] [color=#7a82da]{[/color] status[color=#7a82da]++;[/color] [color=#0098dd]switch[/color] [color=#7a82da]([/color]status [color=#7a82da]%[/color] [color=#ce33c0]3[/color][color=#7a82da]){[/color] [color=#0098dd]case[/color] [color=#ce33c0]0[/color][color=#7a82da]:[/color] [color=#23974a]printf[/color][color=#7a82da]([/color][color=#c5a332]"a[/color][color=#df631c]\n[/color][color=#c5a332]"[/color][color=#7a82da]);[/color] [color=#23974a]timer_channel_output_pulse_value_config[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color] [color=#23974a]TIMER_CH_0[/color][color=#7a82da],[/color] tim[color=#7a82da][[/color][color=#23974a]B[/color].[color=#a05a48]idle[/color][color=#7a82da]);[/color] [color=#23974a]timer_channel_output_pulse_value_config[/color][color=#7a82da]([/color][color=#23974a]TIMER15[/color][color=#7a82da],[/color] [color=#23974a]TIMER_CH_0[/color][color=#7a82da],[/color] [color=#ce33c0]0[/color][color=#7a82da]);[/color] [color=#0098dd]break[/color][color=#7a82da];[/color] [color=#0098dd]case[/color] [color=#ce33c0]1[/color][color=#7a82da]:[/color] [color=#23974a]printf[/color][color=#7a82da]([/color][color=#c5a332]"b[/color][color=#df631c]\n[/color][color=#c5a332]"[/color][color=#7a82da]);[/color] [color=#23974a]timer_channel_output_pulse_value_config[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color] [color=#23974a]TIMER_CH_0[/color][color=#7a82da],[/color] tim[color=#7a82da][[/color][color=#23974a]B[/color].[color=#a05a48]t_off[/color][color=#7a82da]);[/color] [color=#23974a]timer_channel_output_pulse_value_config[/color][color=#7a82da]([/color][color=#23974a]TIMER15[/color][color=#7a82da],[/color] [color=#23974a]TIMER_CH_0[/color][color=#7a82da],[/color] [color=#ce33c0]0[/color][color=#7a82da]);[/color] [color=#0098dd]break[/color][color=#7a82da];[/color] [color=#0098dd]case[/color] [color=#ce33c0]2[/color][color=#7a82da]:[/color] [color=#23974a]printf[/color][color=#7a82da]([/color][color=#c5a332]"c[/color][color=#df631c]\n[/color][color=#c5a332]"[/color][color=#7a82da]);[/color] [color=#23974a]timer_channel_output_pulse_value_config[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color] [color=#23974a]TIMER_CH_0[/color][color=#7a82da],[/color] tim[color=#7a82da][[/color][color=#23974a]B[/color].[color=#a05a48]t_on[/color][color=#7a82da]);[/color] [color=#23974a]timer_channel_output_pulse_value_config[/color][color=#7a82da]([/color][color=#23974a]TIMER15[/color][color=#7a82da],[/color] [color=#23974a]TIMER_CH_0[/color][color=#7a82da],[/color] pwm_ch[color=#7a82da][[/color][color=#23974a]B[/color].[color=#a05a48]pulse[/color][color=#7a82da]);[/color] [color=#0098dd]break[/color][color=#7a82da];[/color] [color=#0098dd]default[/color][color=#7a82da]:[/color] [color=#0098dd]break[/color][color=#7a82da];[/color] [color=#7a82da]}[/color] [color=#23974a]timer_interrupt_flag_clear[/color][color=#7a82da]([/color][color=#23974a]TIMER0[/color][color=#7a82da],[/color][color=#23974a] [/color][color=#23974a]TIMER_INT_CH0[/color][color=#7a82da]);[/color] [color=#7a82da]}[/color] [color=#7a82da]}[/color] [/size][/backcolor][/color]

    定时器 GD32E230 TI timer ni TE

    16976浏览量 10回复量 关注量
  • GD32E230的定时器读出值和CNT寄存器不一致 sos

    如题,用的是TIMER2的输入捕获,能进中断,但是用timer_counter_read(TIMER2);函数读出的值与仿真中CNT中的值差别非常大IO的初始代码 /*config input capture io alternate */ gpio_mode_set(GPIOB, GPIO_MODE_AF, GPIO_PUPD_PULLUP, GPIO_PIN_0|GPIO_PIN_1); gpio_af_set(GPIOB,GPIO_AF_1,GPIO_PIN_0); gpio_af_set(GPIOB,GPIO_AF_4,GPIO_PIN_1); TIMER2初始化代码 void timer2_inital(void) { timer_parameter_struct timer_parameter; timer_ic_parameter_struct timer_ic_parameter; rcu_periph_clock_enable(RCU_TIMER2); timer_parameter.alignedmode = TIMER_COUNTER_EDGE; timer_parameter.clockdivision = TIMER_CKDIV_DIV1; timer_parameter.counterdirection = TIMER_COUNTER_UP; timer_parameter.period = 0xffff; timer_parameter.prescaler = 24; timer_parameter.repetitioncounter =0; timer_init(TIMER2,&timer_parameter); timer_ic_parameter.icfilter =0; timer_ic_parameter.icpolarity = TIMER_IC_POLARITY_RISING; timer_ic_parameter.icprescaler = TIMER_IC_SELECTION_DIRECTTI; timer_ic_parameter.icselection = TIMER_IC_PSC_DIV1; timer_input_capture_config(TIMER2,TIMER_CH_2,&timer_ic_parameter); /* enable and set TIMER2 interrupt */ nvic_irq_enable(TIMER2_IRQn, 1U); timer_auto_reload_shadow_enable(TIMER2); timer_interrupt_enable(TIMER2,TIMER_INT_CH2); timer_enable(TIMER2); } 请大侠们诊断下,问题出在什么地方

    GD32E230 寄存器 定时器 TI timer

    3010浏览量 0回复量 关注量
  • 赛元单片机触摸没反应,新手求带。。。

    按照指南操作静态码调试正常,在我的板子上从Touch key Tool Menu图表窗口可以看到手触摸的时候波形变化,也成功变成绿色,但是不知道怎么调试动态,因为静态是用的他们官网下载的静态码直接烧录就可以了,而动态没有直接烧录的码,要从自己的代码里面做进去,就复杂了,按照他们指南操作下来弄了一天硬是一点反应没有,求大哥大姐指导: //************************************************************ // Copyright (c) 深圳市赛元微电子有限公司 // 文件名称 : main.c // 作者 : Yanni // 模块功能 : SC91F8311触控DEMO // 最后更正日期: // 版本 : 2015-12-25: // : //************************************************************* #include "h\SC92F836XB_C.h" #include #include "h\data_type.h" #include "lib\SensorMethod.h" #define _TOUCHKEY_DEBUG_ #ifdef _TOUCHKEY_DEBUG_ #include "SOC_DebugTouchKey_Lib\SOC_DebugTouchKey.h" #endif #define nop _nop_(); //??? //*****************全局变量区*************************************************** INT32U exKeyValueFlag = 0; //当前轮按键标志 INT8U Timercount = 0; //定时器计数 //BOOL TimerFlag_1ms = 0; //定时器1MS标志 uchar a,b,c; //*****************全局变量区*************************************************** BOOL TimerFlag_1s,TimerFlag_1ms,TimerFlag_10s = 0; //定时器1MS标志 INT8U Flag_1s ,Flag_1ms,Flag_10s=0; INT8U gTkIsValid = 0; //按键有效标志 INT8U exKeyValue = 0; //当前轮按键键值 INT8U KeyValue = 0; //按键键值 sbit sda=P2^5; //TM1640??? sbit scl=P2^6; //TM1640??? uchar dis[]={0xFE,0x30,0xD5,0x75,0x39,0x6F,0xEF,0x34,0xFF,0x7F,0xBF,0xFF,0xCE,0xF3,0xCF,0x8F,0xFF,0xff};//??? // //0 1 2 3 4 5 6 7 8 9 a b c d e f ?? ?? void delay(INT16U z) //????? { uint x,y; for(x=z;x>0;x--) for(y=487;y>0;y--); } //*********START*********************************************** void start() //1640?? { sda=1; nop nop scl=1; nop nop sda=0; } //************************************************************** void stop() //1640?? { scl=0; nop nop sda=0; scl=1; nop nop sda=1; nop nop } //*********************************************************** void write(uchar date) //1640??? { uchar i; for(i=0;i<8;i++) { scl=0; if(date&0x01) { sda=1; nop nop } else { sda=0; nop nop } scl=1; nop date=date>>1; } } //**************?TM1640??????*************************** void send(uchar T,uchar time,uchar led) { uchar i; start(); write(0x44); //设置芯片工作模式,这里选地址自动加1 stop(); start(); write(0xc0);//设置首地址,数码管的位选值 for(i=0;i<16;i++)//地址自加不必每次都写地址,传输显示数据,最多16字节不能多写 { if(i==0)write(dis[T/100]); //GRID1 if(i==1)write(dis[T/10%10]); //GRID2 if(i==2)write(dis[T%10]); //GRID3 if(i==3)write(dis[time/10]); //GRID4 if(i==4)write(dis[time%10]); //GRID5 if(i==5)write(led&0xff); //GRID6 if(i==6)write(0x00); if(i==7)write(0x00); if(i==8)write(led&0xff); //GRID9 if(i==9)write(0x00); if(i==10)write(0x00); if(i==11)write(0x00); if(i==12)write(0x00); if(i==13)write(0x00); if(i==14)write(0x00); if(i==15)write(led&0xff);//GRID16 delay(20); } stop(); start(); write(0x89); //亮度选择 stop(); } /************************************************** *函数名称:void TimerInit(void) *函数功能:定时器初始化 *入口参数:void *出口参数:void **************************************************/ void TimerInit(void) { TMCON = (TMCON&0xfe)|(0<<0); //bit0: 0为FOSC/12,1为FOSO TMOD = TMOD&0xf0; //设置定时0,工作方式0 TMOD = TMOD|0x00; TH0=(8192-1000)/32; //1000*1=1000us ,1MS TL0=(8192-1000)%32; TF0 = 0; //清中断标志 TR0=0; //关定时器0 ET0=1; //使能定时器0中断 TR0=1; } /************************************************** *函数名称:void timer0()interrupt 1 *函数功能:定时器中断服务函数 *入口参数:void *出口参数:void **************************************************/ void timer0()interrupt 1 { TH0 = (8192-1000)/32; //2000*1/4us=500us TL0 = (8192-1000)%32; TimerFlag_1ms = 1; } /************************************************** *函数名称:void Sys_Init(void) *函数功能:系统初始化 *入口参数:void *出口参数:void **************************************************/ void Sys_Init(void) { WDTCON = 0x10; //1--1 -- 00 开WDT,WDT清0,WDT 524.288ms溢出;烧录时,可Code Option选择ENWDT //TK对应的IO设置为强推挽输出1 P0CON = 0xFF; P0PH = 0xFF; P1CON = 0xFF; P1PH = 0xFF; P2CON = 0xFF; P2PH = 0xFF; P0 = 0xFF; P1 = 0xFF; P2 = 0xFF; P5 = 0x00; EA = 1; //开总中断 TimerInit(); //定时器初始化 } /************************************************** *函数名称:void ChangeTouchKeyvalue(void) *函数功能:转换TK键值 *入口参数:void *出口参数:void **************************************************/ void ChangeTouchKeyvalue(void) { switch(exKeyValueFlag) { //不同间距不同大小的按键 case 0x00000001:exKeyValue = 1;break; case 0x00000002:exKeyValue = 2;break; case 0x00000004:exKeyValue = 3;break; case 0x00000006:exKeyValue = 4;break; case 0x0000001f:exKeyValue = 5;break; default:exKeyValue = 0xff;break; } } /************************************************** *函数名称:void UpdateLcdBufFunc(void) *函数功能:更新显示数据函数 *入口参数:void *出口参数:void **************************************************/ void UpdateLcdBufFunc(void) { if(exKeyValue != 0xff) {a++; if(gTkIsValid == 0) //松手前只出一次键 { gTkIsValid = 1; KeyValue=exKeyValue; switch(KeyValue) { //不同间距不同大小的按键 case 1:a++; //break; case 2:b=55;break; case 3:c=11;break; case 4:b=26;break; case 5:c=1;break; default:exKeyValue = 0xff;break; } } } else { gTkIsValid = 0; } } /************************************************** *函数名称:void Sys_Scan(void) *函数功能:扫描TK和显示 *入口参数:void *出口参数:void **************************************************/ /* void Sys_Scan(void) { if(SOCAPI_TouchKeyStatus&0x80) //重要步骤2: 触摸键扫描一轮标志,是否调用TouchKeyScan()一定要根据此标志位置起后 { SOCAPI_TouchKeyStatus &= 0x7f; //重要步骤3: 清除标志位, 需要外部清除。 exKeyValueFlag = TouchKeyScan();//按键数据处理函数 TouchKeyRestart(); //启动下一轮转换 } } */ /************************************************** *函数名称:void Sys_Scan(void) *函数功能:扫描TK和显示 *入口参数:void *出口参数:void **************************************************/ void Sys_Scan(void) { if(SOCAPI_TouchKeyStatus&0x80) //重要步骤2: 触摸键扫描一轮标志,是否调用TouchKeyScan()一定要根据此标志位置起后 { SOCAPI_TouchKeyStatus &= 0x7f; //重要步骤3: 清除标志位, 需要外部清除。 exKeyValueFlag = TouchKeyScan();//按键数据处理函数 ChangeTouchKeyvalue(); //转换键值 UpdateLcdBufFunc(); //更新显示数据 TouchKeyRestart(); //启动下一轮转换 } } /************************************************** *函数名称:void main(void) *函数功能:主函数 *入口参数:void *出口参数:void **************************************************/ void main(void) { Sys_Init();//触控按键初始化 #ifdef _TOUCHKEY_DEBUG_SOCAPI_ DeBugTouchKey_Init(); #endif TouchKeyInit(); while(1) { WDTCON = 0x10; send(a,b,c); //if(exKeyValueFlag==0) if(TimerFlag_1ms==1) { TimerFlag_1ms=0; Timercount++; if(Timercount>10) { Timercount=0; Sys_Scan(); } } } }

    触摸 单片机 ST TI timer

    1140浏览量 4回复量 关注量
  • 我的捕获程序只能进一次中断怎么办求大神 sos

    void setclock(void) { WDTCTL = WDTPW + WDTHOLD; // watchdog timer setup if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF) { while(1); // If cal constants erased, trap CPU!! } BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation IFG1 &= ~OFIFG; } void settimer(){ TACTL=TACLR; TACTL=TASSEL_2+MC_2; TACCTL1=CM_3+CCIS_0+CAP+CCIE; TACCTL1&=~CCIFG; _EINT(); } void setgpio(){ P1DIR=0X01; P1OUT=0X01; P1SEL=BIT2+BIT1; } void main(void) { setclock(); setgpio(); settimer(); while(1); } #pragma vector=TIMER0_A1_VECTOR __interrupt void Timer_A (void) { if(TACCTL1&CCIFG){ TACCTL1&=CCIFG; //CC=CCR1-C; //C=CCR1; P1OUT^=BIT0; } }

    se AC TI timer hz

    793浏览量 0回复量 关注量
12下一页