سلام به همگی
من پورت یرسال راه اندازی کردم، وقتی وقفه اتفاق میافته و برنامه های تحت وقفه اجرا میشه دیگه از وقفه خارج نمیشه و به Main برنمیگرده که مابقی برنامه اجرا بشه
لطفا راهنمایی کنید که کجای کار اشکال داره
کد:
#include <lpc17xx.h>
#include <stdio.h>
#include "lpc17xx_pinsel.h"
#include "lpc17xx_gpio.h"
#include "lpc17xx_uart.h"
#include "lpc17xx_pwm.h"
#include "lpc17xx_clkpwr.h"
#include "debug_frmwrk.h"
int u0 = 0;
uint8_t input0;
void Delay (uint32_t Time)
{
uint32_t i;
i = 0;
while (Time--) {
for (i = 0; i < 5000; i++);
}
}
void UART2_IRQHandler(void)
{
input0 = UART_ReceiveByte(LPC_UART2);
GPIO_SetValue(2,0x00001000);
Delay (2000);
GPIO_ClearValue( 2,0x00018000 );
u0=1;
}
int main(void)
{
unsigned char u0;
PINSEL_CFG_Type PinCfg2;
//*********************************************************UART2 Configuration structure variable
UART_CFG_Type UARTConfigStruct2;
//*********************************************************UART2 FIFO configuration Structure variable
UART_FIFO_CFG_Type UARTFIFOConfigStruct2;
//*********************************************************Initialize UART2 Pin Connect : P0.10 , P0.11 ( pins 48 & 49 Of Micro )
PinCfg2.Funcnum = 1;
PinCfg2.OpenDrain = 0;
PinCfg2.Pinmode = 0;
PinCfg2.Pinnum = 10;
PinCfg2.Portnum = 0;
PINSEL_ConfigPin(&PinCfg2);
PinCfg2.Pinnum = 11;
PINSEL_ConfigPin(&PinCfg2);
UARTConfigStruct2.Baud_rate = 38400;
UARTConfigStruct2.Databits = UART_DATABIT_8;
UARTConfigStruct2.Parity = UART_PARITY_NONE;
UARTConfigStruct2.Stopbits = UART_STOPBIT_1;
CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCUART2, ENABLE);
//*********************************************************Initialize UART2 peripheral with given to corresponding parameter
UART_Init(LPC_UART2,&UARTConfigStruct2);
UART_FIFOConfigStructInit(&UARTFIFOConfigStruct2);
//*********************************************************Initialize FIFO for UART2 peripheral
UART_FIFOConfig(LPC_UART2, &UARTFIFOConfigStruct2);
UART_IntConfig(LPC_UART2, UART_INTCFG_RBR, ENABLE);
//*********************************************************Enable Interrupt for UART2 channel
NVIC_EnableIRQ(UART2_IRQn);
//*********************************************************Enable UART2 Transmit
UART_TxCmd(LPC_UART2, ENABLE);
//*********************************************************
GPIO_SetDir(2 ,0x00001800 ,1 );
UARTPuts_(LPC_UART2, "In the name of God");
while (UART_CheckBusy(LPC_UART2));
UARTPuts_(LPC_UART2, "Enter a char:");
while (1)
{
if (u0==1)
{
GPIO_SetValue( 2,0x00000800 );
Delay (5000);
FIO_ClearValue( 2,0x00018000 );
u0 = 0;
}
}
}