CAN-Engine Chapter 3: Hardware
3-5
Three external interrupt lines are not shared with PIO pins:
INT0 = J2 pin 8
INT1 = J2 pin 6
INT3 = J2 pin 21
The 32 PIO lines, P0-P31, are configurable via two 16-bit registers, PIOMODE and PIODIRECTION. The
settings are as follows:
MODE PIOMODE reg. PIODIRECTION reg. PIN FUNCTION
0 0 0 Normal operation
1 0 1 INPUT with pull-up/pull-down
2 1 0 OUTPUT
3 1 1 INPUT without pull-up/pull-down
CAN-Engine initialization on PIO pins in ae_init() is listed below:
outport(0xff78,0xe73c); // PDIR1, TxD0, RxD0, TxD1, RxD1, P16=PCS0, P17=PCS1=PPI
outport(0xff76,0x0000); // PIOM1
outport(0xff72,0xec7b); // PDIR0, P12,A19,A18,A17,P2=PCS6=RTC
outport(0xff70,0x1000); // PIOM0, P12=LED
The C function in the library ae_lib can be used to initialize PIO pins.
void pio_init(char bit, char mode);
Where bit = 0-31 and mode = 0-3, see the table above.
Example: pio_init(12, 2); will set P12 as output
pio_init(1, 0); will set P1 as Timer1 output
void pio_wr(char bit, char dat);
pio_wr(12,1); set P12 pin high, if P12 is in output mode
pio_wr(12,0); set P12 pin low, if P12 is in output mode
unsigned int pio_rd(char port);
pio_rd (0); return 16-bit status of P0-P15, if corresponding pin is in input mode,
pio_rd (1); return 16-bit status of P16-P31, if corresponding pin is in input mode,
Some of the I/O lines are used by the CAN-Engine system for on-board components (Table 3.2). We
suggest that you not use these lines unless you are sure that you are not interfering with the operation of
such components (i.e., if the component is not installed).
You should also note that the external interrupt PIO pins INT2, 4, 5, and 6 are not available for use as
output because of the inverters attached. The input values of these PIO interrupt lines will also be inverted
for the same reason. As a result, calling pio_rd to read the value of P31 (INT2) will return 1 when pin 19
on header J2 is pulled low, with the result reversed if the pin is pulled high.
Signal Pin Function
P14 /MCS0 100M BaseT Ethernet
P4 /DT STEP2 jumper
P11 Timer0 input Shared with RTC, EE data input
P12 DRQ0/INT5 Output for LED or U7 serial EE clock or Hit watchdog
P17 /PCS1 CAN, ADC
P22 TxD0 Default SER0 debug