问答

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

21ic问答首页 - TAG - GD32E230
  • 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

    7716浏览量 8回复量 关注量
  • eclipse搭建GD32E230编译环境 sos

    我想请问下,有没有人用eclipse搭建成功过GD32E230的编译环境?

    Eclipse 编译环境 GD32E230

    374浏览量 0回复量 关注量
  • GD32E230串口发送完成中断标识位没法清除!!

    串口发送初始化为(PA9)中断发送方式,初始化代码如下:/* enable COM GPIO clock */ rcu_periph_clock_enable(RCU_GPIOA); /* enable USART clock */ rcu_periph_clock_enable(RCU_USART0); /* configure USART Tx as alternate function push-pull */ gpio_mode_set(GPIOA, GPIO_MODE_AF, GPIO_PUPD_PULLUP, GPIO_PIN_9); gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_9); /* connect port to USARTx_Tx */ gpio_af_set(GPIOA, GPIO_AF_1, GPIO_PIN_9); /* configure USART Rx as alternate function push-pull */ gpio_mode_set(GPIOA, GPIO_MODE_AF, GPIO_PUPD_PULLUP, GPIO_PIN_10); gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_10); /* connect port to USARTx_Rx */ gpio_af_set(GPIOA, GPIO_AF_1, GPIO_PIN_10); /* USART configure */ usart_deinit(USART0); usart_baudrate_set(USART0, baud); usart_word_length_set(USART0, USART_WL_8BIT); usart_stop_bit_set(USART0, USART_STB_1BIT); usart_parity_config(USART0, USART_PM_NONE); usart_hardware_flow_rts_config(USART0, USART_RTS_DISABLE); usart_hardware_flow_cts_config(USART0, USART_CTS_DISABLE); usart_transmit_config(USART0, USART_TRANSMIT_ENABLE); nvic_irq_enable(USART0_IRQn, 0); usart_interrupt_enable(USART0, USART_INT_TC); usart_enable(USART0); 中断服务程序: void USART0_IRQHandler(void) { if(RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_TC)) { usart_interrupt_flag_clear(USART0,USART_INT_FLAG_TC); UplinkDrv_Sending((uint_8*)&(USART_TDATA(USART0))); } } void UplinkDrv_Sending(uint_8 *reg) { if(UplinkFrame.Send.Pc >= UplinkFrame.Send.Len) { UplinkDrv_Recv_Creat(); } else { *reg = UplinkFrame.Send.Buff[UplinkFrame.Send.Pc]; UplinkFrame.Send.Pc++; } } 目前是不到发送完一个字节就多次进入该发送中断完成服务程序,导致发送失败。 大拿有遇到相关问题吗?

    串口发送 GD32E230 SAR USART pi IO

    504浏览量 2回复量 关注量
  • GD32E230在MDK5.33-AC6环境下编译无法跳转到定义? sos

    编译出来0错误0警告,MDK已经勾选Browse infomation,MDK和pack包安装路径是全英文,工程文件也是全英文,源文件全部放在src文件夹,头文件全部放在inc文件夹,文件夹直接放在工程目录下,目录深度只有一级,就差直接把所有源文件和头文件放在工程目录下了。但就是不支持跳转到定义,请问有人遇到过同样的问题吗?你们是怎么处理的?

    技术交流 AC MDK 编译 GD32E230 源文件

    933浏览量 0回复量 关注量
  • GD32E230 一复位就不启动了

    GD32E230 设的内部晶振,用Keil 调试,运行正常,只要一复位就不启动了,哪位大神帮助一下,困扰好几天了

    GD32E230 gd32e23 keil 晶振 调试

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

    2264浏览量 0回复量 关注量
  • h88

    GD32E230的ADC可靠不? sos

    我想用 TIMER14 CH0 触发 ADC(扫描转换模式),就怎么触发不了。高手帮我看看哪错了 #include "gd32e23x_adc.h" #include "gd32e23x_dma.h" #include "gd32e23x_gpio.h" #include "gd32e23x_timer.h" static volatile uint16_t data[4]; static void rcuConfig(); static void adcConfig(); static void dmaConfig(); static void portConfig(); static void timerConfig(); void main() { rcuConfig(); timerConfig(); portConfig(); dmaConfig(); adcConfig(); timer_enable(TIMER14); gpio_bit_set(GPIOB, GPIO_PIN_4); while (1) ; } void rcuConfig() { rcu_periph_clock_enable(RCU_GPIOA); rcu_periph_clock_enable(RCU_GPIOB); rcu_periph_clock_enable(RCU_ADC); rcu_periph_clock_enable(RCU_DMA); rcu_periph_clock_enable(RCU_TIMER14); rcu_adc_clock_config(RCU_ADCCK_AHB_DIV3); } void adcConfig() { adc_special_function_config(ADC_SCAN_MODE, ENABLE); adc_dma_mode_enable(); adc_channel_length_config(ADC_REGULAR_CHANNEL, 4U); adc_regular_channel_config(1U, ADC_CHANNEL_3, ADC_SAMPLETIME_1POINT5); adc_regular_channel_config(2U, ADC_CHANNEL_4, ADC_SAMPLETIME_1POINT5); adc_regular_channel_config(3U, ADC_CHANNEL_8, ADC_SAMPLETIME_1POINT5); adc_regular_channel_config(4U, ADC_CHANNEL_9, ADC_SAMPLETIME_1POINT5); adc_external_trigger_config(ADC_REGULAR_CHANNEL, ENABLE); adc_external_trigger_source_config(ADC_REGULAR_CHANNEL, ADC_EXTTRIG_REGULAR_T14_CH0); adc_enable(); for (uint16_t i = 0; i < 1000; ++i) ; adc_calibration_enable(); } void dmaConfig() { dma_parameter_struct initParam; initParam.periph_addr = 0x4001244CU; // ADC_RDATA initParam.periph_inc = DMA_PERIPH_INCREASE_DISABLE; initParam.memory_addr = (uint32_t)data; initParam.memory_inc = DMA_MEMORY_INCREASE_ENABLE; initParam.periph_width = DMA_PERIPHERAL_WIDTH_16BIT; initParam.memory_width = DMA_MEMORY_WIDTH_16BIT; initParam.direction = DMA_PERIPHERAL_TO_MEMORY; initParam.number = 4U; initParam.priority = DMA_PRIORITY_HIGH; dma_init(DMA_CH0, &initParam); dma_circulation_enable(DMA_CH0); dma_interrupt_enable(DMA_CH0, DMA_INT_FTF); dma_interrupt_flag_clear(DMA_CH0, DMA_INT_FLAG_FTF); nvic_irq_enable(DMA_Channel0_IRQn, 1); dma_channel_enable(DMA_CH0); } void portConfig() { gpio_mode_set(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO_PIN_3); gpio_mode_set(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO_PIN_4); gpio_mode_set(GPIOB, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO_PIN_0); gpio_mode_set(GPIOB, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO_PIN_1); gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_4); // LED } void timerConfig() { timer_parameter_struct initParam; initParam.prescaler = 71; initParam.alignedmode = TIMER_COUNTER_EDGE; initParam.counterdirection = TIMER_COUNTER_UP; initParam.period = 99; initParam.clockdivision = TIMER_CKDIV_DIV1; initParam.repetitioncounter = 0U; timer_init(TIMER14, &initParam); timer_oc_parameter_struct ocParam; ocParam.outputstate = TIMER_CCX_ENABLE; ocParam.ocpolarity = TIMER_OC_POLARITY_HIGH; timer_channel_output_config(TIMER14, TIMER_CH_0, &ocParam); timer_channel_output_pulse_value_config(TIMER14, TIMER_CH_0, 2U); timer_channel_output_mode_config(TIMER14, TIMER_CH_0, TIMER_OC_MODE_PWM1); } void DMA_Channel0_IRQHandler() { static uint32_t i = 0; if (dma_interrupt_flag_get(DMA_CH0, DMA_INT_FLAG_FTF)) { dma_interrupt_flag_clear(DMA_CH0, DMA_INT_FLAG_FTF); ++i; if (i == 10000) { i = 0; gpio_bit_toggle(GPIOB, GPIO_PIN_4); } } }

    ADC GD32E230 TI IO pi

    1005浏览量 0回复量 关注量