![Tern CAN-Engine Скачать руководство пользователя страница 27](http://html.mh-extra.com/html/tern/can-engine/can-engine_technical-manual_1089501027.webp)
CAN-Engine
Chapter 4: Software
4-5
By default, the interrupts are all disabled after initialization. To disable them again, you can repeat the call
but pass in 0 as the first argument.
The NMI (Non-Maskable Interrupt) is special in that it can not be masked (disabled). The default ISR will
return on interrupt.
void int0_init( unsigned char i, void interrupt far(* int0_isr)() );
void int1_init( unsigned char i, void interrupt far(* int1_isr)() );
void int2_init( unsigned char i, void interrupt far(* int2_isr)() );
void int3_init( unsigned char i, void interrupt far(* int3_isr)() );
void int4_init( unsigned char i, void interrupt far(* int4_isr)() );
void int5_init( unsigned char i, void interrupt far(* int5_isr)() );
void int6_init( unsigned char i, void interrupt far(* int6_isr)() );
void int7_init( unsigned char i, void interrupt far(* int7_isr)() );
void int8_init( unsigned char i, void interrupt far(* int8_isr)() );
void int9_init( unsigned char i, void interrupt far(* int9_isr)() );
void nmi_init(void interrupt far (* nmi_isr)());
4.2.3
I/O Initialization
Two ports of 16 I/O pins each are available on the CAN-Engine. Hardware details regarding these PIO lines
can be found in the Hardware chapter.
Several functions are provided for access to the PIO lines. At the beginning of any application where you
choose to use the PIO pins as input/output, you will need to initialize these pins in one of the four available
modes. Before selecting pins for this purpose, make sure that the peripheral mode operation of the pin is
not needed for a different use within the same application.
You should also confirm the PIO usage that is described above within ae_init(). During initialization,
several lines are reserved for TERN usage and you should understand that these are not available for your
application. There are several PIO lines that are used for other on-board purposes. These are all described
in some detail in the Hardware chapter of this technical manual. For a detailed discussion toward the I/O
ports, please refer to Chapter 11 of the AMD Am186ES User’s Manual.
Please see the sample program ae_pio.c in
tern\186\samples\ae
. You will also find that these
functions are used throughout TERN sample files, as most applications do find it necessary to re-configure
the PIO lines.
The function pio_wr and pio_rd can be quite slow when accessing the PIO pins. Depending on the pin
being used, it might require from 5-10
µ
s. The maximum efficiency you can get from the PIO pins occur if
you instead modify the PIO registers directly with an outport instruction Performance in this case will be
around 1-2
µ
s to toggle any pin.
The data register is 0xff74 for PIO port 0, and 0xff7a for PIO port 1.
void pio_init
Arguments:
char bit, char mode
Return value:
none
bit refers to any one of the 32 PIO lines, 0-31.
mode refers to one of four modes of operation.
•
0, High-impedance Input operation
•
1, Open-drain output operation
•
2, output
•
3, peripheral mode
unsigned int pio_rd: