终于看到正弦波了 哈哈哈哈

This commit is contained in:
zhan-min 2020-12-14 23:46:15 +08:00
parent edd4771aed
commit 16f3f304f2
9 changed files with 2411 additions and 2359 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\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

View File

@ -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

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.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>

View File

@ -10,7 +10,7 @@
#define MeasurementRange 200 #define MeasurementRange 3.2
/* /*
****************************************************************** ******************************************************************
@ -31,7 +31,7 @@ rt_thread_t KeyScan_thread = RT_NULL;
//可设置项 //可设置项
char* RangeMode[] = {"Auto", "Manu"}; char* RangeMode[] = {"Auto", "Manu"};
char* TriggerMode[] = {"", ""}; char* TriggerMode[] = {"Up", "Down"};
char* SamplingMode[] = {"A", "N", "S"}; char* SamplingMode[] = {"A", "N", "S"};
uint16_t TimePerDiv_Group[] = {2, 5, 10, 20, 50, 100, 200, 500}; uint16_t TimePerDiv_Group[] = {2, 5, 10, 20, 50, 100, 200, 500};
@ -42,11 +42,11 @@ uint8_t TimePerDivOderNbr = sizeof(TimePerDiv_Group)/sizeof(TimePerDiv_Group[0]
int8_t TimePerDivOder = 0;//当前每格间隔时间的序号 int8_t TimePerDivOder = 0;//当前每格间隔时间的序号
int16_t CurTriggerValue = 0; //代号0触发阀值 float CurTriggerValue = 0.0; //代号0触发阀值
char* CurRangeMode = {"auto"}; //代号1量程模式0自动1手动 char* CurRangeMode = {"Auto"}; //代号1量程模式0自动1手动
char* CurTriggerMode = {""}; //代号2触发模式0下降沿触发1上升沿触发 char* CurTriggerMode = {"Up"}; //代号2触发模式0下降沿触发1上升沿触发
char* CurSamplingMode = {"A"}; //代号3采样模式0自动1普通2单次 char* CurSamplingMode = {"A"}; //代号3采样模式0自动1普通2单次
uint16_t CurTimePerDiv = 1; //代号4每格代表的时间间隔 uint16_t CurTimePerDiv = 500; //代号4每格代表的时间间隔
//要显示的信息 //要显示的信息
__IO uint16_t ADC_ConvertedValue[ADCx_1_SampleNbr] = {0};//ADC采集数据 __IO uint16_t ADC_ConvertedValue[ADCx_1_SampleNbr] = {0};//ADC采集数据
@ -73,11 +73,10 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
{ {
case 0: case 0:
{ {
CurTriggerValue += Operation; if((Operation > 0) && (CurTriggerValue < MeasurementRange))
if(CurTriggerValue < 0) CurTriggerValue += 0.1;
CurTriggerValue = 0; if((Operation < 0) && (CurTriggerValue > 0.1))
if(CurTriggerValue > MeasurementRange) CurTriggerValue -= 0.1;
CurTriggerValue = MeasurementRange;
break; break;
} }
case 1: case 1:
@ -87,6 +86,7 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
RangeModeNrb = 0; RangeModeNrb = 0;
if(RangeModeNrb > 1) if(RangeModeNrb > 1)
RangeModeNrb = 1; RangeModeNrb = 1;
CurRangeMode = RangeMode[RangeModeNrb];
break; break;
} }
case 2: case 2:
@ -96,6 +96,7 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
TriggerModeNrb = 0; TriggerModeNrb = 0;
if(TriggerModeNrb > 1) if(TriggerModeNrb > 1)
TriggerModeNrb = 1; TriggerModeNrb = 1;
CurTriggerMode = TriggerMode[TriggerModeNrb];
break; break;
} }
case 3: case 3:
@ -105,6 +106,7 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
SamplingModeNrb = 0; SamplingModeNrb = 0;
if(SamplingModeNrb > 2) if(SamplingModeNrb > 2)
SamplingModeNrb = 2; SamplingModeNrb = 2;
CurSamplingMode = SamplingMode[SamplingModeNrb];
break; break;
} }
case 4: case 4:
@ -120,7 +122,7 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
default : default :
break; break;
} }
rt_kprintf("TriggerValue: %d\n",CurTriggerValue); rt_kprintf("TriggerValue: %.1f\n",CurTriggerValue);
rt_kprintf("RangeMode: %s\n",CurRangeMode); rt_kprintf("RangeMode: %s\n",CurRangeMode);
rt_kprintf("TriggerMode: %s\n",CurTriggerMode); rt_kprintf("TriggerMode: %s\n",CurTriggerMode);
rt_kprintf("Sampling_mode: %s\n",CurSamplingMode); rt_kprintf("Sampling_mode: %s\n",CurSamplingMode);
@ -136,37 +138,40 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
*/ */
void Setting_Inf_Update(uint8_t CurSetItem) void Setting_Inf_Update(uint8_t CurSetItem)
{ {
char dispBuff[100]; char dispBuff[100];
float ConvertedTriggerValue;//用于将触发阀值单位转换为伏特
ILI9341_Clear(240, 0, 20, 240); ILI9341_Clear(240, 0, 20, 240);
ILI9341_DispString_EN(240, (((sFONT *)LCD_GetFont())->Height)*CurSetItem, "->"); ILI9341_DispString_EN(240, (((sFONT *)LCD_GetFont())->Height)*CurSetItem, "->");
switch(CurSetItem) switch(CurSetItem)
{ {
case 0: case 0:
{ {
ConvertedTriggerValue = CurTriggerValue/200*3.3; ILI9341_Clear(260, (((sFONT *)LCD_GetFont())->Height)*0, 60, (((sFONT *)LCD_GetFont())->Height));
/*使用c标准库把变量转化成字符串*/ /*使用c标准库把变量转化成字符串*/
sprintf(dispBuff,"%f V", ConvertedTriggerValue); sprintf(dispBuff,"%.1f V", CurTriggerValue);
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*0, dispBuff); ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*0, dispBuff);
break; break;
} }
case 1: case 1:
{ {
ILI9341_Clear(260, (((sFONT *)LCD_GetFont())->Height)*1, 60, (((sFONT *)LCD_GetFont())->Height));
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*1, CurRangeMode); ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*1, CurRangeMode);
break; break;
} }
case 2: case 2:
{ {
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*0, CurTriggerMode); ILI9341_Clear(260, (((sFONT *)LCD_GetFont())->Height)*2, 60, (((sFONT *)LCD_GetFont())->Height));
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*2, CurTriggerMode);
break; break;
} }
case 3: case 3:
{ {
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*1, CurSamplingMode); ILI9341_Clear(260, (((sFONT *)LCD_GetFont())->Height)*3, 60, (((sFONT *)LCD_GetFont())->Height));
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*3, CurSamplingMode);
break; break;
} }
case 4: case 4:
{ {
ILI9341_Clear(260, (((sFONT *)LCD_GetFont())->Height)*4, 60, (((sFONT *)LCD_GetFont())->Height));
/*使用c标准库把变量转化成字符串*/ /*使用c标准库把变量转化成字符串*/
sprintf(dispBuff,"%d ms", CurTimePerDiv); sprintf(dispBuff,"%d ms", CurTimePerDiv);
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*4, dispBuff); ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*4, dispBuff);
@ -249,7 +254,7 @@ 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] /21, Wave_Centor_X-(Wave_Width/2)+i+1, ADC_ConvertedValue[i+1] /21 ); ILI9341_DrawLine ( Wave_Centor_X-(Wave_Width/2)+i, ADC_ConvertedValue[i], Wave_Centor_X-(Wave_Width/2)+i+1, ADC_ConvertedValue[i+1] );
} }
} }
flag = 0; flag = 0;

View File

@ -16,7 +16,7 @@ extern int8_t RangeModeNrb;
extern int8_t TriggerModeNrb; extern int8_t TriggerModeNrb;
extern int8_t SamplingModeNrb; extern int8_t SamplingModeNrb;
extern int16_t CurTriggerValue; //代号0触发阀值 extern float CurTriggerValue; //代号0触发阀值
extern char* CurRangeMode; //代号1量程模式0自动1手动 extern char* CurRangeMode; //代号1量程模式0自动1手动
extern char* CurTriggerMode; //代号2触发模式0下降沿触发1上升沿触发2上升沿下降沿触发 extern char* CurTriggerMode; //代号2触发模式0下降沿触发1上升沿触发2上升沿下降沿触发
extern char* CurSamplingMode; //代号3采样模式0自动1普通2单次 extern char* CurSamplingMode; //代号3采样模式0自动1普通2单次

View File

@ -128,6 +128,7 @@ void ADCx_Init(void)
FlagStatus Get_Trigger_Status(void) FlagStatus Get_Trigger_Status(void)
{ {
uint16_t d0, d1; uint16_t d0, d1;
uint8_t ConvertedTriggerValue = CurTriggerValue/3.3*200-0.5;//用于转换触发阀值
if(SamplingModeNrb == 0) if(SamplingModeNrb == 0)
return SET; return SET;
@ -143,12 +144,12 @@ FlagStatus Get_Trigger_Status(void)
if(TriggerModeNrb == 0) if(TriggerModeNrb == 0)
{ {
if((d0 >= CurTriggerValue) && (d1 <= CurTriggerValue)) if((d0 >= ConvertedTriggerValue) && (d1 <= ConvertedTriggerValue))
return SET; return SET;
} }
else if(TriggerModeNrb == 1) else if(TriggerModeNrb == 1)
{ {
if((d1 >= CurTriggerValue) && (d0 <= CurTriggerValue)) if((d1 >= ConvertedTriggerValue) && (d0 <= ConvertedTriggerValue))
return SET; return SET;
} }
} }
@ -159,7 +160,7 @@ FlagStatus Get_Trigger_Status(void)
void Get_Wave(void* parameter) void Get_Wave(void* parameter)
{ {
uint8_t flag = 1;//波形数据采集完成标志位 uint8_t flag = 1, i=1;//波形数据采集完成标志位
uint16_t ADC_SampleCount = 0; uint16_t ADC_SampleCount = 0;
while(1) while(1)
@ -170,11 +171,23 @@ void Get_Wave(void* parameter)
while(ADC_SampleCount < ADCx_1_SampleNbr) while(ADC_SampleCount < ADCx_1_SampleNbr)
{ {
while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) != SET); while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) != SET);
ADC_ConvertedValue[ADC_SampleCount] = ADC_GetConversionValue(ADCx_1)*200/255-0.5;//将采样值映射到显示区间 ADC_ConvertedValue[ADC_SampleCount] = ADC_GetConversionValue(ADCx_1)*200/4096-0.5;//将采样值映射到显示区间
Delay_us( CurTimePerDiv*1000/50 -7 );//²ÉÑù¼ä¸ôʱ¼ä Delay_us( CurTimePerDiv*1000/50 -7 );//²ÉÑù¼ä¸ôʱ¼ä
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC); ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
ADC_SampleCount++; ADC_SampleCount++;
} }
if(i==1)
{
i=0;
while(i < ADCx_1_SampleNbr)
{
rt_kprintf("%d ",ADC_ConvertedValue[i]);
if(i%10 == 0)
rt_kprintf("\n");
i++;
}
i=0;
}
if(SamplingModeNrb == 2) if(SamplingModeNrb == 2)
{ {
StopSample = SET; StopSample = SET;

View File

@ -74,18 +74,15 @@ void rt_hw_board_init()
ILI9341_DispString_EN(240, (((sFONT *)LCD_GetFont())->Height)*0, "->"); ILI9341_DispString_EN(240, (((sFONT *)LCD_GetFont())->Height)*0, "->");
char dispBuff[100]; char dispBuff[100];
/*使用c标准库把变量转化成字符串*/
sprintf(dispBuff,"TV: %d", CurTriggerValue);
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*0, dispBuff);
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*0, "0.0 V");
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*1, CurRangeMode); ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*1, CurRangeMode);
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*2, CurTriggerMode); ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*2, CurTriggerMode);
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*3, CurSamplingMode);
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*3, CurTriggerMode); /*使用c标准库把变量转化成字符串*/
sprintf(dispBuff,"%d ms", CurTimePerDiv);
sprintf(dispBuff,"TPD: %d", CurTimePerDiv);
ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*4, dispBuff); ILI9341_DispString_EN(260, (((sFONT *)LCD_GetFont())->Height)*4, dispBuff);