我在IAR for ARM4.41A中编写了一段代码,是汉字库,只有40个汉字。现在我遇到了一个问题。如果我不用const,只用unsigned char disp[132]={。。。};,第一行汉字中有几个规则的图标,上半行。如果我8行汉字全采用const定义,则程序不能运行(死机)。如果最后一行汉字不用const,那几个规则的图标就在最后一行出现(最后半行)。我用RAM方式仿真的时候没有错(没有奇怪的图标出现),只是在remapping ram之后才有。请问各位高人谁知道这是什么问题?不是硬件的问题。
数组重新定义了
我现在将16X16的汉字数组定义成一个二维数组,只要加上const定义,程序就死机,停在0x0000001C(B寄存器)。不加const定义,显示就有奇怪图标。有谁知道是什么原因吗?
RE
用const定义的话,数据位于flash中。不要光说死机,至少跟一下程序,看看在访问什么地址时死机?
程序在这里死机
static void ADCTaskStart(void *p_arg)
{
p_arg = p_arg;
data_V = 0;
data_T = 0;
value_V = 0;
value_T = 0;
port180_V = 0;
port180_T = 0;
GPIO_Config (GPIO1,0x0003,GPIO_HI_AIN_TRI);
GPIO_Config (GPIO1,0x6000,GPIO_OUT_PP);
GPIO_Config (GPIO2,0x0400,GPIO_OUT_PP);
DispInitBT();
ADC12_Init();
ADC12_ITConfig(DISABLE);
ADC12_PrescalerConfig(100);
ADC12_ModeConfig(ADC12_SINGLE);
for(;;)
{
while(port180_V <= 59)
{
ADC_bit_init_V(port180_V);
ADC12_ChannelSelect(ADC12_CHANNEL0);
ADC12_ConversionStart();
while(ADC12_FlagStatus(ADC12_DA0) == RESET);
data_V = ADC12_ConversionValue(ADC12_CHANNEL0);
value_V = ADC12_Calib(data_V);
if(port180_V <= 59)
{
result_V[port180_V] = value_V;
port180_V++;
}
}
while(port180_T <= 59)
{
ADC_bit_init_T(port180_T);
ADC12_ChannelSelect(ADC12_CHANNEL0);
ADC12_ConversionStart();
while(ADC12_FlagStatus(ADC12_DA0) == RESET);
data_T = ADC12_ConversionValue(ADC12_CHANNEL0);
value_T = ADC12_Calib(data_T);
if(port180_T <= 59)
{
result_T[port180_T] = value_T;
port180_T++;
}
}
ADC_Current();
// DispClear();
DispStart();
OSTimeDlyHMSM(0, 0, 0, 50);
}
}
第一个while循环出不去,死锁了。考虑与数组的定义有关。
unsigned char port180_V;
unsigned char port180_T;
unsigned short data_V;
unsigned short data_T;
unsigned short data_C;
unsigned short value_V,value_T,value_C,result_C;
unsigned short result_V[90] = {0};
unsigned short result_T[90] = {0};
void ADC_bit_init_V(unsigned char port_V);
void ADC_bit_init_T(unsigned char port_T);
void ADC_Current();
void DispStart();
void Generic_Wait(unsigned long TimeSet);
void DispRefresh();
void DispClear();
void DispClearPart(unsigned char PageWantSet);
void DispInitBT();
unsigned short ADC12_Calib(unsigned short Conv_Res);
void Disp_ByteSend(unsigned char DataWantSend);
void DispStartPart();
unsigned char const Disp0[16] = {0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00};
unsigned char const Disp1[16] = {0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00};
。。。
不定一成const,例如定义成如下
unsigned char Disp0[16] = {0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00};
就不死机,但在显示屏上出现规则的奇怪图标。
DATA_Z和DATA_C
result_V是DATA_Z段,value_V也是DATA_Z段。
大家帮助分析一下,是不是启动代码从flash复制程序到RAM的过程中出问题了。
按道理DATA_Z段和DATA_C段没有冲突,各管各的,为什么加上const就出问题哪?上面的源程序第一个while循环出不来,死在那了。
str710程序改了一下,毛病依旧。
static void ADCTaskStart(void *p_arg)
{
unsigned char i;
unsigned char j;
p_arg = p_arg;
data_V = 0;
data_T = 0;
value_V = 0;
value_T = 0;
GPIO_Config (GPIO1,0x0003,GPIO_HI_AIN_TRI);
GPIO_Config (GPIO1,0x6000,GPIO_OUT_PP);
GPIO_Config (GPIO2,0x0400,GPIO_OUT_PP);
DispInitBT();
ADC12_Init();
ADC12_ITConfig(DISABLE);
ADC12_PrescalerConfig(100);
ADC12_ModeConfig(ADC12_SINGLE);
for(;;)
{
for(i = 0; i < 60; i++)
{
ADC_bit_init_V(i);
ADC12_ChannelSelect(ADC12_CHANNEL0);
ADC12_ConversionStart();
while(ADC12_FlagStatus(ADC12_DA0) == RESET);
data_V = ADC12_ConversionValue(ADC12_CHANNEL0);
value_V = ADC12_Calib(data_V);
result_V = value_V;
}
for(j = 0; j < 60; j++)
{
ADC_bit_init_T(j);
ADC12_ChannelSelect(ADC12_CHANNEL0);
ADC12_ConversionStart();
while(ADC12_FlagStatus(ADC12_DA0) == RESET);
data_T = ADC12_ConversionValue(ADC12_CHANNEL0);
value_T = ADC12_Calib(data_T);
result_T[j] = value_T;
}
ADC_Current();
// DispClear();
DispStart();
OSTimeDlyHMSM(0, 0, 0, 50);
}
}
unsigned short data_V;
unsigned short data_T;
unsigned short data_C;
unsigned short value_V,value_T,value_C,result_C;
unsigned short result_V[90] = {0};
unsigned short result_T[90] = {0};
void ADC_bit_init_V(unsigned char port_V);
void ADC_bit_init_T(unsigned char port_T);
void ADC_Current();
void DispStart();
void Generic_Wait(unsigned long TimeSet);
void DispRefresh();
void DispClear();
void DispClearPart(unsigned char PageWantSet);
void DispInitBT();
unsigned short ADC12_Calib(unsigned short Conv_Res);
void Disp_ByteSend(unsigned char DataWantSend);
void DispStartPart();
可能是remapping的问题。
可能是remapping的问题。
那位知道如何将要remapping的内容事先清零?ads1.2的我知道,IAR for ARM如何写程序?
str710问题讨论
有谁知道,或愿意和我讨论的?
我的QQ:401290908,269699223
Re
第一个while循换里每次port180_V都加1,怎么会出不去呢
如何判断死在第一个while中?
你是如何判断程序没有跳出第一个while?
请在第二个while处加一个断点,调试运行看是否能够停到这个断点?若不停,则强行停止运行,看看port180_V的值是多少?判断一下问题何在?