微秒延时有效,频率计算恢复正常
This commit is contained in:
parent
863898810b
commit
4e8559ac76
|
@ -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\keil526\ARM\PACK\Keil\STM32F1xx_DFP\2.1.0\Device\Include -ID:\install\keil
|
tall\Keil_v5\Arm\Packs\Keil\STM32F1xx_DFP\2.0.0\Device\Include -ID:\install\Kei
|
||||||
526\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predefine="__UVISION_VE
|
l_v5\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predefine="__UVISION_V
|
||||||
RSION SETA 526" --predefine="STM32F10X_HD SETA 1" --list=.\listings\context_rvd
|
ERSION SETA 527" --predefine="STM32F10X_HD SETA 1" --list=.\listings\context_rv
|
||||||
s.lst ..\rtthread\libcpu\arm\cortex-m3\context_rvds.S
|
ds.lst ..\rtthread\libcpu\arm\cortex-m3\context_rvds.S
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -553,10 +553,11 @@ 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\keil526\ARM\PACK\Keil\STM32F1xx_DFP\2.1.0\Device\Include -
|
loscope -ID:\install\Keil_v5\Arm\Packs\Keil\STM32F1xx_DFP\2.0.0\Device\Include
|
||||||
ID:\install\keil526\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predefi
|
-ID:\install\Keil_v5\ARM\CMSIS\Include --predefine="__MICROLIB SETA 1" --predef
|
||||||
ne="__UVISION_VERSION SETA 526" --predefine="STM32F10X_HD SETA 1" --list=.\list
|
ine="__UVISION_VERSION SETA 527" --predefine="STM32F10X_HD SETA 1" --list=.\lis
|
||||||
ings\startup_stm32f10x_hd.lst ..\Libraries\CMSIS\startup\startup_stm32f10x_hd.s
|
tings\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>
|
<TargetCommonOption>
|
||||||
<Device>STM32F103VE</Device>
|
<Device>STM32F103VE</Device>
|
||||||
<Vendor>STMicroelectronics</Vendor>
|
<Vendor>STMicroelectronics</Vendor>
|
||||||
<PackID>Keil.STM32F1xx_DFP.2.1.0</PackID>
|
<PackID>Keil.STM32F1xx_DFP.2.0.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>
|
||||||
|
|
|
@ -35,15 +35,15 @@ uint16_t TimePerDiv_Group[] = {2, 5, 10, 20, 50, 100, 200, 500};
|
||||||
|
|
||||||
int8_t SamplStatusNrb =0;
|
int8_t SamplStatusNrb =0;
|
||||||
int8_t TriggerModeNrb = 0;
|
int8_t TriggerModeNrb = 0;
|
||||||
int8_t SamplingModeNrb =0;
|
int8_t SamplingModeNrb =1;
|
||||||
uint8_t TimePerDivOderNbr = sizeof(TimePerDiv_Group)/sizeof(TimePerDiv_Group[0]);
|
uint8_t TimePerDivOderNbr = sizeof(TimePerDiv_Group)/sizeof(TimePerDiv_Group[0]);
|
||||||
int8_t TimePerDivOder = 0;//当前每格间隔时间的序号
|
int8_t TimePerDivOder = 0;//当前每格间隔时间的序号
|
||||||
|
|
||||||
|
|
||||||
char* CurSamplStatus = {"Run"}; //代号5,采样状态,0:停止采样,1:正在采样,采用中断方式设置
|
char* CurSamplStatus = {"Run"}; //代号5,采样状态,0:停止采样,1:正在采样,采用中断方式设置
|
||||||
float CurTriggerValue = 0.0; //代号1,触发阀值
|
float CurTriggerValue = 2.0; //代号1,触发阀值
|
||||||
char* CurTriggerMode = {"Up"}; //代号2,触发模式,0:下降沿触发,1:上升沿触发
|
char* CurTriggerMode = {"Up"}; //代号2,触发模式,0:下降沿触发,1:上升沿触发
|
||||||
char* CurSamplingMode = {"Auto"}; //代号3,采样模式,0:自动,1:普通,2:单次
|
char* CurSamplingMode = {"Normal"}; //代号3,采样模式,0:自动,1:普通,2:单次
|
||||||
uint16_t CurTimePerDiv = 2; //代号4,每格代表的时间间隔
|
uint16_t CurTimePerDiv = 2; //代号4,每格代表的时间间隔
|
||||||
|
|
||||||
//要显示的信息
|
//要显示的信息
|
||||||
|
@ -51,6 +51,9 @@ float CurWaveFrq = 0.0; //
|
||||||
__IO uint16_t ADC_ConvertedValue[ADCx_1_SampleNbr] = {0};//ADC采集数据
|
__IO uint16_t ADC_ConvertedValue[ADCx_1_SampleNbr] = {0};//ADC采集数据
|
||||||
|
|
||||||
|
|
||||||
|
//全局变量
|
||||||
|
uint8_t WaveLenthSumNrb=0;//波长计算累加次数
|
||||||
|
uint16_t WaveLenth=0;//波长
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
|
@ -67,7 +70,6 @@ __IO uint16_t ADC_ConvertedValue[ADCx_1_SampleNbr] = {0};//ADC
|
||||||
*/
|
*/
|
||||||
static void Setting_do(uint8_t CurSetItem, int8_t Operation)
|
static void Setting_do(uint8_t CurSetItem, int8_t Operation)
|
||||||
{
|
{
|
||||||
char dispBuff[100];
|
|
||||||
switch(CurSetItem)
|
switch(CurSetItem)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -111,13 +113,6 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sprintf(dispBuff,"%.1f V", CurTriggerValue);
|
|
||||||
rt_kprintf("TriggerValue: %s\n",dispBuff);
|
|
||||||
rt_kprintf("RangeMode: %s\n",CurSamplStatus);
|
|
||||||
rt_kprintf("TriggerMode: %s\n",CurTriggerMode);
|
|
||||||
rt_kprintf("Sampling_mode: %s\n",CurSamplingMode);
|
|
||||||
rt_kprintf("TimePerDiv: %d\n",CurTimePerDiv);
|
|
||||||
rt_kprintf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,7 +127,7 @@ void Setting_Inf_Update(uint8_t CurSetItem)
|
||||||
char dispBuff[100];
|
char dispBuff[100];
|
||||||
ILI9341_Clear(0, 0, 320, 30);
|
ILI9341_Clear(0, 0, 320, 30);
|
||||||
|
|
||||||
sprintf(dispBuff,"%.1fkHz", CurWaveFrq);
|
sprintf(dispBuff,"%.2fkHz", CurWaveFrq);
|
||||||
ILI9341_DispString_EN(Div*0+StartPos_X, StartPos_Y, dispBuff);
|
ILI9341_DispString_EN(Div*0+StartPos_X, StartPos_Y, dispBuff);
|
||||||
/*使用c标准库把变量转化成字符串*/
|
/*使用c标准库把变量转化成字符串*/
|
||||||
sprintf(dispBuff,"%.1fV", CurTriggerValue);
|
sprintf(dispBuff,"%.1fV", CurTriggerValue);
|
||||||
|
@ -164,7 +159,7 @@ void Setting_Inf_Update(uint8_t CurSetItem)
|
||||||
{
|
{
|
||||||
ILI9341_Clear(Div*CurSetItem+StartPos_X, StartPos_Y, Div, (((sFONT *)LCD_GetFont())->Height));
|
ILI9341_Clear(Div*CurSetItem+StartPos_X, StartPos_Y, Div, (((sFONT *)LCD_GetFont())->Height));
|
||||||
LCD_SetColors(BLACK, WHITE);
|
LCD_SetColors(BLACK, WHITE);
|
||||||
ILI9341_DispString_EN(Div*CurSetItem+StartPos_X+15, StartPos_Y, CurTriggerMode);
|
ILI9341_DispString_EN(Div*CurSetItem+StartPos_X+5, StartPos_Y, CurTriggerMode);
|
||||||
LCD_SetColors(WHITE, BLACK);
|
LCD_SetColors(WHITE, BLACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -245,33 +240,48 @@ void PlotBlackground(void)
|
||||||
*/
|
*/
|
||||||
void CalculateFrequency(void)
|
void CalculateFrequency(void)
|
||||||
{
|
{
|
||||||
uint16_t SampleNrb_Pre=0, SampleNrb_Aft=0, WaveLenth=0;
|
uint16_t SampleNrb_Pre=0, SampleNrb_Aft=0;
|
||||||
uint8_t WaveLenthSumNrb=0, SumNrb, ConvertedTriggerValue = CurTriggerValue/3.3*200-0.5;//用于转换触发阀值 自动采样模式下对频率求平均值
|
uint8_t SumNrb=4;//自动采样模式下对频率求平均值
|
||||||
|
float d0, d1;
|
||||||
|
|
||||||
if(SamplingModeNrb == 0)
|
// if(SamplingModeNrb == 0)
|
||||||
SumNrb = 4;
|
// SumNrb = 4;
|
||||||
else
|
// else
|
||||||
SumNrb = 0;
|
// SumNrb = 0;
|
||||||
//计算波长
|
//计算波长
|
||||||
while((Get_Trigger_Status(ADC_ConvertedValue[SampleNrb_Pre], ADC_ConvertedValue[SampleNrb_Pre+1]) == SET) && (SampleNrb_Pre < (ADCx_1_SampleNbr-1)))
|
d0 = ADC_ConvertedValue[SampleNrb_Pre]/200.0*3.3;
|
||||||
|
d1 = ADC_ConvertedValue[SampleNrb_Pre+1]/200.0*3.3;
|
||||||
|
while((Get_Trigger_Status(d0, d1) == SET) && (SampleNrb_Pre < (ADCx_1_SampleNbr-1)))
|
||||||
{
|
{
|
||||||
SampleNrb_Pre++;
|
SampleNrb_Pre++;
|
||||||
|
d0 = ADC_ConvertedValue[SampleNrb_Pre]/200.0*3.3;
|
||||||
|
d1 = ADC_ConvertedValue[SampleNrb_Pre+1]/200.0*3.3;
|
||||||
}
|
}
|
||||||
SampleNrb_Aft = 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)))
|
while((Get_Trigger_Status(d0, d1) == RESET) && (SampleNrb_Aft < (ADCx_1_SampleNbr-1)))
|
||||||
{
|
{
|
||||||
SampleNrb_Aft++;
|
SampleNrb_Aft++;
|
||||||
}
|
d0 = ADC_ConvertedValue[SampleNrb_Aft]/200.0*3.3;
|
||||||
|
d1 = ADC_ConvertedValue[SampleNrb_Aft+1]/200.0*3.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_kprintf("WaveLenth: %d\n", SampleNrb_Aft - SampleNrb_Pre);
|
||||||
|
|
||||||
if(SampleNrb_Aft < ADCx_1_SampleNbr-1)
|
if(SampleNrb_Aft < ADCx_1_SampleNbr-1)
|
||||||
{
|
{
|
||||||
WaveLenth += SampleNrb_Aft - SampleNrb_Pre;
|
WaveLenth += SampleNrb_Aft - SampleNrb_Pre+2;
|
||||||
if(++WaveLenthSumNrb >= SumNrb)
|
if(++WaveLenthSumNrb >= SumNrb)
|
||||||
{
|
{
|
||||||
|
WaveLenthSumNrb = 0;
|
||||||
|
// if(SamplingModeNrb == 0)
|
||||||
|
// {
|
||||||
|
// WaveLenth = WaveLenth>>2;
|
||||||
|
// }
|
||||||
WaveLenth = WaveLenth>>2;
|
WaveLenth = WaveLenth>>2;
|
||||||
//计算频率
|
//计算频率
|
||||||
CurWaveFrq = 1/(((float)WaveLenth)*((float)CurTimePerDiv)/50);//(1/(WaveLenth*CurTimePerDiv/50/1000))*1000 kHz
|
CurWaveFrq = 1/(((float)WaveLenth)*((float)CurTimePerDiv)/50);//(1/(WaveLenth*CurTimePerDiv/50/1000))*1000 kHz
|
||||||
Setting_Inf_Update(0);
|
Setting_Inf_Update(0);
|
||||||
|
WaveLenth = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
@ -302,7 +312,8 @@ void PlotWave(void* parameter)
|
||||||
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, Wave_Centor_Y-(Wave_Height/2)+ADC_ConvertedValue[i],
|
||||||
|
Wave_Centor_X-(Wave_Width/2)+i+1, Wave_Centor_Y-(Wave_Height/2)+ADC_ConvertedValue[i+1] );
|
||||||
}
|
}
|
||||||
//频率显示
|
//频率显示
|
||||||
CalculateFrequency();//计算和刷新一起
|
CalculateFrequency();//计算和刷新一起
|
||||||
|
@ -343,7 +354,6 @@ void Setting(void* parameter)
|
||||||
queue_status = rt_mq_recv(setting_data_queue, &setting_data, sizeof(setting_data), 5000);//五秒钟无操作则退出设置
|
queue_status = rt_mq_recv(setting_data_queue, &setting_data, sizeof(setting_data), 5000);//五秒钟无操作则退出设置
|
||||||
if(queue_status == RT_EOK)
|
if(queue_status == RT_EOK)
|
||||||
{
|
{
|
||||||
rt_kprintf("setting_data: %d\n",setting_data);
|
|
||||||
switch(setting_data)
|
switch(setting_data)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -429,7 +439,6 @@ void Key_Scan(void* parameter)
|
||||||
setting_data = 4;
|
setting_data = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rt_kprintf("setting_data: %d\n",setting_data);
|
|
||||||
rt_mq_send(setting_data_queue, &setting_data, sizeof(setting_data));
|
rt_mq_send(setting_data_queue, &setting_data, sizeof(setting_data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,15 +127,11 @@ void ADCx_Init(void)
|
||||||
|
|
||||||
|
|
||||||
FlagStatus Get_Trigger_Status(float d0, float d1)
|
FlagStatus Get_Trigger_Status(float d0, float d1)
|
||||||
{
|
{
|
||||||
char dispBuff[100];
|
|
||||||
|
|
||||||
if(TriggerModeNrb == 0)
|
if(TriggerModeNrb == 0)
|
||||||
{
|
{
|
||||||
if((d0 >= CurTriggerValue) && (d1 <= CurTriggerValue))
|
if((d0 >= CurTriggerValue) && (d1 <= CurTriggerValue))
|
||||||
{
|
{
|
||||||
sprintf(dispBuff,"%.1f V", d1);
|
|
||||||
rt_kprintf("d1: %s\n",dispBuff);
|
|
||||||
return SET;
|
return SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,8 +139,6 @@ FlagStatus Get_Trigger_Status(float d0, float d1)
|
||||||
{
|
{
|
||||||
if((d1 >= CurTriggerValue) && (d0 <= CurTriggerValue))
|
if((d1 >= CurTriggerValue) && (d0 <= CurTriggerValue))
|
||||||
{
|
{
|
||||||
sprintf(dispBuff,"%.1f V", d1);
|
|
||||||
rt_kprintf("d1: %s\n",dispBuff);
|
|
||||||
return SET;
|
return SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,8 @@ void rt_hw_board_init()
|
||||||
PS2_Key_Config();
|
PS2_Key_Config();
|
||||||
|
|
||||||
//其中0、3、5、6 模式适合从左至右显示文字,
|
//其中0、3、5、6 模式适合从左至右显示文字,
|
||||||
//不推荐使用其它模式显示文字 其它模式显示文字会有镜像效果
|
//不推荐使用其它模式显示文字 其它模式显示文字会有镜像效果
|
||||||
//其中 6 模式为大部分液晶例程的默认显示方向
|
//其中 6 模式为大部分液晶例程的默认显示方向
|
||||||
ILI9341_GramScan ( 3 );
|
ILI9341_GramScan ( 3 );
|
||||||
LCD_SetColors(WHITE, BLACK);
|
LCD_SetColors(WHITE, BLACK);
|
||||||
ILI9341_Clear(0,0,LCD_X_LENGTH,LCD_Y_LENGTH);
|
ILI9341_Clear(0,0,LCD_X_LENGTH,LCD_Y_LENGTH);
|
||||||
|
@ -80,7 +80,7 @@ void rt_hw_board_init()
|
||||||
/*使用c标准库把变量转化成字符串*/
|
/*使用c标准库把变量转化成字符串*/
|
||||||
sprintf(dispBuff,"%.1fV", CurTriggerValue);
|
sprintf(dispBuff,"%.1fV", CurTriggerValue);
|
||||||
ILI9341_DispString_EN(Div*1+StartPos_X+10, StartPos_Y, dispBuff);
|
ILI9341_DispString_EN(Div*1+StartPos_X+10, StartPos_Y, dispBuff);
|
||||||
ILI9341_DispString_EN(Div*2+StartPos_X+15, StartPos_Y, CurTriggerMode);
|
ILI9341_DispString_EN(Div*2+StartPos_X+5, StartPos_Y, CurTriggerMode);
|
||||||
ILI9341_DispString_EN(Div*3+StartPos_X, StartPos_Y, CurSamplingMode);
|
ILI9341_DispString_EN(Div*3+StartPos_X, StartPos_Y, CurSamplingMode);
|
||||||
sprintf(dispBuff,"%dms", CurTimePerDiv);
|
sprintf(dispBuff,"%dms", CurTimePerDiv);
|
||||||
ILI9341_DispString_EN(Div*4+StartPos_X, StartPos_Y, dispBuff);
|
ILI9341_DispString_EN(Div*4+StartPos_X, StartPos_Y, dispBuff);
|
||||||
|
|
Loading…
Reference in New Issue