贴出IAR下的简化测试程序,有经验的朋友帮忙看下,编译器按理说不应该有这样的问题啊
#include "iostm8s103f3.h"
#define uchar unsigned char
#define uint unsigned int
#define beep PD_ODR_ODR6
#define led PD_ODR_ODR5
#define RF PA_IDR_IDR3
void delay_1ms(uint x) //1毫秒延时
{
uchar b,c;
for(;x>0;x--)
{
for(b=5;b>0;b--);
{
for(c=150;c>0;c--);
}
}
}
void delay_us(uint x)
{
for(;x>0;x--)
{
x++;x--;
}
}
void MJ(uint dey)
{
for(;dey>0;dey--)
{
beep=!beep;
delay_us(200);
}
}
void BB(uint size,uchar Number)
{
TIM2_IER_UIE=0;
TIM4_IER_UIE=0;
for(;Number>0;Number--)
{
led=!led;
MJ(size);
led=!led;
delay_1ms(size);
}
led=1;
TIM2_IER_UIE=1;
}
#pragma vector=0x05 //PA
__interrupt void ext_A3(void) //RF外部中断
{
;
}
void Init_GPIO(void) //IO初始化
{
PA_DDR=0xF7;
PA_CR1=0x00;
PA_CR2=0x00; //PA3中断,休眠前开启
PD_DDR=0xff;//ef
PD_CR1=0x60;
PD_CR2=0x00;
PD_ODR=0X20;
CLK_CKDIVR=0X02; //CPU 4分频
}
void system_start() //上电初始化
{
Init_GPIO();
EXTI_CR1=0XC1; //PD上升沿和下降沿触发,PA仅上升沿触发
PA_CR2=0x08; //开启PA3上升沿中断
asm("rim");//开全局中断
}
void main()
{
system_start();
BB(200,6);
while(1)
{
led=!led;
asm("HALT");
}
} |