|  | 
 
| 有点长,不过这个问题真的很奇怪,有兴趣的朋友可以耐心看看 
 主文件如下:
 
 void * test_function[][2]=    /* 二维指针数组,存放待测试的几个项目 */
 {
 (void *)Test_Led,    "LED test      ",
 (void *)Test_KeyBoard,    "keyboard      ",
 (void *)Timer_Pwm,"Test PWM and pwm timer   ",
 (void *)Test_Rtc,    "RTC test    ",
 (void *)Test_Adc,    "ADC sampling test      ",
 (void *)Test_Printf,"Test Printf   ",
 0,    0
 };
 
 ////////////////////////////////////////////////////////////////////////////
 
 void Main(void)
 {
 U32 i;
 
 rSYSCFG = SYSCFG_8KB;
 
 #if (PLLON == 1)
 ChangePllValue(PLL_M,PLL_P,PLL_S);
 
 #endif
 
 Port_Init();
 
 Isr_Init();/* 中断初始化,使能IRQ,禁止FIQ,使用非矢量中断 */
 
 Uart_Init(0,115200);/* 串口初始化,设置串口0波特率:115200bps */
 
 Delay(0);  /* 校准延时时间 */
 
 while(1)
 {
 i = 0;
 Uart_Printf("\n\n\n            Welcome to SW44B0 test!             \n");
 Uart_Printf("            Now,let's start.                    \n\n");
 
 while(1)
 {
 Uart_Printf("%2d:%s",i+1,test_function[1]);
 i++;
 if((int)(test_function[0]) == 0)
 {
 Uart_Printf("\n");
 break;/* 退出循环 */
 }
 if((i%4) == 0)
 Uart_Printf("\n");
 }
 
 Uart_Printf("\nPlease select which peripheral you want to test:");
 
 i = Uart_GetIntNum();/* 获取输入的数字 */
 
 i--;/* i自减 */
 
 Uart_Printf("\n");
 
 if((i < (sizeof(test_function)/
  ) )/* 无符号整型总是大于或等于0 */ ( (void (*)(void)) (test_function[0]) )();
 }
 }
 
 
 显示主界面如下:
 
 Welcome to SW44B0 test!
 Now,let's start.
 
 1:LED test        2:keyboard      3:Test PWM and pwm timer    4:RTC test
 5:ADC sampling test       6:Test Printf
 
 Please select which peripheral you want to test:
 
 其中,2,3,4中都涉及到中断处理,比如,keyboard我使用的是中断请求的方法,四个按键分别接EINT4~EINT7中断。
 现在的问题是,当我在主界面输入1或者5,即选择没涉及中断的测试项目时,程序就能正常运行,所谓正常运行,在这里
 就是指i = Uart_GetIntNum();这句话返回后,i确实为1。但是当我选择2,3或者4即选择涉及到中断的选项时,i = Uart_GetIntNum();返回的
 i是0而不是2,3或者4,这样i--后,i为0xffffffff,自然,不会进入相应的处理函数了。
 我是用单步调试观察i值的,进入Uart_GetIntNum()函数后,确实很奇怪,i=1或者5都很正常返回,可是i=2,3,4时却返回0,真的是百思不得其解。
 我用sdt生成的bin文件没有这些问题的。
 兄弟们帮帮忙,课题很急,如果再解决不了的话,我可能又要重新用sdt了
 谢谢
 | 
 |