rtd ECAN1000HR Скачать руководство пользователя страница 22

ECAN1000 User’s Manual  

 

 

22  

 

 

BDM-610020026 rev B 

 

Using Interrupts in your program

 

 

Adding interrupt support to your program is not as difficult as it may seem 
especially  when  programming  under  DOS.  The  following  discussion  will 
cover  programming  under  DOS.  Note  that  even  the  smallest  mistake  in 
your interrupt program may cause the computer to hang up and will only 
restart after a reboot. This can be frustrating and time-consuming.

  

 

 

Writing an Interrupt Service Routine (ISR)

 

 

The first step in adding interrupts to your software is to write an interrupt 
service  routine  (ISR).  This  is  the  routine  that  will  be  executed  automati-
cally each time an interrupt request occurs for the specified IRQ. An ISR 
is different from other sub-routines or procedures. First, on entrance the 
processor registers must be pushed onto the stack before anything else! 
Second, just before exiting the routine, you must clear the interrupt on the 
ECAN1000HR  by  writing  to  the  SJA1000  CAN  controller,  and  write  the 
EOI  command  to  the  interrupt  controller.  Finally,  when  exiting  the  inter-
rupt  routine  the  processor  registers  must  be  popped  from  the  system 
stack and you must execute the IRET assembly instruction. This instruc-
tion  pops  the  CS,  IP  and  processor  flags  from  the  system  stack.  These 
were pushed onto the stack when entering the ISR. 
 
Most  compilers  allow  you  to  identify  a  function  as  an  interrupt  type  and 
will  automatically  add  these  instructions  to  your  ISR  with  one  exception: 
most  compilers  do  not  automatically  add  the  EOI  command  to  the  func-
tion,  you  must  do  it  yourself.  Other  than  this  and  a  few  exceptions  dis-
cussed  below,  you  can  write  your  ISR  as  any  code  routine.  It  can  call 
other functions and procedures in your program and it can access global 
data. If you are writing your first ISR, we recommend you stick to the ba-
sics; just something that enables you to verify you have entered the ISR 
and  executed  it  successfully.  For  example:  set  a flag in your ISR and in 
your main program check for the flag. 

 

 

Note: 

If you choose to write your ISR in in-line Assembly, you must push 
and pop registers correctly and exit the routine with the IRET in-
struction instead of the RET instruction. 

 

Содержание ECAN1000HR

Страница 1: ...ECAN1000HR Isolated CAN interface board User s Manual BDM 610020026 Rev B...

Страница 2: ...ECAN1000HR ISOLATED 1 MB S CAN INTERFACE BOARD USER S MANUAL RTD Embedded Technologies INC 103 Innovation Blvd State College PA 16803 0906 Phone 1 814 234 8087 FAX 1 814 234 5218 E mail sales rtd com...

Страница 3: ...hed by RTD Embedded Technologies Inc 103 Innovation Blvd State College PA 16803 0906 Copyright 1999 2002 2003 2007 by RTD Embedded Technologies Inc All rights reserved The RTD Logo is a registered tra...

Страница 4: ...ALVANICALLY ISOLATED CAN BUS CONNECTOR 15 J34 GALVANICALLY ISOLATED CAN BUS TERMINATION JUMPER 15 CHAPTER 4 HARDWARE DESCRIPTION 16 THE CAN BUS CONTROLLER 17 GALVANIC ISOLATION OF THE CAN BUS 18 CHAPT...

Страница 5: ...N1000HR INTEGRATED IN A PC 104 RTD CPUMODULE STACK 14 FIGURE 5 19 EUROCARD RACK INSTALLATION WITH AN INTEGRATED PC 104 DATAMODULE AND 14 FIGURE 6 ECAN1000HR BLOCK DIAGRAM 16 TABLES TABLE 1 FACTORY CON...

Страница 6: ...the major features of the ECAN1000HR A more detailed discussion in included in Chapter 4 Hardware description and in Chapter 5 Board operation and program ming The board setup is described in Chapter...

Страница 7: ...N1000HR is designed on a PC 104 form factor An easy me chanical interface to both PC 104 and EUROCARD systems can be achieved Stack your ECAN1000HR directly on a PC 104 compatible computer using the o...

Страница 8: ...its functions so that you can obtain maximum use of its fea tures even in the most demanding applications This manual does not cover CAN bus network programming and system design When you need help T...

Страница 9: ...1 below illustrates the factory jumper setting for the ECAN1000HR Fig ure 1 shows the board layout of the ECAN1000HR and the locations of the jumpers The following paragraphs explain how to change the...

Страница 10: ...st setting up your module is address contention Some of your computers I O space is already occupied by other devices and memory resident programs When the ECAN1000HR at tempts to use its own reserved...

Страница 11: ...jumper is removed it corresponds to a logical 0 connecting the jumper to a 1 When you set the base address of the board record the setting inside the back cover of this manual BASE ADDRESS JUMPER SET...

Страница 12: ...utputs to one of the interrupt channels available on the host XT AT bus If your board has no AT extension interrupts IRQ 10 15 are not available Figure 3 Interrupt set to IRQ 5 Note The ECAN1000HR doe...

Страница 13: ...hardware Before installing the board in your computer check the jumper settings Chapter 2 reviews the factory settings and how to alter them If any alterations are needed please refer to the appropri...

Страница 14: ...n be easily inserted into a 19 rack installation us ing the CPU as a form factor adaptor Assemble your PC 104 data mod ules on an RTD single board EUROCARD computer and install the sys tem in a 19 enc...

Страница 15: ...9 GND isolated 10 N C Table 3 J12 CAN Bud Connector 9 7 5 3 1 I_GND N C I_GND BUS_L N C N C I_ 5V N C BUS_H I_GND 10 8 6 4 2 Table 4 Physical interface connector J12 pinout of the ECAN1000HR J34 Galva...

Страница 16: ...DM 610020026 rev B Chapter 4 HARDWARE DESCRIPTION This chapter describes in detail the major features of the ECAN1000HR The Philips SJA1000 CAN bus controller Galvanic isolation of the CAN bus Figure...

Страница 17: ...d can be configured to ei ther transmit or to receive Each message identifier contains control and status bits A message ob ject with a direction set for receive will send a remote frame by requesting...

Страница 18: ...ly to improve immunity to bus noise but also to protect the bus trans ceiver This choke also reduces the radiated emissions in the range of 30 200MHz A 1W DC DC converter may be used to power other re...

Страница 19: ...ribed in the next sections reprinted from the SJA1000 chip specific user s manual ADDRESS Description BASE 00h ADDRESS BASE 01h DATA of ADDRESS BASE 02h HARDWARE RESET OF SJA1000 Table 5 ECAN Memory M...

Страница 20: ...rds serial ports etc Your ECAN1000HR can interrupt the main processor when a message is received or transmitted if interrupts are enabled on the ECAN1000HR board By using interrupts you can write powe...

Страница 21: ...0h What exactly happens when an interrupt occurs Understanding the sequence of events when an interrupt is triggered is necessary to correctly write interrupt handlers When an interrupt request line i...

Страница 22: ...I command to the interrupt controller Finally when exiting the inter rupt routine the processor registers must be popped from the system stack and you must execute the IRET assembly instruction This i...

Страница 23: ...ting point mathematical operations in your ISR Note that the problem of reentrancy exists no matter what programming language you use Even if you are writing your ISR in Assembly lan guage DOS and man...

Страница 24: ...rray of pointers ad dresses and it is locate din the first 1024 bytes of the memory Segment 0 offset 0 You can read this value directly but it is better practice to use DOS function 35h get interrupt...

Страница 25: ...routine for set ting up interrupt vectors Remember that interrupt vector 8 corresponds to IRQ0 vector 9 for IRQ1 etc If you need to program the source of your interrupts do that next For ex ample if y...

Страница 26: ...rq_handlers Inputs Nothing Returns Nothing Purpose Set the pointers in the interrupt table to point to our funtions ie setup for ISR s void init_irq_handlers void _disable old_IRQ1_handler _dos_getvec...

Страница 27: ...parameters and speed of bus programmable Balanced CAN bus Choke Jumper selectable 120 Ohm termination resistors Transceiver type Philips 82C251 0 8W 5V isolated output power for other field devices Co...

Страница 28: ...description of the board s behavior List the name of a contact person familiar with technical details of the problem or situation along with their phone and fax numbers address and e mail address if...

Страница 29: ...d the control of RTD Embedded Technologies OR AS A RESULT OF SERVICE OR MODIFICATION BY ANYONE OTHER THAN RTD Embedded Technologies EXCEPT AS EXPRESSLY SET FORTH ABOVE NO OTHER WARRANTIES ARE EXPRESSE...

Отзывы: