iar for stm8外部中断程序
写了一个程序却怎么进不了中断谁知道问题出在哪里?附程序#include"iostm8s003f3.h"#defineucharunsignedchar#defineuin...
写了一个程序却怎么进不了中断谁知道问题出在哪里?附程序
#include "iostm8s003f3.h"
#define uchar unsigned char
#define uint unsigned int
#define M_OPEN PC_ODR_ODR4=1
#define M_OFF PC_ODR_ODR4=0
#define F_OPEN PC_ODR_ODR3=1
#define F_OFF PC_ODR_ODR3=0
#define LED_OPEN PD_ODR_ODR4=0
#define LED_OFF PD_ODR_ODR4=1
void GPIO_Nint()
{
PD_DDR|=(1<<4) ;
PD_CR1|=(1<<4);
PD_CR2&=0XEF;
PC_DDR|=(1<<3)|(1<<4);
PC_CR1|=(1<<3)|(1<<4);
PC_CR2&=0XE7;
//PA_DDR&=0XF7;
//PA_CR1&=(1<<3);
//PA_CR2&=0XF7;
PB_DDR&=0XDF;
PB_CR1&=(1<<5);
PB_CR2&=0XDF;
M_OFF;
F_OFF;
LED_OFF;
}
void delay(uint ms)
{
uint b;
uint a;
for(a=ms;a>0;a--)
{
for(b=60;b>0;b--);
}
}
void work()
{
M_OPEN ;
F_OPEN ;
LED_OPEN;
}
void half()
{
M_OFF ;
F_OFF ;
LED_OFF ;
}
void EXTI_init(void)
{
EXTI_CR1=0x04;
}
void main()
{
asm("sim");
EXTI_init();
GPIO_Nint();
asm("rim");
while(1)
{
work();
}
}
#pragma vector=0x06
__interrupt void EXTI_PB5_()
{
while(1)
{
half();
}
} 展开
#include "iostm8s003f3.h"
#define uchar unsigned char
#define uint unsigned int
#define M_OPEN PC_ODR_ODR4=1
#define M_OFF PC_ODR_ODR4=0
#define F_OPEN PC_ODR_ODR3=1
#define F_OFF PC_ODR_ODR3=0
#define LED_OPEN PD_ODR_ODR4=0
#define LED_OFF PD_ODR_ODR4=1
void GPIO_Nint()
{
PD_DDR|=(1<<4) ;
PD_CR1|=(1<<4);
PD_CR2&=0XEF;
PC_DDR|=(1<<3)|(1<<4);
PC_CR1|=(1<<3)|(1<<4);
PC_CR2&=0XE7;
//PA_DDR&=0XF7;
//PA_CR1&=(1<<3);
//PA_CR2&=0XF7;
PB_DDR&=0XDF;
PB_CR1&=(1<<5);
PB_CR2&=0XDF;
M_OFF;
F_OFF;
LED_OFF;
}
void delay(uint ms)
{
uint b;
uint a;
for(a=ms;a>0;a--)
{
for(b=60;b>0;b--);
}
}
void work()
{
M_OPEN ;
F_OPEN ;
LED_OPEN;
}
void half()
{
M_OFF ;
F_OFF ;
LED_OFF ;
}
void EXTI_init(void)
{
EXTI_CR1=0x04;
}
void main()
{
asm("sim");
EXTI_init();
GPIO_Nint();
asm("rim");
while(1)
{
work();
}
}
#pragma vector=0x06
__interrupt void EXTI_PB5_()
{
while(1)
{
half();
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询