单片机是stm32f103zet6,程序不大。同一个程序,有的板子死机,有的不死机。追查死机原因,是因为一个指针数组的地址变化了。
for(m1=0;m1<Num;m1++)
{
m3=0;
for(m2=0;m2<8;m2++)
{
if(m1==Num-1&&mood!=0)
{
for(m0=0;m0<mood;m0++)m3+=*ReadBL_address[m1*8+m0]<<m0;
}
else m3+=*ReadBL_address[m1*8+m2]<<m2;
}
*(out+3+m1)=m3;
if(*ReadBL_address[80]==1)
Send_Num =1+1+1+Num+2;
}
}
就经过这段程序 ,地址变的,
这是数组的初始化
ReadBL_address[0]=&gl1.wl_bl.out1;
ReadBL_address[1]=&gl2.wl_bl.out1;
ReadBL_address[2]=&gl3.wl_bl.out1;
ReadBL_address[3]=&gl4.wl_bl.out1;
ReadBL_address[4]=&gl0.wl_bl.out1;
ReadBL_address[5]=&sn1.wl_bl.out1;
ReadBL_address[6]=&sn2.wl_bl.out1;
ReadBL_address[7]=&sn3.wl_bl.out1;
ReadBL_address[8]=&sn4.wl_bl.out1;
ReadBL_address[9]=&mh2.wl_bl.out1;
ReadBL_address[10]=&gl0.wl_bl.out1;
ReadBL_address[11]=&shui1.wl_bl.out1;
ReadBL_address[12]=&shui2.wl_bl.out1;
ReadBL_address[13]=&sj1.wl_bl.out1;
ReadBL_address[14]=&sj2.wl_bl.out1;
ReadBL_address[15]=&gl0.wl_bl.out1;
ReadBL_address[16]=&gl0.wl_bl.out1;
ReadBL_address[17]=&gl0.wl_bl.out1;
ReadBL_address[18]=&gl0.wl_bl.out1;
ReadBL_address[19]=&gl0.wl_bl.out1;
ReadBL_address[20]=&gl1.wl_bl.out2;
ReadBL_address[21]=&gl2.wl_bl.out2;
ReadBL_address[22]=&gl3.wl_bl.out2;
ReadBL_address[23]=&gl4.wl_bl.out2;
ReadBL_address[24]=&gl0.wl_bl.out2;
ReadBL_address[25]=&sn1.wl_bl.out2;
ReadBL_address[26]=&sn2.wl_bl.out2;
ReadBL_address[27]=&sn3.wl_bl.out2;
ReadBL_address[28]=&sn4.wl_bl.out2;
ReadBL_address[29]=&mh2.wl_bl.out2;
ReadBL_address[30]=&gl0.wl_bl.out2;
ReadBL_address[31]=&shui1.wl_bl.out2;
ReadBL_address[32]=&shui2.wl_bl.out2;
ReadBL_address[33]=&sj1.wl_bl.out2;
ReadBL_address[34]=&sj2.wl_bl.out2;
ReadBL_address[35]=&gl0.wl_bl.out2;
ReadBL_address[36]=&gl0.wl_bl.out2;
ReadBL_address[37]=&gl0.wl_bl.out2;
ReadBL_address[38]=&gl0.wl_bl.out2;
ReadBL_address[39]=&gl0.wl_bl.out2;
求大神们什么原因让地址变得,
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>