智能车制作

标题: 调试的时候Illegal BP是怎么回事? [打印本页]

作者: librae8226    时间: 2009-12-1 13:58
标题: 调试的时候Illegal BP是怎么回事?
我调了一个定义在另一个文件里的函数就出现这个问题了,
大家有遇到过吗?怎么解决的啊?
作者: chenrunshe_007    时间: 2009-12-7 13:45
回复 1# librae8226
不知所云,楼主最好讲的详细一点,有代码最好
作者: librae8226    时间: 2009-12-7 18:36
回复 2# chenrunshe_007

这是main.c代码(for(;;)里主要实现发送图像功能):

  1. #include "includes.h"
  2. #pragma CODE_SEG DEFAULT
  3. void main(void)
  4. {
  5.     /* put your own code here */
  6.     int i, j;
  7.    
  8.     DisableInterrupts;
  9.     SetBusCLK_48M();
  10.     TimerInit();
  11.     Port_Init();
  12.     PWM_Init();
  13.     SCI_Init();
  14.     EnableInterrupts;
  15.     for(;;)  
  16.     {
  17.         //Send Image
  18.         if( flag == 1 )
  19.         {
  20.             DisableInterrupts;
  21.             TFLG1 = 0x00;
  22.             flag = 0;
  23.             ImageBinarize();
  24.             for( i = 0; i < ROW_VALUE; i++ )
  25.             {
  26.                 PORTA_PA7 = !PORTA_PA7;
  27.                 for( j = 0; j < COLUMN_VALUE; j++ )
  28.                 {
  29.                     if( buff_b[i][j] == 1 )
  30.                         uart_putchar('1');
  31.                     else
  32.                         uart_putchar('0');
  33.                 }
  34.                 uart_putchar('\n');
  35.             }
  36.             uart_putchar('\n');
  37.         }
  38.         PORTA_PA1 = !PORTA_PA1;
  39.         TFLG1 = 0x0F;
  40.         EnableInterrupts;
  41.         //Send Complete
  42.     }
  43.     /* loop forever */
  44.     /* please make sure that you never leave main */
  45. }
复制代码


这是ImageProcess.c中的发送图像代码:

  1. #include "includes.h"

  2. // Illegal BP while debugging??
  3. void SendImage(void)
  4. {
  5.     int i,j;
  6.     int servflag = 3;
  7.     if( flag )            
  8.     {
  9.         DisableInterrupts;
  10.         TFLG1 = 0x00;
  11.         flag = 0;
  12.         BinarizeImage();
  13.         for( i = 0; i < ROW_VALUE; i++ )
  14.         {  
  15.             PORTA_PA7 = !PORTA_PA7;
  16.             for( j = 0; j < COLUMN_VALUE; j++ )
  17.             {
  18.                 if( buff_b[i][j] == 1 )
  19.                     uart_putchar('1');
  20.                 else
  21.                     uart_putchar('0');
  22.             }
  23.             uart_putchar(0x0a);
  24.             uart_putchar(0x0d);
  25.         }
  26.     }
  27.     TFLG1 = 0x0F;
  28.     EnableInterrupts;
  29. }
复制代码


如图:
全速执行后停止了:
[attach]815[/attach]

调试里的command窗口
[attach]816[/attach]
command里的消息
[attach]817[/attach]

问题在void SendImage(void)这个函数上,也就是说,如果我把函数内容写到main.c的for(;;)里,就可以实现发送图像,但是如果我把函数单独写到ImageProcess.c这个文件里,再在主函数里调,在调试的时候全速执行就会自己停止,同时出现Illegal BP这个提示。
是哪里出了问题?谢谢~
作者: librae8226    时间: 2009-12-7 18:39
对了,再补充一点,我在其他文件里同样写了别的函数,像模块初始化这些,调用的时候都没问题,可是一调用这个SendImage()就出问题……
作者: chenrunshe_007    时间: 2009-12-8 13:56
回复 4# librae8226
大哥,你没有把void SendImage(void)这个函数的头文件装载到Main.c中不出错才怪
两个方法:
1.把你的ImageProcess.c改为ImageProcess.h,然后在Main.c开始那里加上 #include "ImageProcess.h",要注意的是ImageProcess.h文件一定要和Main.c保存在同一个文件夹(貌似在工程的窗口那里有include文件夹,你把ImageProcess.h拉进去就行了,没有就算了,我也记得不是很清楚)。
2.如果你不想把ImageProcess.c改成ImageProcess.h也行,但是要新建一个ImageProcess.h,并在里面写好跟ImgaeProcess.c对应的接口函数(faint!久不看我也忘记接口函数怎么写了,你可以参考一下论坛里的龙丘的例程或者whut_wj的三种测速的程序,我记得上面写有),然后也是同样在在Main.c开始那里加上 #include "ImageProcess.h"。

我之前遇到的情况就是这样解决的,不知道放在你那里得不得,你试试,不得再说
作者: whut_wj    时间: 2009-12-8 19:08
改为内联函数。
作者: librae8226    时间: 2009-12-8 19:30
噢,谢谢,我再研究研究~




欢迎光临 智能车制作 (http://111.231.132.190/) Powered by Discuz! X3.2