求助,CCS4.1,C代码o3优化问题
时间:10-02
整理:3721RD
点击:
串口初始化,连续对寄存器赋值,不开优化没问题,开o3优化,前面的赋值都给优化没了。下面是程序
void McBsp1_init( void ) //SPI MODE{
int16_t i;
SPSA1=SPCR1;
SPSD1=0; /*reset rev */
SPSA1=SPCR2; /*reset xtm*/
SPSD1=0;
SPSA1=SPCR1;
SPSD1=0x1800; //CLKSTP=11,SPI MODE
SPSA1=RCR1;
SPSD1=0x40; //RFRLEN1=0000000,RWDLEN1=010
SPSA1=XCR1;
SPSD1=0x40; //RFRLEN1=0000000,RWDLEN1=010
SPSA1=SRGR2;
SPSD1=0x2000; //CLKSM=1,FSGM=0
SPSA1=SRGR1;
SPSD1=0xff; //CLKGDV=0xff
SPSA1=XCR2;
SPSD1=0x0; ////XDATDLY=00,XPHASE=0
SPSA1=RCR2;
SPSD1=0x0; ////XDATDLY=00,XPHASE=0
SPSA1=PCR;
SPSD1=0xA08;//a0a //FSXM=1,CLKXM=1,FSXP=1,CLKXP=0
SPSA1=SPCR2;
SPSD1=SPSD1|0x40;
for(i=0;i<10;i++);
SPSA1=SPCR1;
SPSD1=SPSD1|0x1; /*reset rev */
SPSA1=SPCR2; /*reset xtm*/
SPSD1=SPSD1|0x1;
for(i=0;i<10;i++);
}
优化后单步执行,发现前面好多赋值都没执行!
有没有什么办法让DSP不优化这段代码啊?
void McBsp1_init( void ) //SPI MODE{
int16_t i;
SPSA1=SPCR1;
SPSD1=0; /*reset rev */
SPSA1=SPCR2; /*reset xtm*/
SPSD1=0;
SPSA1=SPCR1;
SPSD1=0x1800; //CLKSTP=11,SPI MODE
SPSA1=RCR1;
SPSD1=0x40; //RFRLEN1=0000000,RWDLEN1=010
SPSA1=XCR1;
SPSD1=0x40; //RFRLEN1=0000000,RWDLEN1=010
SPSA1=SRGR2;
SPSD1=0x2000; //CLKSM=1,FSGM=0
SPSA1=SRGR1;
SPSD1=0xff; //CLKGDV=0xff
SPSA1=XCR2;
SPSD1=0x0; ////XDATDLY=00,XPHASE=0
SPSA1=RCR2;
SPSD1=0x0; ////XDATDLY=00,XPHASE=0
SPSA1=PCR;
SPSD1=0xA08;//a0a //FSXM=1,CLKXM=1,FSXP=1,CLKXP=0
SPSA1=SPCR2;
SPSD1=SPSD1|0x40;
for(i=0;i<10;i++);
SPSA1=SPCR1;
SPSD1=SPSD1|0x1; /*reset rev */
SPSA1=SPCR2; /*reset xtm*/
SPSD1=SPSD1|0x1;
for(i=0;i<10;i++);
}
优化后单步执行,发现前面好多赋值都没执行!
有没有什么办法让DSP不优化这段代码啊?
开o3优化后,编译器就会把代码的次序打乱了,单步的时候就会出现意料之外的结果