Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Explain to me ARM interrupt code

Status
Not open for further replies.

hbaocr

Full Member level 4
Joined
May 13, 2007
Messages
232
Helped
25
Reputation
48
Reaction score
4
Trophy points
1,298
Location
Hochiminh City university of technology (VietNam)
Activity points
2,765
arm interrupt code

hello , all friend
Plz , explain this code below , I don't know how it work. If more than two FIQ request , how can it work, and how can CPU core recognize which interrupt source is responding.
look on my code at row painted red color ,
can me declare more than two row like this
ex:
void FIQ_Handler (void) __fiq;
void ADC_handler(void)__fiq;

And If I can do it,how can CPU recognize which FIQ Interrupt routine respond for which interrupt source when it is responded


Code:
/****************************************************/
/* Examples Program For "CP-JR ARM7 USB-LPC2148"    */
/* Target MCU  : Philips ARM7-LPC2148               */
/*       	   : X-TAL : 12.00 MHz                  */
/*             : Run Speed 60.00 MHz (With PLL)     */
/*             : PLL Setup = M(5),P(2)				*/
/*             : VPB Clock = CPU Clock = 60.00 MHz	*/
/* Keil Editor : uVision3 V3.03a                    */
/* Compiler    : Keil CARM V2.50a		            */
/* Create By   : Eakachai Makarn ([url]WWW.ETT.CO.TH[/url])    */
/* Last Update : 17/May/2006                        */
/* Function    : Example Use UART1 Show FIQ(EINT1)  */
/****************************************************/
// 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" 	                                	// LPC2148 MPU Register
#include <stdio.h>											// For Used Function printf 

/* pototype  section */
void init_serial0 (void); 									// Initil UART-0
int putchar (int ch);  										// Put Char to UART-0
int getchar (void);  										// Get Char From Uart-0
[color=red]void FIQ_Handler (void) __fiq;	[/color]   							// EINT1(FIQ) Interrupt Service 

int main(void)
{  
  init_serial0();		   									// Initilial UART0 = 9600,N,8,1
  
  // Initial External Interrupt-1(GPIO0.14)
  EXTMODE      |= 0x02;										// Select External Interrupt-1 = Edge Select Trigger
  EXTPOLAR     |= 0x02;										// Select External Interrupt-1 = Rising Edge Trigger
  PINSEL0 	   |= 0x20000000;								// Set GPIO0.14 = EXTINT1 Interrupt
  EXTINT 		= 0x00000002;								// Clear External Interrupt1 Flag

  // Initial Interrupt Vector
  VICIntSelect 	= 0x00008000;								// Select Interrupt-15 (External Interrupt1)
  VICIntEnable	= 0x00008000;								// Enable Interrupt-15 (External Interrupt1)
    
  printf("CP-JRARM7 USB-LPC2148...Example FIQ Interrupt\n");// Call Printf Function
  printf("Interrupt-1 Rising Edge Trig By GPIO0.14\n");		// Call Printf Function
  printf("Press Switch-LOAD For Trigger Interrupt-1\n\n");	// Call Printf Function
  printf("Hello From......Main Function\n");				// Call Printf Function

  // Loop Here Wait Interrupt
  while(1);													
}

/******************************/
/* 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)

  U0LCR &= 0xFC;											// Reset Word Select(1:0)
  U0LCR |= 0x03;											// Data Bit = 8 Bit
  U0LCR &= 0xFB;											// Stop Bit = 1 Bit
  U0LCR &= 0xF7;											// Parity = Disable
  U0LCR &= 0xBF;											// Disable Break Control
  U0LCR |= 0x80;											// Enable Programming of Divisor Latches

  // U0DLM:U0DLL = 60.00 MHz / [16 x Baud]
  //             = 60.00 MHz / [16 x 9600]
  //             = 390.6 = 391 = 0187H
  U0DLM = 0x01;												// Program Divisor Latch(391) for 9600 Baud
  U0DLL = 0x87;

  U0LCR &= 0x7F;											// Disable Programming of Divisor Latches

  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));  								// Wait TXD Buffer Empty
    U0THR = 0x0D;                          					// Write CR
  }
  while (!(U0LSR & 0x20));									// Wait TXD Buffer Empty
  return (U0THR = ch);										// Write Character
}

/*****************************/
/* Read Character From UART0 */
/*****************************/
int getchar (void)  
{                    
  while (!(U0LSR & 0x01));									// Wait RXD Receive Data Ready
  return (U0RBR);											// Get Receice Data & Return
}



/********************************/
/* External Interrupt-1 Service */
/********************************/
void FIQ_Handler (void)	__fiq
{
  printf("Hello From......External Interrupt-1\n");			// Call Printf Function
  EXTINT = 0x00000002;										// Clear External Interrupt1 Flag
}
 

arm interrupt vectors

It can't!

You can only have one FIQ_Handler, if you have more than one fast interrupt then your FIQ_Handler need to check what interrupt was triggered.
 

__fiq

hey,Encrypted
thank for your helping
can you tell me more detail about it
it can be construction below or not???

Code:
#include "header.h"

void FIQ_handle(void)__fiq; 
//interrupt routine for FIQ respond

void main()
{
program
}


void FIQ_handle(void)__fiq
{
check FIQ status register(VICFIQstatus) to see which interrupt request sources are coresponding and program for each coresponded interrupt request
example
select case VICFIQstatus
case <INT1>
{
interrupt service routine for FIQ interrupt INT1
break;
}
case <INT 2>
{
interrupt service routine for FIQ interrupt INT2
break;
}
....

}
 

arm interrupt

Yes, if you must use fast interrupts.

It would be easier to use Vectored IRQs and let the interrupt controller take care of things.

PS: Read '5.7 VIC usage notes' in the user manual, it recommendeds that only one
interrupt source should be classified as FIQ.
 

fiq handling in lpc2148 sample code

thank Encrypted a lot
is it similiar to IRQ and non_IRQ interrupt request. That we can only declare one interrupt service routine , and check to see which interrupt source are coresponding by checking IRQ status. and do the same contruction above.
 

arm interrupt vector

No, you have different handlers for different interrupts and you assign them priorities.

Take a look at the Hitex book 'The Insider's Guide To The NXP ARM7-Based Microcontrollers', you can download it for free. It has everything you want to know.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top