diandian 发表于 2011-3-12 21:34:23

紧急求助!IAR C FOR SAM8程序优化出错

紧急求助!IAR C FOR SAM8程序优化出错
    不知什么原因,用IAR V2.21A(用V2.30A也是一样) 编写的小程序具体如下,单片机S3F9444,选择不同的优化(size优化),结果差非常大,优其是HIGH级优化,可以说已经变成完全不同程序了,是不是哪里设置错误?望路过的大位侠赐教,谢谢!

//**********************************************************************
//#include <stdio.h>
#include "ioS3C9444.h"
#include "intrinsics.h"

//**********************************************************************

//**********************************************************************

void __no_operation(void);
void buz(unsigned int b_time);


/********************************************************************

       smart option
      
       003C=00H;
       003D=00H;
       003E=11001000(0xC8) LVR enable 3.0V
       003F=00000011B;   internal RC oscillator3.2MHZ
      
      
*******************************************************************/

__code const volatile unsigned char SmartOption @0x003C=
{0x00,0x00,0xC8,0x03};


//*********************************************************************

void main(void)
{

//***填充系统SMART OPTION***/

unsigned char buffer = SmartOption;

//********************************************************************

unsigned d;

//********************************************************************
   __disable_interrupt();//SYM=0x00;//stop all interrupt
//BTCON=0x03;// watch_dog enable   00000011B
BTCON=0xA0;// watch_dog disable   1010000B
CLKCON=0x98;//no divided CPU clock10011000B
SP=0x20;//initialize stact pointer
P0CONL|=0x28;//00101001B P0.2,P0.1 as push-pull output,P0.0 as input
            //P0.2 as buz signal,P0.1 as SW signal, P0.0 as RC signal reciver
P0PND=0x00; //00000010B INT0 ,INT1 disable
P1CON=0x0A; //00001010B P1 as output,but P1.2 can only as input******
P1=0; //P1.1 ,P1.0 as 0,P1.2 can only as input***
P0=0; //P0.2 ,P0.1 as 0

//*******************************************************************

d=0;

//*******************************************************************

next0:

for(d=0;d<3000;d++)

   {
      ;
   }
buz(2000);
for(d=0;d<9000;d++)

   {
      ;

   }

goto next0;

}



//*******************************************************************



void buz(unsigned b_time)
      {
         unsigned int b;
         b=0;
    loop:
         P0|=0x04; //P0.2 as 1
         for(b=0;b<14;b++)
            {
             __no_operation();

            }
         if(b_time>0)
         {
             __no_operation();
         }
         P0&=0xFB; //P0.2 as 0
         for(b=0;b<14;b++);
            {
             __no_operation();

            }
         if(b_time>1)
         {
            b_time--;
            goto loop;
         }

      }
页: [1]
查看完整版本: 紧急求助!IAR C FOR SAM8程序优化出错