Weight_Bed/EX_Init.c

80 lines
1.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "H/Function_Init.H"
void EX_Init(void);
uchar INT1_flag = 0x00;
/*****************************************************
*函数名称void EXTI_Test(void)
*函数功能:外部中断测试
*入口参数void
*出口参数void
*****************************************************/
void EXTI_Test(void)
{
EX_Init();
while(1)
{
}
}
/*****************************************************
*函数名称void EX_Init(void)
*函数功能:外部中断初始化
*入口参数void
*出口参数void
*****************************************************/
void EX_Init(void)
{
//配置中断口INT07、INT11/10、INT20/21
P0CON &= 0X7F; //中断IO口设置为高阻输入
P0PH |= 0x80; //中断IO口设置为高阻带上拉
P4CON &= 0XFC; //中断IO口设置为高阻输入
P4PH |= 0x03; //中断IO口设置为高阻带上拉
P2CON &= 0XFC; //中断IO口设置为高阻输入
P2PH |= 0x03; //中断IO口设置为高阻带上拉
//配置INT07上升沿中断、INT11/10下降沿中断、INT20/21双沿中断
//下降沿设置
INT0F = 0X00 ; //0关闭 1使能
INT1F = 0X03 ; //0关闭 1使能
INT2F = 0X03 ; //0关闭 1使能
//上升沿设置
INT0R = 0X80 ; //0关闭 1使能
INT1R = 0X00 ; //0关闭 1使能
INT2R = 0X03 ; //0关闭 1使能
//外部中断优先级设置
IE |= 0x05; //外部中断01中断使能
IE1 |= 0x08; //外部中断2中断使能
IP |= 0X00; //配置中断优先级
IP1 |= 0X00;
EA = 1;
}
/*****************************************************
*函数名称void EX0/1/2() interrupt 0/2/10
*函数功能:外部中断函数
*入口参数void
*出口参数void
*****************************************************/
void INT0Interrupt() interrupt 0
{
P04 = ~P04;
}
void INT1Interrupt() interrupt 2
{
P05 = ~P05;
if(P40 == 0)
{
INT1_flag = 0x10; //INT10产生中断
}
if(P41 == 0)
{
INT1_flag = 0x20; //INT11产生中断
}
}
void INT2Interrupt() interrupt 10
{
P06 = ~P06;
}