完成频率计算和显示部分,待调试
This commit is contained in:
parent
16f3f304f2
commit
bc2e32c797
|
@ -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
|
@ -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>
|
||||
|
|
|
@ -49,6 +49,7 @@ char* CurSamplingMode = {"A"}; //
|
|||
uint16_t CurTimePerDiv = 500; //代号4,每格代表的时间间隔
|
||||
|
||||
//要显示的信息
|
||||
float WaveFrq = 0.0;//波形频率,单位kHz
|
||||
__IO uint16_t ADC_ConvertedValue[ADCx_1_SampleNbr] = {0};//ADC采集数据
|
||||
FlagStatus StopSample = RESET;//停止采样标志
|
||||
|
||||
|
@ -221,16 +222,58 @@ void PlotBlackground(void)
|
|||
|
||||
/**
|
||||
* @brief 计算波形频率
|
||||
* @param Operation:当前正在设置的参数
|
||||
* @param ADC_ConvertedValue:采集的波形数据
|
||||
* @retval None
|
||||
*/
|
||||
void CalculateFrequency(uint16_t *ADC_ConvertedValue)
|
||||
void CalculateFrequency(void)
|
||||
{
|
||||
uint8_t n;
|
||||
for(n=0;n < ADCx_1_SampleNbr; n++)
|
||||
{
|
||||
uint8_t i, WaveLenth=0, WaveLenthSumNrb=0, SumNrb;//自动采样模式下对频率求平均值
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -242,7 +285,7 @@ void CalculateFrequency(uint16_t *ADC_ConvertedValue)
|
|||
//波形显示
|
||||
void PlotWave(void* parameter)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t i;
|
||||
rt_err_t recv_statu = RT_EOK;
|
||||
uint8_t flag = 0;//波形数据采集完成标志
|
||||
while(1)
|
||||
|
@ -250,12 +293,15 @@ void PlotWave(void* parameter)
|
|||
recv_statu = rt_mq_recv(getwave_status_queue, &flag, sizeof(flag), RT_WAITING_FOREVER);
|
||||
if(recv_statu == RT_EOK && flag == 1)
|
||||
{
|
||||
//波形显示
|
||||
PlotBlackground();
|
||||
for(i=0; i <= ADCx_1_SampleNbr-2; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ extern uint16_t CurTimePerDiv; //
|
|||
|
||||
//要显示的信息
|
||||
extern __IO uint16_t ADC_ConvertedValue[];//ADC采集数据
|
||||
extern float WaveFrq;//波形频率,单位kHz
|
||||
|
||||
extern uint16_t TimePerDiv_Group[];
|
||||
extern uint8_t TimePerDivOderNbr;
|
||||
|
@ -33,6 +34,7 @@ extern FlagStatus StopSample;//ֹͣ
|
|||
|
||||
|
||||
void PlotBlackground(void);
|
||||
void CalculateFrequency(void);
|
||||
void PlotWave(void* parameter);
|
||||
void Init(void);
|
||||
void Run(void);
|
||||
|
|
Loading…
Reference in New Issue