资源简介
利用STM32上的ADC、TIM2、DMA实现对多个通道的交流正弦信号的采样,并计算分别得其有效值,通道数目可以根据需要自行增加,另外保留了注入通道的使用。为了减轻MCU的负担,利用STM32的DMA功能;另外采用串口输出到PC机上(串口调试助手),以利于观察采样计算后得到的有效值。
代码片段和文件信息
#define ADC1_DR_Address ((u32)0x4001244C)
#define SAMPLE_MAX_POINTS ((u16)256)
#define SAMPLE_MAX_CHANNELS ((u8)4)
#define TICKS_PER_SEC ((u8)20)
#include “stm32f10x.h“
#include “math.h“
#include “stdio.h“
void NVIC_Configuration(void);
void ADC_Configuration(void);
void DMA_Configuration(void);
void TIM_Configuration(void);
void SysTickConfiguration(void);
void USART_Configuration(void);
void delay_s(u16 time);
void Task_SampleVC(void);
float SAMPLE_GetValidValue(vu16 Value_VC[SAMPLE_MAX_POINTS][SAMPLE_MAX_CHANNELS] u8 Channel_n);
float SAMPLE_GetAverage(vu16 value[SAMPLE_MAX_POINTS][SAMPLE_MAX_CHANNELS] u8 Channel_n);
const double WINDOW[SAMPLE_MAX_POINTS]= //------二阶窗--------------
{
0.0000610350.0001220700.0001831050.0002441410.0003051760.0003662110.0004272460.000488281
0.0005493160.0006103520.0006713870.0007324220.0007934570.0008544920.0009155270.0009765630.001037598
0.0010986330.0011596680.0012207030.0012817380.0013427730.0014038090.0014648440.0015258790.001586914
0.0016479490.0017089840.0017700200.0018310550.0018920900.0019531250.0020141600.0020751950.002136230
0.0021972660.0022583010.0023193360.0023803710.0024414060.0025024410.0025634770.0026245120.002685547
0.0027465820.0028076170.0028686520.0029296880.0029907230.0030517580.0031127930.0031738280.003234863
0.0032958980.0033569340.0034179690.0034790040.0035400390.0036010740.0036621090.0037231450.003784180
0.0038452150.0039062500.0039672850.0040283200.0040893550.0041503910.0042114260.0042724610.004333496
0.0043945310.0044555660.0045166020.0045776370.0046386720.0046997070.0047607420.0048217770.004882813
0.0049438480.0050048830.0050659180.0051269530.0051879880.0052490230.0053100590.0053710940.005432129
0.0054931640.0055541990.0056152340.0056762700.0057373050.0057983400.0058593750.0059204100.005981445
0.0060424800.0061035160.0061645510.0062255860.0062866210.0063476560.0064086910.0064697270.006530762
0.0065917970.0066528320.0067138670.0067749020.0068359380.0068969730.0069580080.0070190430.007080078
0.0071411130.0072021480.0072631840.0073242190.0073852540.0074462890.0075073240.0075683590.007629395
0.0076904300.0077514650.0078125000.0077514650.0076904300.0076293950.0075683590.0075073240.007446289
0.0073852540.0073242190.0072631840.0072021480.0071411130.0070800780.0070190430.0069580080.006896973
0.0068359380.0067749020.0067138670.0066528320.0065917970.0065307620.0064697270.0064086910.006347656
0.0062866210.0062255860.0061645510.0061035160.0060424800.0059814450.0059204100.0058593750.005798340
0.0057373050.0056762700.0056152340.0055541990.0054931640.0054321290.0053710940.0053100590.005249023
0.0051879880.0051269530.0050659180.0050048830.0049438480.0048828130.0048217770.0047607420.004699707
0.0046386720.0045776370.0045166020.0044555660.0043945310.0
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 17273 2010-04-23 10:40 SampleTaskVC\CMSIS\core_cm3.c
文件 85714 2010-04-23 10:40 SampleTaskVC\CMSIS\core_cm3.h
文件 31997 2010-04-23 10:40 SampleTaskVC\CMSIS\system_stm32f10x.c
文件 2068 2010-04-23 10:40 SampleTaskVC\CMSIS\system_stm32f10x.h
文件 8893 2010-04-23 10:39 SampleTaskVC\FWLib\inc\misc.h
文件 21601 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_adc.h
文件 7466 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_bkp.h
文件 20503 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_can.h
文件 6483 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_cec.h
文件 2073 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_crc.h
文件 15062 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_dac.h
文件 3729 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_dbgmcu.h
文件 20573 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_dma.h
文件 6735 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_exti.h
文件 25356 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_flash.h
文件 26187 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_fsmc.h
文件 19316 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_gpio.h
文件 29501 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_i2c.h
文件 3739 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_iwdg.h
文件 4294 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_pwr.h
文件 30246 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_rcc.h
文件 3768 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_rtc.h
文件 21774 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_sdio.h
文件 17983 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_spi.h
文件 50427 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_tim.h
文件 16459 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_usart.h
文件 2877 2010-04-23 10:39 SampleTaskVC\FWLib\inc\stm32f10x_wwdg.h
文件 6931 2010-04-23 10:39 SampleTaskVC\FWLib\src\misc.c
文件 47016 2010-04-23 10:39 SampleTaskVC\FWLib\src\stm32f10x_adc.c
文件 8497 2010-04-23 10:39 SampleTaskVC\FWLib\src\stm32f10x_bkp.c
............此处省略94个文件信息
- 上一篇:百度语音合成和语音识别
- 下一篇:W5200模块-UDP模式例程
评论
共有 条评论