问答

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

21ic问答首页 - TAG - sy
  • 请问GD32F20x怎么修改晶振频率

    请问GD32F20x怎么修改晶振频率,system_gd32f20x.c中好像是按25MHz的晶振来配置的,怎么修改成别的频率,谢谢。

    syste sy ST hz 晶振 gd32f20x

    3301浏览量 8回复量 关注量
  • CW32时钟

    刚开始使用CW32,请问RCC_SysClk_Switch和RCC_SYSCLKSRC_Config有什么区分

    sy SCL SC rc 时钟 CW32

    1033浏览量 1回复量 关注量
  • GD32F303问题

    [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]问题背景是这样的:[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]配置了一个20Khz的定时器溢出中断,System_cnt_add()函数是对一个变量++,就是创建了一个时间基准。然后在Task_time_slice_function()函数里面实现了一个led每0.5s翻转的任务。[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]于是遇到了这样一个问题:[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]当我把这个Task_time_slice_function()函数放在中断的时候,led能够正常实现每0.5s翻转的操作,也就是输出一个1Hz的方波。但是当我把Task_time_slice_function()函数放在main函数的while循环里面时,功能就失效了,变成输出32Hz的方波。有没有人知道怎么回事,希望能指点一下,谢谢![/size][/font][/backcolor][/color][font=Tahoma, Microsoft Yahei, Simsun][color=#444444][size=16px] [/size][/color][/font][color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]这是用到的几个函数[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]int main(void)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]{[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] Systemclock_config();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] nvic_config();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] gpio_config();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] spi2_config();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] timer_config();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] System_cnt_init();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] while(1)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] {[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] Task_time_slice_function();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] }[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]}[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]/* time0 20kHz*/[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]void TIMER0_UP_IRQHandler(void)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]{ [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] if(SET == timer_interrupt_flag_get(TIMER0, TIMER_INT_UP))[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] {[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] timer_interrupt_flag_clear(TIMER0, TIMER_INT_FLAG_UP);[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] System_cnt_add();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] }[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]}[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]void Task_time_slice_function(void)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]{[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] /* 1ms */[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] if(_abs(systemclock_data.systemclock_cnt - systemclock_data.systemclock_lastcnt_1ms) >= systemclock_data.systemclock_cnt_1ms)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] {[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] systemclock_data.systemclock_lastcnt_1ms = systemclock_data.systemclock_cnt;[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] led_main();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] }[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] /* 10ms */[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] if(_abs(systemclock_data.systemclock_cnt - systemclock_data.systemclock_lastcnt_10ms) >= systemclock_data.systemclock_cnt_10ms)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] {[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] systemclock_data.systemclock_lastcnt_10ms = systemclock_data.systemclock_cnt;[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] }[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] /* 100ms */[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] if(_abs(systemclock_data.systemclock_cnt - systemclock_data.systemclock_lastcnt_100ms) >= systemclock_data.systemclock_cnt_100ms)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] {[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] systemclock_data.systemclock_lastcnt_100ms = systemclock_data.systemclock_cnt;[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] }[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] /* 1000ms */[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] if(_abs(systemclock_data.systemclock_cnt - systemclock_data.systemclock_lastcnt_1000ms) >= systemclock_data.systemclock_cnt_1000ms)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] {[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] systemclock_data.systemclock_lastcnt_1000ms = systemclock_data.systemclock_cnt;[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px] }[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(242, 249, 253)][font=Tahoma, "][size=16px]}[/size][/font][/backcolor][/color]

    TE GD32F303 ST sy System syste

    2111浏览量 3回复量 关注量