采样模式调试通过。。。舒服
This commit is contained in:
parent
2a8f902286
commit
6ea41e3def
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MeasurementRange 3.2
|
#define MeasurementRange 3.3
|
||||||
|
|
||||||
/*
|
/*
|
||||||
******************************************************************
|
******************************************************************
|
||||||
|
@ -70,13 +70,14 @@ FlagStatus StopSample = RESET;//ֹͣ
|
||||||
*/
|
*/
|
||||||
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 0:
|
case 0:
|
||||||
{
|
{
|
||||||
if((Operation > 0) && (CurTriggerValue < MeasurementRange))
|
if((Operation > 0) && (CurTriggerValue < MeasurementRange))
|
||||||
CurTriggerValue += 0.1;
|
CurTriggerValue += 0.1;
|
||||||
if((Operation < 0) && (CurTriggerValue > 0.1))
|
if((Operation < 0) && (CurTriggerValue > 0.0))
|
||||||
CurTriggerValue -= 0.1;
|
CurTriggerValue -= 0.1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +124,8 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rt_kprintf("TriggerValue: %.1f\n",CurTriggerValue);
|
sprintf(dispBuff,"%.1f V", CurTriggerValue);
|
||||||
|
rt_kprintf("TriggerValue: %s\n",dispBuff);
|
||||||
rt_kprintf("RangeMode: %s\n",CurSamplStatus);
|
rt_kprintf("RangeMode: %s\n",CurSamplStatus);
|
||||||
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);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "bsp_adc.h"
|
#include "bsp_adc.h"
|
||||||
#include "bsp_TiMbase.h"
|
#include "bsp_TiMbase.h"
|
||||||
#include "OSC.h"
|
#include "OSC.h"
|
||||||
|
#include "bsp_usart.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,32 +128,42 @@ void ADCx_Init(void)
|
||||||
|
|
||||||
FlagStatus Get_Trigger_Status(void)
|
FlagStatus Get_Trigger_Status(void)
|
||||||
{
|
{
|
||||||
uint16_t d0, d1;
|
float d0, d1;
|
||||||
uint8_t ConvertedTriggerValue = CurTriggerValue/3.3*200-0.5;//用于转换触发阀值
|
char dispBuff[100];
|
||||||
|
|
||||||
if(SamplingModeNrb == 0)
|
if(SamplingModeNrb == 0)
|
||||||
return SET;
|
return SET;
|
||||||
else if((SamplingModeNrb == 1) || (SamplingModeNrb == 2))
|
else if((SamplingModeNrb == 1) || (SamplingModeNrb == 2))
|
||||||
{
|
{
|
||||||
while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) == RESET);
|
while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) == RESET);
|
||||||
d0 = ADC_GetConversionValue(ADCx_1);
|
d0 = ADC_GetConversionValue(ADCx_1)/4096.0*3.3;
|
||||||
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
||||||
|
|
||||||
while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) == RESET);
|
while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) == RESET);
|
||||||
d1 = ADC_GetConversionValue(ADCx_1);
|
d1 = ADC_GetConversionValue(ADCx_1)/4096.0*3.3;
|
||||||
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(TriggerModeNrb == 0)
|
if(TriggerModeNrb == 0)
|
||||||
{
|
{
|
||||||
if((d0 >= ConvertedTriggerValue) && (d1 <= ConvertedTriggerValue))
|
if((d0 >= CurTriggerValue) && (d1 <= CurTriggerValue))
|
||||||
|
{
|
||||||
|
sprintf(dispBuff,"%.1f V", d1);
|
||||||
|
rt_kprintf("d1: %s\n",dispBuff);
|
||||||
return SET;
|
return SET;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(TriggerModeNrb == 1)
|
else if(TriggerModeNrb == 1)
|
||||||
{
|
{
|
||||||
if((d1 >= ConvertedTriggerValue) && (d0 <= ConvertedTriggerValue))
|
if((d1 >= CurTriggerValue) && (d0 <= CurTriggerValue))
|
||||||
|
{
|
||||||
|
sprintf(dispBuff,"%.1f V", d1);
|
||||||
|
rt_kprintf("d1: %s\n",dispBuff);
|
||||||
return SET;
|
return SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return RESET;
|
return RESET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +171,7 @@ FlagStatus Get_Trigger_Status(void)
|
||||||
|
|
||||||
void Get_Wave(void* parameter)
|
void Get_Wave(void* parameter)
|
||||||
{
|
{
|
||||||
uint8_t flag = 1, i=1;//波形数据采集完成标志位
|
uint8_t flag = 1;//波形数据采集完成标志位
|
||||||
uint16_t ADC_SampleCount = 0;
|
uint16_t ADC_SampleCount = 0;
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
|
@ -176,18 +187,18 @@ void Get_Wave(void* parameter)
|
||||||
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
||||||
ADC_SampleCount++;
|
ADC_SampleCount++;
|
||||||
}
|
}
|
||||||
if(i==1)
|
// if(i==1)
|
||||||
{
|
// {
|
||||||
i=0;
|
// i=0;
|
||||||
while(i < ADCx_1_SampleNbr)
|
// while(i < ADCx_1_SampleNbr)
|
||||||
{
|
// {
|
||||||
rt_kprintf("%d ",ADC_ConvertedValue[i]);
|
// rt_kprintf("%d ",ADC_ConvertedValue[i]);
|
||||||
if(i%10 == 0)
|
// if(i%10 == 0)
|
||||||
rt_kprintf("\n");
|
// rt_kprintf("\n");
|
||||||
i++;
|
// i++;
|
||||||
}
|
// }
|
||||||
i=0;
|
// i=0;
|
||||||
}
|
// }
|
||||||
if(SamplingModeNrb == 2)
|
if(SamplingModeNrb == 2)
|
||||||
{
|
{
|
||||||
StopSample = SET;
|
StopSample = SET;
|
||||||
|
|
Loading…
Reference in New Issue