Home

Mod5282 Interrupts Application Note

image

Contents

1. OSSemPost amp IrqPostSem extern C void UserMain void pd void putdisp unsigned short w Helper function to display a decimal number void PutDispDecimal WORD val BOOL blank_zero WORD w W val 1000 0x1000 if w 0 amp amp blank_zero w 0xF000 w val 100 10 0x0100 if w 0xF000 w OxFFOO w val 10 10 0x0010 if w OxFFOO w OxFFFO w t val 10 020001 putdisp w void UserMain void pd InitializeStack if Ethernet IP 0 GetDHCPAddress OSChangePrio MAIN_PRIO EnableAutoUpdate DWORD isr_count 0 Count how many times the switch was hit Initialize the semaphore we are using OSSemInit amp IrqPostSem 0 First set up the Eport module to use IRQ1 as a falling edge active IRQ pin See the 5282 UM chapter 11 Set the pin assignment register irgl pin falling edge sensitive sim eport eppar 0x0008 00 00 00 00 00 00 10 00 see table 11 13 in UM sim eport epddr 0x0 All edge port pins as inputs sim eport epier 0x0002 Enable IRQ1 only 00000010 Now enable the actual interrupt controller See users manual chapter 10 for more information We are going to use the BSP helper function declared above and implemented in BSP c SetIntc 0 The first interrupt controller long Sout_irgl_pin_isr Our interrupt function 1 The vector number from the
2. your system architecture and determine which interrupt level 1 7 is appropriate Level 1 is the lowest priority level 7 is the highest Use caution with level 7 since it is unique in that it is a non maskable interrupt If you use level 7 the ISR cannot call any uCOS functions or use the INTERRUPT macro e Write an Interrupt Service Routine ISR If you are using IRQ1 6 use the INTERRUPT macro to make coding the ISR easier If you are using the level 7 unmaskable IRQ then you must write the program code to save and restore the CPU registers e Call the SetIntc function to set up the interrupt vector level and priority The function should be called prior to any interrupts occurring 2 1 Hardware Configuration The IRQ pins for external interrupts on the 5282 run through a hardware module called the Edge Port Module The Edge Port Module allows you to configure the IRQ1 7 pins as inputs outputs and interrupt generators They can be configured to be edge or level sensitive See chapter 12 of the 5282 User s Manual for a discussion of these functions It is very important to perform the specific action required by the hardware module to clear the interrupt The IRQ button on the NetBurner Module Development Board is attached to the IRQ1 pin The example interrupt program at the end of this document configures IRQ1 as an interrupt source and enables you to generate an interrupt by pressing the button 2 2 Interrupt Controlle
3. Mirna Mod5282 Interrupts Application Note Revision 1 1 July 15 2004 Document Status Released Table of Contents Table Of Contents ali bd li IN A a E e e dal e ln 22 a AA cietcttigen curate ce abe sere ds Oatuen tape a T E a e E 2 1 HardWare Cont otra A AA pants aos 2 2 Mterr pt Controllers A bens Aa ea eas 2 3 Th TNE RRP LO MAROON AA A A ea n dci ZA Example ota SR e e nn So Example PEA AS 1 Introduction The 5282 has a very flexible interrupt system It is somewhat different than the traditional M68K or 5206 ColdFire interrupt system On first inspection it is somewhat confusing as the interrupt documentation is split into multiple chapters of the 5282 User s Manual and it is not easy to identify what is going on This application note will attempt to clear up some of this confusion 2 General Procedure To configure an interrupt on the 5282 you must really configure it twice The first part of the configuration configures the hardware module that causes the interrupt Timers serial I O external pins CAN Ethernet etc The documentation for this part of the process is defined in the ColdFire 5282 User s Manual and is specific to the processor peripheral you will use in your application The second part of the configuration involves setting up the interrupt controller for that specific interrupt source In general the following procedure is used to enable interrupt handling in an application e Review
4. d restore the CPU registers and s section written in C C that does the actual work The extern directive is only needed if you are creating this code in a cpp file it prevents name mangling If you are crating a c file do not include the extern section extern Cc void NMI_C_Part The part of the ISR written in C C void NMI_ASM Part The part of the ISR written in Assembly The Function_Holder is just a place holder so we can create some inline assembly language code It will never be called Note that in the __asm__ statements you need a leading space between the and the instruction However a space is not used for labels void Function_Holder _asm__ global NMI_ASM Part export the label for ASM part _asm_ extern NMI_C_ Part label for the C part of the ISR _asm__ NMI_ASM_Part label for the assembly part of the ISR _asm_ move w 0x2700 sr set the IRQ mask to mask all _asm_ lea 60 a7 a7 make space on the system stack _asm_ movem l d0 d7 a0 a6 a7 save all registers _asm__ jsr NMI_C_Part _asm_ movem 1 a7 d0 d7 a0 a6 _asm__ lea 60 a7 a7 _asm__ rte This is the C C part of the ISR that is called from the assembly code void NMI_C_Part Your C C application code goes here In the SetIntc call use
5. e same level With this type of interrupt controller structure your application can have multiple interrupt sources at the same level For example on the Mod5282 IRQ 3 is used for the UARTs and IRQS is used for the uCOS timer You may also use external interrupts IRQ3 and IRQS and they will not conflict with the timer and serial ports because each has their own ISR vectors If you have two or more interrupt sources at the same level eg IRQ5 the IRQ that occurs first will be processed first If two IRQ sources at the same level occur simultaneously priority is determined as follows e The source with the highest priority level as specified in the interrupt control register Note that this is a different setting than the interrupt level which is 1 7 e If priority levels are identical then the source with the lowest vector number get processed first 2 3 The INTERRUPT MACRO When you create an Interrupt Service Routine ISR the ISR must save the state of processor registers upon entry to the ISR and restore them before exiting In addition interrupts 1 6 interface with the uCOS operating system The INTERRUPT macro is provided to handle these all these issues Note that a level 7 unmaskable interrupt cannot call any uCOS functions and therefore cannot use the INTERRUPT macro 2 4 Example of a Level 7 ISR The following example of a level 7 NMI ISR consists of two parts a section written in assembly language to save an
6. rs All interrupts in the 5282 go through the interrupt controllers described in chapter 10 Each of the two interrupt controllers support 64 different interrupt sources The first interrupt controller numbered 0 supports the vast majority of the CPU functionality The second interrupt controller is used exclusively for the CAN system The Interrupt controller is organized around vectors and the first step in using the interrupt controller is to identify the vector associated with the peripheral generating the interrupt request This is shown in chapter 10 table 10 13 in section 10 3 6 1 of the 5282 users manual Once you have identified the vector you need to set up the vector destination and priority In NetBurner 5282 based devices we have provided a helper function to do this extern C This function sets up the 5282 interrupt controller void SetIntc int intc long func int vector int level int prio Parameter Type Usage intc int The number of the interrupt controller to use normally 0 for anything but CAN func long The address of the ISR function long vector The vector number to use This depends on which processor peripheral you use per table 10 13 of the 5282 User s Manual int level The interrupt level to assign this function 1 7 7 being non maskable int prio The priority to assign this function Priority is used to differentiate between multiple interrupts requesting at th
7. the name NMI_ASM Part to set the function address for the vector parameter 3 Example Program The following example program will configure IRQ1 to operate with the IRQ pushbutton on the Mod5282 development board Each time the button is pressed an interrupt will be counted include predef h include lt stdio h gt include lt ctype h gt include lt startnet h gt include lt autoupdate h gt include lt dhcpclient h gt include lt mod5282 system sim5282 h gt include lt cfinter h gt An interrupt setup helper defined in bsp c extern C This function sets up the 5282 interrupt controller void SetIntc int intc long func int vector int level int prio OS_SEM IrqPostSem We are going to use a Semaphore to communicate between the IRQ1 pin ISR and the main application Declare our interrupt procedure name our_irgl_pin_isr masking level The value of the ColdFire SR during the interrupt use 0x2700 to mask all interrupts 0x2500 to mask levels 1 5 etc 0x2100 to mask level 1 INTERRUPT out_irgl_pin_isr 0x2100 WARNING WARNING WARNING Only a very limited set of RTOS functions can be called from within an interrupt service routine Basically only OS POST functions and LED functions should be used No I O read write or printf may be called since they can block sim eport epfr 0x02 Clear the interrupt edge 00000010
8. users manual table 10 13 1 Set this to priority 1 but any value from 1 to 6 would be valid 1 The priority within the gross levels see chapter 10 any value from 0 to 7 is ok i iprintf Application started n iprintf Press the IRQ button on the development board n while 1 OSSemPend amp IrqPostSem 0 Wait forever PutDispDecimal isr_count true iprintf The interrupt Switch was hit ld times r n isr_count

Download Pdf Manuals

image

Related Search

Related Contents

IMPORTANT: Read and understand this manual before assembling  Super Talent Technology 32GB USB 2.0  LG L1920P User's Manual  Toshiba Satellite S70t-B00E  Philips AJ3121  Pritchatts House (PDF-1MB)  SA-W3000 - ソニー製品情報  Unidad Condensadora Bomba de Calor  Acer X152H  - Freescale Semiconductor  

Copyright © All rights reserved.
Failed to retrieve file