微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > LM3S9B96 中断映射表的配置

LM3S9B96 中断映射表的配置

时间:11-11 来源:互联网 点击:

muxing for UART0 functions on port A0 and A1.
// This step is not necessary if your part does not support pin muxing.
GPIOPinConfigure(GPIO_PD0_U2RX);
GPIOPinConfigure(GPIO_PD1_U2TX);

// Initialize the UART for console I/O.
UARTStdioInit(2);

UARTprintf("Uart2 is ready ->\n");
}

//*****************************************************************************
//
// 主函数
//
//*****************************************************************************
int main(void)
{
// Set the clocking to run directly from the crystal.
SysCtlClockSet(SYSCTL_SYSdiv_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

LED_Init(); // 初始化LED,输出

InitConsole(); // UART2初始化

GPIO_PJ7_Init(); // 初始化PJ7管脚,输入

IntMasterEnable(); // 开总中断

GPIOPinWrite(LED_PORT, LED_PIN, LED_OFF);
Delay(0xFFFFF);
GPIOPinWrite(LED_PORT, LED_PIN, LED_ON);
Delay(0xFFFFF);
GPIOPinWrite(LED_PORT, LED_PIN, LED_OFF);
Delay(0xFFFFF);
GPIOPinWrite(LED_PORT, LED_PIN, LED_ON);
Delay(0xFFFFF);
GPIOPinWrite(LED_PORT, LED_PIN, LED_OFF);
Delay(0xFFFFF);
GPIOPinWrite(LED_PORT, LED_PIN, LED_ON);
Delay(0xFFFFF);

while (1)
{
Delay(0xFFFFF); // 646ms
}
}

//*****************************************************************************
//
// PJ7管脚的中断服务函数,双沿触发
//
//*****************************************************************************
void GPIO_Port_J_ISR(void)
{
// 读取中断状态,GPIOJ端口的8个管脚都可能触发中断
DWORD Status = GPIOPinIntStatus(GPIO_PORTJ_BASE, true);

// 清除中断状态,重要
GPIOPinIntClear(GPIO_PORTJ_BASE, Status);

if ((Status & GPIO_PIN_7) != 0)
{
// 上升沿中断处理函数
if (0x00000080 == GPIOPinRead(GPIO_PORTJ_BASE, GPIO_PIN_7))
{
UARTprintf("PJ7 is low to high ->\n");
Delay(0xFFFFF);
}
else if (0 == GPIOPinRead(GPIO_PORTJ_BASE, GPIO_PIN_7)) // 下降沿中断处理函数
{
UARTprintf("PJ7 is high to low ->\n");
Delay(0xFFFFF);
}
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top