完成频率计算和显示部分,待调试

This commit is contained in:
zhan-min 2020-12-15 15:35:16 +08:00
parent 16f3f304f2
commit bc2e32c797
7 changed files with 2469 additions and 2384 deletions

View File

@ -303,10 +303,10 @@ ARM Macro Assembler Page 5
E000ED08 E000ED08
Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M3 --apcs=interw 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 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 tall\keil526\ARM\PACK\Keil\STM32F1xx_DFP\2.1.0\Device\Include -ID:\install\keil
l_v5\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predefine="__UVISION_V 526\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predefine="__UVISION_VE
ERSION SETA 527" --predefine="STM32F10X_HD SETA 1" --list=.\listings\context_rv RSION SETA 526" --predefine="STM32F10X_HD SETA 1" --list=.\listings\context_rvd
ds.lst ..\rtthread\libcpu\arm\cortex-m3\context_rvds.S s.lst ..\rtthread\libcpu\arm\cortex-m3\context_rvds.S

View File

@ -553,11 +553,10 @@ ARM Macro Assembler Page 9
00000000 00000000
Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M3 --apcs=interw 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 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 loscope -ID:\install\keil526\ARM\PACK\Keil\STM32F1xx_DFP\2.1.0\Device\Include -
-ID:\install\Keil_v5\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predef ID:\install\keil526\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predefi
ine="__UVISION_VERSION SETA 527" --predefine="STM32F10X_HD SETA 1" --list=.\lis ne="__UVISION_VERSION SETA 526" --predefine="STM32F10X_HD SETA 1" --list=.\list
tings\startup_stm32f10x_hd.lst ..\Libraries\CMSIS\startup\startup_stm32f10x_hd. ings\startup_stm32f10x_hd.lst ..\Libraries\CMSIS\startup\startup_stm32f10x_hd.s
s

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@
<TargetCommonOption> <TargetCommonOption>
<Device>STM32F103VE</Device> <Device>STM32F103VE</Device>
<Vendor>STMicroelectronics</Vendor> <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> <PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000,0x10000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu> <Cpu>IRAM(0x20000000,0x10000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec> <FlashUtilSpec></FlashUtilSpec>

View File

@ -49,6 +49,7 @@ char* CurSamplingMode = {"A"}; //
uint16_t CurTimePerDiv = 500; //代号4每格代表的时间间隔 uint16_t CurTimePerDiv = 500; //代号4每格代表的时间间隔
//要显示的信息 //要显示的信息
float WaveFrq = 0.0;//波形频率单位kHz
__IO uint16_t ADC_ConvertedValue[ADCx_1_SampleNbr] = {0};//ADC采集数据 __IO uint16_t ADC_ConvertedValue[ADCx_1_SampleNbr] = {0};//ADC采集数据
FlagStatus StopSample = RESET;//停止采样标志 FlagStatus StopSample = RESET;//停止采样标志
@ -221,16 +222,58 @@ void PlotBlackground(void)
/** /**
* @brief * @brief
* @param Operation * @param ADC_ConvertedValue
* @retval None * @retval None
*/ */
void CalculateFrequency(uint16_t *ADC_ConvertedValue) void CalculateFrequency(void)
{ {
uint8_t n; uint8_t i, WaveLenth=0, WaveLenthSumNrb=0, SumNrb;//自动采样模式下对频率求平均值
for(n=0;n < ADCx_1_SampleNbr; n++) uint8_t ConvertedTriggerValue = CurTriggerValue/3.3*200-0.5;//用于转换触发阀值
{ char dispBuff[100];
if(SamplingModeNrb == 0)
SumNrb = 4;
else
SumNrb = 0;
//计算波长
if(TriggerModeNrb == 0)
{
for(i=0;i < ADCx_1_SampleNbr-1; i++)
{
if((ADC_ConvertedValue[i] >= ConvertedTriggerValue) && (ADC_ConvertedValue[i+1] <= ConvertedTriggerValue))
WaveLenth = i;
break;
} }
}
else if(TriggerModeNrb == 1)
{
for(i=0;i < ADCx_1_SampleNbr-1; i++)
{
if((ADC_ConvertedValue[i] <= ConvertedTriggerValue) && (ADC_ConvertedValue[i+1] >= ConvertedTriggerValue))
WaveLenth = i;
break;
}
}
if(i < ADCx_1_SampleNbr-1)
{
WaveLenth += WaveLenth;
if(++WaveLenthSumNrb >= SumNrb)
{
WaveLenth = WaveLenth>>2;
//计算频率
WaveFrq = 1/(((float)WaveLenth)*((float)CurTimePerDiv)/50);//(1/(WaveLenth*CurTimePerDiv/50/1000))*1000 kHz
ILI9341_Clear(260, (((sFONT *)LCD_GetFont())->Height)*5, 60, (((sFONT *)LCD_GetFont())->Height));
/*使用c标准库把变量转化成字符串*/
sprintf(dispBuff,"%.1f kHz", WaveFrq);
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*5, dispBuff);
}
else
return;
}
else
return;
} }
@ -250,12 +293,15 @@ void PlotWave(void* parameter)
recv_statu = rt_mq_recv(getwave_status_queue, &flag, sizeof(flag), RT_WAITING_FOREVER); recv_statu = rt_mq_recv(getwave_status_queue, &flag, sizeof(flag), RT_WAITING_FOREVER);
if(recv_statu == RT_EOK && flag == 1) if(recv_statu == RT_EOK && flag == 1)
{ {
//波形显示
PlotBlackground(); PlotBlackground();
for(i=0; i <= ADCx_1_SampleNbr-2; i++) for(i=0; i <= ADCx_1_SampleNbr-2; i++)
{ {
LCD_SetTextColor(WHITE); LCD_SetTextColor(WHITE);
ILI9341_DrawLine ( Wave_Centor_X-(Wave_Width/2)+i, ADC_ConvertedValue[i], Wave_Centor_X-(Wave_Width/2)+i+1, ADC_ConvertedValue[i+1] ); ILI9341_DrawLine( Wave_Centor_X-(Wave_Width/2)+i, ADC_ConvertedValue[i], Wave_Centor_X-(Wave_Width/2)+i+1, ADC_ConvertedValue[i+1] );
} }
//频率显示
CalculateFrequency();//计算和刷新一起
} }
flag = 0; flag = 0;
} }

View File

@ -24,6 +24,7 @@ extern uint16_t CurTimePerDiv; //
//要显示的信息 //要显示的信息
extern __IO uint16_t ADC_ConvertedValue[];//ADC采集数据 extern __IO uint16_t ADC_ConvertedValue[];//ADC采集数据
extern float WaveFrq;//波形频率单位kHz
extern uint16_t TimePerDiv_Group[]; extern uint16_t TimePerDiv_Group[];
extern uint8_t TimePerDivOderNbr; extern uint8_t TimePerDivOderNbr;
@ -33,6 +34,7 @@ extern FlagStatus StopSample;//ֹͣ
void PlotBlackground(void); void PlotBlackground(void);
void CalculateFrequency(void);
void PlotWave(void* parameter); void PlotWave(void* parameter);
void Init(void); void Init(void);
void Run(void); void Run(void);