更新频率计算方式,待调试;写了微秒延时函数,回寝室试试
This commit is contained in:
parent
e5b6eb7b12
commit
caec4d58bc
|
@ -303,10 +303,10 @@ ARM Macro Assembler Page 5
|
|||
E000ED08
|
||||
Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M3 --apcs=interw
|
||||
ork --depend=.\context_rvds.d -o.\context_rvds.o -I.\RTE\_oscilloscope -ID:\ins
|
||||
tall\Keil_v5\Arm\Packs\Keil\STM32F1xx_DFP\2.0.0\Device\Include -ID:\install\Kei
|
||||
l_v5\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predefine="__UVISION_V
|
||||
ERSION SETA 527" --predefine="STM32F10X_HD SETA 1" --list=.\listings\context_rv
|
||||
ds.lst ..\rtthread\libcpu\arm\cortex-m3\context_rvds.S
|
||||
tall\keil526\ARM\PACK\Keil\STM32F1xx_DFP\2.1.0\Device\Include -ID:\install\keil
|
||||
526\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predefine="__UVISION_VE
|
||||
RSION SETA 526" --predefine="STM32F10X_HD SETA 1" --list=.\listings\context_rvd
|
||||
s.lst ..\rtthread\libcpu\arm\cortex-m3\context_rvds.S
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -553,11 +553,10 @@ ARM Macro Assembler Page 9
|
|||
00000000
|
||||
Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M3 --apcs=interw
|
||||
ork --depend=.\startup_stm32f10x_hd.d -o.\startup_stm32f10x_hd.o -I.\RTE\_oscil
|
||||
loscope -ID:\install\Keil_v5\Arm\Packs\Keil\STM32F1xx_DFP\2.0.0\Device\Include
|
||||
-ID:\install\Keil_v5\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predef
|
||||
ine="__UVISION_VERSION SETA 527" --predefine="STM32F10X_HD SETA 1" --list=.\lis
|
||||
tings\startup_stm32f10x_hd.lst ..\Libraries\CMSIS\startup\startup_stm32f10x_hd.
|
||||
s
|
||||
loscope -ID:\install\keil526\ARM\PACK\Keil\STM32F1xx_DFP\2.1.0\Device\Include -
|
||||
ID:\install\keil526\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predefi
|
||||
ne="__UVISION_VERSION SETA 526" --predefine="STM32F10X_HD SETA 1" --list=.\list
|
||||
ings\startup_stm32f10x_hd.lst ..\Libraries\CMSIS\startup\startup_stm32f10x_hd.s
|
||||
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -655,7 +655,7 @@
|
|||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\OSC\OSC.c</PathWithFileName>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<TargetCommonOption>
|
||||
<Device>STM32F103VE</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F1xx_DFP.2.0.0</PackID>
|
||||
<PackID>Keil.STM32F1xx_DFP.2.1.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x10000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
|
|
|
@ -247,7 +247,7 @@ void PlotBlackground(void)
|
|||
*/
|
||||
void CalculateFrequency(void)
|
||||
{
|
||||
uint16_t i, WaveLenth=0;
|
||||
uint16_t SampleNrb_Pre=0, SampleNrb_Aft=0, WaveLenth=0;
|
||||
uint8_t WaveLenthSumNrb=0, SumNrb, ConvertedTriggerValue = CurTriggerValue/3.3*200-0.5;//用于转换触发阀值 自动采样模式下对频率求平均值
|
||||
|
||||
if(SamplingModeNrb == 0)
|
||||
|
@ -255,16 +255,19 @@ void CalculateFrequency(void)
|
|||
else
|
||||
SumNrb = 0;
|
||||
//计算波长
|
||||
for(i=0;i < ADCx_1_SampleNbr-1; i++)
|
||||
while((Get_Trigger_Status(ADC_ConvertedValue[SampleNrb_Pre], ADC_ConvertedValue[SampleNrb_Pre+1]) == SET) && (SampleNrb_Pre < (ADCx_1_SampleNbr-1)))
|
||||
{
|
||||
if(Get_Trigger_Status(ADC_ConvertedValue[i], ADC_ConvertedValue[i+1]) == SET)
|
||||
WaveLenth = i;
|
||||
break;
|
||||
SampleNrb_Pre++;
|
||||
}
|
||||
SampleNrb_Aft = SampleNrb_Pre;
|
||||
while((Get_Trigger_Status(ADC_ConvertedValue[SampleNrb_Aft], ADC_ConvertedValue[SampleNrb_Aft+1]) == RESET) && (SampleNrb_Aft < (ADCx_1_SampleNbr-1)))
|
||||
{
|
||||
SampleNrb_Aft++;
|
||||
}
|
||||
|
||||
if(i < ADCx_1_SampleNbr-1)
|
||||
if(SampleNrb_Aft < ADCx_1_SampleNbr-1)
|
||||
{
|
||||
WaveLenth += WaveLenth;
|
||||
WaveLenth += SampleNrb_Aft - SampleNrb_Pre;
|
||||
if(++WaveLenthSumNrb >= SumNrb)
|
||||
{
|
||||
WaveLenth = WaveLenth>>2;
|
||||
|
|
17
User/main.c
17
User/main.c
|
@ -1,5 +1,9 @@
|
|||
#include "OSC.h"
|
||||
|
||||
//测试用,待删
|
||||
#include "bsp_led.h"
|
||||
#include "bsp_TiMbase.h"
|
||||
|
||||
/*
|
||||
*************************************************************************
|
||||
* main 函数
|
||||
|
@ -11,8 +15,17 @@
|
|||
* @retval 无
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
Run();
|
||||
{
|
||||
uint16_t t=1000;
|
||||
while(1)
|
||||
{
|
||||
LED3_TOGGLE;
|
||||
while(t--)
|
||||
{
|
||||
Delay_us(1000);
|
||||
}
|
||||
}
|
||||
//Run();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue