问答

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

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

    2142浏览量 3回复量 关注量
  • GD32F205VE替换STM32F205VE,在systeminit函数直接就挂了

    RCC->CR |= (uint32_t)0x00000001;这行就进入hardfault了 什么原因呢?

    EMI ni 函数 System STM32F205 GD32F205

    4559浏览量 1回复量 关注量
  • GD32仿真

    GD32写串口通信程序,仿真打断点,程序不运行至断点处,是在system_gd32f4xx.c中的static void system_clock_120m_8m_hxtal()执行,不能跳出。

    仿真 System syste TE static

    6417浏览量 5回复量 关注量
  • 这是怎么回事?

    使Intermedia GUI无法用set system config来设置,当选中PHY的PRM Flag栏和/或MAC的Default ARQ Enable栏时,Apply时提示“Unable to set the System Configure Status Code = Invalid Parameter”,这是怎么回事?

    TE ST System BLE SystemC

    724浏览量 3回复量 关注量