|
采用的是12位的內部ADC采集程序經過測試可用。- /*
- * Systick_timer.c
- *
- * Created: 2019/4/22 17:41:05
- * Author: autonav
- */
- #include "Systick_timer.h"
- volatile uint32_t systick_ms;
- volatile Flag_TypeDef systick_flag;
- volatile uint32_t systick_ms;
- volatile Flag_TypeDef systick_flag;
- void SysTick_Handler(void)
- {
- systick_ms++;
-
- systick_flag.flag_1ms++;
- systick_flag.flag_2ms++;
- systick_flag.flag_5ms++;
-
- systick_flag.flag_10ms++;
- systick_flag.flag_20ms++;
- systick_flag.flag_50ms++;
-
- systick_flag.flag_100ms++;
- systick_flag.flag_200ms++;
-
- }
- void SysTick_TimerStart()
- {
- if (SysTick_Config(SystemCoreClock / 1000)) //配置1ms SysTick中斷
- {
- while (1)
- {
-
- }
- }
- }
- float64_t SysTick_GetCurrentTime()
- {
- volatile uint32_t load = SysTick->LOAD;
- volatile uint32_t val = SysTick->VAL;
- return( (systick_ms+(float64_t)(load-val)/(load+1)) / 1000);
- }
- float64_t get_dT(float64_t *last_time)
- {
- float64_t current_time = SysTick_GetCurrentTime();
- float64_t dt = current_time - *last_time;
- *last_time = current_time;
- return(dt);
- }
- void Delay(uint32_t x)
- {
- while(x--);
- }
復制代碼
|
-
-
Adc.7z
2020-8-17 20:57 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
1.27 MB, 下載次數: 13, 下載積分: 黑幣 -5
|