Chapter 4: Software
CAN-Engine
_____________________________________________________________________________________
4-2
peek/peekb
Arguments: unsigned int segment, unsigned int offset
Return value: unsigned int/unsigned char data
These functions retrieve the data for a specified address in memory space. Once again, the segment address
is shifted left by four bits and added to the offset to find the 20-bit address. This address is then output over
the address bus, and the hardware component mapped to that address should return either an 8-bit or 16-bit
value over the data bus. If there is no component mapped to that address, this function will return random
garbage values every time you try to peek into that address.
outport/outportb
Arguments: unsigned int address, unsigned int/unsigned char data
Return value: none
This function is used to place the data into the appropriate address in I/O space. It is used most often when
working with processor registers that are mapped into I/O space and must be accessed using either one of
these functions. This is also the function used in most cases when dealing with user-configured peripheral
components.
When dealing with processor registers, be sure to use the correct function. Use outport if you are dealing
with a 16-bit register.
inport/inportb
Arguments: unsigned int address
Return value: unsigned int/unsigned char data
This function can be used to retrieve data from components in I/O space. You will find that most hardware
options added to TERN controllers are mapped into I/O space, since memory space is valuable and is
reserved for uses related to the code and data. Using I/O mappings, the address is output over the address
bus, and the returned 16 or 8-bit value is the return value.
For a further discussion of I/O and memory mappings, please refer to the Hardware chapter of this technical
manual.
4.1
AE.LIB
AE.LIB is a C library for basic CAN-Engine operations. It includes the following modules: AE.OBJ,
SER0.OBJ, SER1.OBJ, SCC.OBJ, and AEEE.OBJ. You need to link AE.LIB in your applications and
include the corresponding header files. The following is a list of the header files:
Include-file name
Description
AE.H
PPI, timer/counter, ADC, DAC, RTC, Watchdog,
SER0.H
Internal serial port 0
SER1.H
Internal serial port 1
SCC.H
External UART SCC2691
AEEE.H
on-board EEPROM