问答

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

21ic问答首页 - TAG - 定时器
  • 51单片机

    就是设置单片机定时器/计数器时,那个TMOD用汇编语言输入什么数据能设置其工作方式,例如MOV TMOD,#11H什么意思

    51单片机 定时 定时器 汇编 汇编语言 计数器

    6066浏览量 12回复量 关注量
  • 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

    3133浏览量 8回复量 关注量
  • AT32F407 编码器 sos

    使用的是AB两线编码器 AT32F407的TMR2,TMR3,TMR4,TMR5,四个定时器最多支持多少个这样的编码器 下载视频

    编码 编码器 定时 定时器

    376浏览量 0回复量 关注量
  • 定时器工作不正常

    MCU型号:STM32F103VCT6,用定时器TIM8, TIM2, TIM4的正交编码器模式计数,模式为编码器模式3,4倍频方波计数。有2点: 1、函数初始化都是一个,唯独TIM2不计数,其他2个都正常 2、早起版本也正常 新版本和旧版本就程序没有差别,可以肯定程序代码是拷贝过来的,没有做什么修改,在同一块板子上试出现的这个问题,只是最近系统重装过,KEIL V5.30版本。 升级旧版本的程序,还是能正常工作 就是不明白为什么会这样,是否系统原因呢? 不知道有没有哪个大咖陪到过类似的问题,请指教,谢谢先

    定时器 TI 编码器 编码 STM32F103VC

    368浏览量 1回复量 关注量
  • 为什么按下S5后定时器没有打开去掉nowshidu=dat_rd1*20就可以了

    #include #include"ds1302.h" #include"iic.h" sbit S7=P3^0; sbit S6=P3^1; sbit S5=P3^2; sbit S4=P3^3; unsigned char dat_rd2; unsigned char kaiguan=0; unsigned char shidu=50; //初始湿度 unsigned char nowshidu; //当前湿度 unsigned char code table[]={0xc0,0xf9,0xA4,0xB0,0x99,0x92,0x82,0xF8, 0x80,0x90,0x88,0x83,0xA7,0xA1,0x86,0x8E,0xbf,0x7f}; unsigned char write[]={0x80,0x82,0x84,0x86,0x88,0x8a,0x8c}; unsigned char read[]={0x81,0x83,0x85,0x87,0x89,0x8b,0x8d}; unsigned char Time[]={0x16,0x30,0x08,0x02,0x16,0x02,0x21}; void delayms(unsigned char x) { unsigned char i; while(x--) { for(i=0;i<113;i++); } } void select (unsigned char n) { switch(n) { case 4: P2=(P2&0x1f)|0x80; break; case 5: P2=(P2&0x1f)|0xa0; break; case 6: P2=(P2&0x1f)|0xc0; break; case 7: P2=(P2&0x1f)|0xe0; break; } } void guanbi() { select(5); P0=0x00; select(4); P0=0xff; } void DS1302_write() { unsigned char i; Ds1302_Single_Byte_Write(0x8e,0x00); for(i=0;i<7;i++) { Ds1302_Single_Byte_Write(write[i],Time[i]); } Ds1302_Single_Byte_Write(0x8e,0x80); } void DS1302_read() { unsigned char i; for(i=0;i<7;i++) { Time[i]=Ds1302_Single_Byte_Read(read[i]); } } void read_rd2() { IIC_Start(); IIC_SendByte(0x90); IIC_WaitAck(); IIC_SendByte(0x03); IIC_WaitAck(); IIC_Start(); IIC_SendByte(0x91); IIC_WaitAck(); dat_rd2=IIC_RecByte(); IIC_WaitAck(); IIC_Ack(0); IIC_Stop(); } void shuma(unsigned char pos,unsigned char date) { select(6); P0=0x01<shidu) { select(5); P0=0x40; } else if(nowshidu

    HID 定时器 unsigned dc include

    2259浏览量 1回复量 关注量
  • F0541通过定时器5进行捕获测量内部低速RC振荡器的真实频率 sos

    [backcolor=rgb(255, 255, 255)][font=Tahoma, Microsoft Yahei, Simsun][color=#444444]example required of F0541: page107 in datasheet.由于内部低速RC振荡器频率随工艺角有偏差,可通过定时器5进行捕获测量内部低速RC振荡器的真实频率,然后根据实际的频率值进行溢出时间的计算。[/color][/font][/backcolor]

    定时器 RC振荡器 datasheet Example sheet

    2533浏览量 0回复量 关注量
  • 中颖单片机SH79F6441 T3定时器重载疑问?

    本人首次使用中颖单片机SH79F6441,对它的T3定时器重载,有如下疑惑: 在首次对T3定时器的16位计数器/定时器寄存器(TH3,TL3)置成都置成0(TH3=0x00, TL3=0x00) 后,启动运行一段时间后,读TH3、TL3,如果这个时候读到的值为TH3=0xef, TL3=0x56, 那么当T3定时器在溢出重载时,加载到计数器中的是0X0000,还是0xef56?

    定时器 中颖单片机 计数器 寄存器

    388浏览量 1回复量 关注量
  • 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

    2210浏览量 0回复量 关注量
  • HC89F0541/0531定时器0或者1外部脉冲计数用法问题 sos

    HC89F0541/0531,数据手册24页的PTM 可全映射外设功能引脚表示可以把定时器0或者1的外部输入或 T0 时钟分频输出连接到I/O口,但是64页PTM优先级表中只有TO_OUT,和T1_OUT,如果要用作外部时钟计输入计数模式该怎么设置连接I/O呢?

    定时器 脉冲计数 HC 时钟 I/O

    1518浏览量 0回复量 关注量
  • TDA3x里的定时器功能 sos

    想问下大佬们,TI公司的基于TDA3x的开发板里,关于定时器的配置怎么用的

    定时 定时器 开发板 TI

    895浏览量 0回复量 关注量
  • STC15W4K61S4,内部rc串口二异常

    使用内部22.1184m rc,产生115200或者9600的波特率,输出都是乱码, 只有换成内部11.0592m rc输出才能正常,是什么原因? 这款单片机内部rc最高27m,串口计算器在22.1184m时115200和9600误差是零,下载校准频率误差不超过0.1% 什么原因可能导致的在非115200波特率时乱码? 初始化如下 void UartInit(void) //115200bps@22.1184MHz { P_SW2 &= 0xfe; //选择p10/p11位置为串口2 S2CON = 0x50; //8位数据,可变波特率 AUXR &= 0xFB; //定时器2时钟为Fosc/12,即12T T2L = 0xFC; //设定定时初值 T2H = 0xFF; //设定定时初值 AUXR |= 0x10; //启动定时器2 IE2 |= 0x01; //使能串口2中断 AUXR |= 0x14; //启动定时器2 }

    rc 串口 STC15W4K 定时 定时器

    5245浏览量 3回复量 关注量
  • GD32F450如何配置通过定时器触发DMA内存到内存的传输 sos

    我想配置通过定时器触周期性发DMA内存到内存的传输,求教

    DMA 内存 定时器 触发 GD32F450

    99浏览量 0回复量 关注量
  • 定时器使用

    老师们,我要用STM32F103定时器定时,采用查询方式,用哪个HAL库函数查询标志呢?

    定时器 STM stm32f10 STM32F1 STM32F103

    173浏览量 1回复量 关注量
  • 不能进入外部中断

    void main (void) { EA=1; EX0=1; // 设定接受INT0的中断 TMOD=0x01; /*定时器初始化*/ TH0=0xff; TL0=0xf6; TR0=1; ET0=1;//如果加入定时器设置就无法进入中断函数,不设定时器则可以进入外部中断 while(1); } 如果加入定时器设置就无法进入中断函数,不设定时器则可以进入外部中断 static void decode(void) interrupt 0 using 2 //外部中断函数 内容为红外遥控器解码函数、 {红外要红解码的内容,因较长未列出} 请问下问什么设置定时器就不能进入外部中断了??请高手解答!

    外部中断 定时器 定时 函数 中断函数

    139浏览量 15回复量 关注量
  • 请问一下88F516在空闲模式下。定时器T0可以工作吗?

    请问一下88F516在空闲模式下。定时器T0可以工作吗?

    定时 定时器 定时器T0

    91浏览量 5回复量 关注量
12下一页