Interrupts in ARM LPC2148
Interrupts in ARM LPC2148
Interrupts in ARM LPC2148
*/
*/
/*
/*
/*
*/
*/
*/
*/
*/
*/
*/
*/
/****************************************************/
// Print Message to UART1 (9600,N,8,1)
// Used GPIO0.14 Trigger Interrupt (FIQ Vector)
// Press SW-LOAD For Trigger External Interrup-1
#include "LPC214x.H"
#include <stdio.h>
// For Used Function printf
/* pototype section */
void init_serial0 (void);
// Initil UART-0
int main(void)
{
init_serial0();
9600,N,8,1
// Initilial UART0 =
|= 0x20000000;
= 0x00000002;
// Clear External
// Select Interrupt-15
VICIntEnable
= 0x00008000;
(External Interrupt1)
// Enable Interrupt-15
// Call Printf
// Call Printf Function
// Call Printf
/******************************/
/* Initial UART0 = 9600,N,8,1 */
/* VPB(pclk) = 60.00 MHz
*/
/******************************/
void init_serial0 (void)
{
PINSEL0 &= 0xFFFFFFF0;
// Reset P0.0,P0.1 Pin Config
PINSEL0 |= 0x00000001;
// Select P0.0 = TxD(UART0)
PINSEL0 |= 0x00000004;
// Select P0.1 = RxD(UART0)
//
U0DLM = 0x01;
// Program Divisor Latch(391) for 9600 Baud
U0DLL = 0x87;
U0FCR |= 0x01;
// FIF0 Enable
U0FCR |= 0x02;
// RX FIFO Reset
U0FCR |= 0x04;
// TX FIFO Reset
U0FCR &= 0x3F;
}
/****************************/
/* Write Character To UART0 */
/****************************/
int putchar (int ch)
{
if (ch == '\n')
{
while (!(U0LSR & 0x20));
TXD Buffer Empty
U0THR = 0x0D;
// Wait
// Write CR
}
while (!(U0LSR & 0x20));
// Wait
/*****************************/
/* Read Character From UART0 */
/*****************************/
int getchar (void)
{
while (!(U0LSR & 0x01));
RXD Receive Data Ready
// Wait
return (U0RBR);
// Get Receice Data & Return
}
/********************************/
/* External Interrupt-1 Service */
/********************************/
void FIQ_Handler (void)
__fiq
{
printf("Hello From......External Interrupt-1\n");
Function
EXTINT = 0x00000002;
// Clear External Interrupt1 Flag
}
// Call Printf