stm32f103RCT6芯片,正在做液晶示波器,但是出现了应该是关于数组的问题,编译未出错,运行通过串口测试是卡在下面函数的36行,红字标识,下面是出错的函数,其余部分没有对这段函数产生影响。
麻烦大神帮忙解答。
#include "stm32f10x.h"
#include "delay.h"
#include "tft.h"
#include "lcd.h"
#include "gui.h"
#include "adc.h"
#include "time.h"
#include "jshz.h"
#include "bxhs.h"
unsigned char Num[10]={0,1,2,3,4,5,6,7,8,9};
unsigned int m=0;
static int z;
void bxhs10_50HZ(void)
{
float temp1[128],temp2[128],adcx,num=0;
float tempx[128],tempy[128];
int hz=0,x,y,a,b;
USART_SendData(USART1,0);
delay_ms(10);
TIM_Cmd(TIM3,ENABLE);//?aê???ê±
for(x=0;x<128;x++)//?áμúò?′?μ?
{
USART_SendData(USART1,1);
delay_ms(10);
while(m==0);
m=0;
USART_SendData(USART1,2);
delay_ms(10);
adcx=Get_Adc_Average(ADC_Channel_1,2);
temp1[x]=(float)adcx*(3.3/4096)*20;//-1.64;
本函数就是卡在这个temp1数组这里出不去,这是个adc接收并存在数组的for循环, 当这条指令的数组的改成tempx时便能运行出去,下面的temp2也是一样,
USART_SendData(USART1,3);
delay_ms(10);
}
TIM_Cmd(TIM3,DISABLE);//í£?1??ê±
// z=jshz(temp1,z);//?????μ?ê
/*for(x=0;x<128;x++)
{
for(y=0;y<10;y++)
{
num=num+temp1[x*10+y];
}
tempx[x]=num/10;
num=0;
}*/
USART_SendData(USART1,0);
delay_ms(10);
for(x=0;x<127;x++)//2áμú?t′?μ?
{
a=tempy[x];
b=tempy[x+1];
if(a>31)a=31;
if(a<-31)a=-31;
if(b>31)b=31;
if(b<-31)b=-31;
Gui_DrawLine(x,31-a,x,31-b,BLACK);
}
USART_SendData(USART1,1);
delay_ms(10);
wg();
hz=10000/z;
Gui_DrawFont_GBK16(62,105,GREEN,BLACK,"f=");
if(hz>=10000)
{
if(hz>99999)hz=99999;
Gui_DrawFont_SZHS16(70,105,GREEN,BLACK,Num[hz/10000]);
Gui_DrawFont_GBK16(78,105,GREEN,BLACK,".");
Gui_DrawFont_SZHS16(86,105,GREEN,BLACK,Num[hz/1000%10]);
Gui_DrawFont_SZHS16(94,105,GREEN,BLACK,Num[hz/100%10]);
Gui_DrawFont_GBK16(102,105,GREEN,BLACK,"KHZ");
}
else
{
Gui_DrawFont_SZHS16(70,105,GREEN,BLACK,Num[hz/1000]);
Gui_DrawFont_SZHS16(78,105,GREEN,BLACK,Num[hz/100%10]);
Gui_DrawFont_SZHS16(86,105,GREEN,BLACK,Num[hz/10%10]);
Gui_DrawFont_GBK16(102,105,BLACK,BLACK,"KHZ");
Gui_DrawFont_GBK16(94,105,GREEN,BLACK,"HZ");
}
USART_SendData(USART1,2);
delay_ms(10);
for(x=0;x<127;x++)//D′μúò?′?μ?
{
a=tempx[x];
b=tempx[x+1];
if(a>31)a=31;
if(a<-31)a=-31;
if(b>31)b=31;
if(b<-31)b=-31;
Gui_DrawLine(x,31-a,x,31-b,WHITE);
}
USART_SendData(USART1,3);
delay_ms(10);
TIM_Cmd(TIM3,ENABLE);//?aê???ê±
for(x=0;x<128;x++)//?áμú?t′?μ?
{
while(m==0);
m=0;
adcx=Get_Adc_Average(ADC_Channel_1,2);
temp2[x]=(float)adcx*(3.3/4096)*20;//-1.64;
//Gui_DrawFont_GBK16(5,73,GREEN,BLACK,temp);
}
TIM_Cmd(TIM3,DISABLE);//í£?1??ê±
//z=jshz(temp2,z);//?????μ?ê
/*for(x=0;x<128;x++)
{
for(y=0;y<10;y++)
{
num=num+temp2[x*10+y];
}
tempy[x]=num/10;
num=0;
}*/
for(x=0;x<127;x++)//2áμúò?′?μ?
{
a=tempx[x];
b=tempx[x+1];
if(a>31)a=31;
if(a<-31)a=-31;
if(b>31)b=31;
if(b<-31)b=-31;
Gui_DrawLine(x,31-a,x,31-b,BLACK);
}
wg();
hz=10000/z;
Gui_DrawFont_GBK16(62,105,GREEN,BLACK,"f=");
if(hz>=10000)
{
if(hz>99999)hz=99999;
Gui_DrawFont_SZHS16(70,105,GREEN,BLACK,Num[hz/10000]);
Gui_DrawFont_GBK16(78,105,GREEN,BLACK,".");
Gui_DrawFont_SZHS16(86,105,GREEN,BLACK,Num[hz/1000%10]);
Gui_DrawFont_SZHS16(94,105,GREEN,BLACK,Num[hz/100%10]);
Gui_DrawFont_GBK16(102,105,GREEN,BLACK,"KHZ");
}
else
{
Gui_DrawFont_SZHS16(70,105,GREEN,BLACK,Num[hz/1000]);
Gui_DrawFont_SZHS16(78,105,GREEN,BLACK,Num[hz/100%10]);
Gui_DrawFont_SZHS16(86,105,GREEN,BLACK,Num[hz/10%10]);
Gui_DrawFont_GBK16(102,105,BLACK,BLACK,"KHZ");
Gui_DrawFont_GBK16(94,105,GREEN,BLACK,"HZ");
}
for(x=0;x<127;x++)//D′μú?t′?μ?
{
a=tempy[x];
b=tempy[x+1];
if(a>31)a=31;
if(a<-31)a=-31;
if(b>31)b=31;
if(b<-31)b=-31;
Gui_DrawLine(x,31-a,x,31-b,WHITE);
}
}
怎么解决溢出问题呢
一周热门 更多>