background image

 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 

 

 

Содержание CAN-Engine

Страница 1: ...5616 USA Tel 530 758 0180 Fax 530 758 0181 Email sales tern com http www tern com CAN Engine C Programmable Embedded CAN Controller with 100M BaseT Ethernet RS232 CompactFlash and 16 bit parallel high speed ADC Technical Manual ...

Страница 2: ... 758 0181 Email sales tern com http www tern com Important Notice TERN is developing complex high technology integration systems These systems are integrated with software and hardware that are not 100 defect free TERN products are not designed intended authorized or warranted to be suitable for use in life support applications devices or systems or in other critical applications TERN and the Buye...

Страница 3: ...lash 256 KW and battery backed SRAM 256 KW It also includes 3 timers PWMs 20 PIOs 512 byte serial EEPROM two UARTs 3 timer counters and a watchdog timer The three 16 bit timers can be used to count or time external events up to 10 MHz or to generate non repetitive or variable duty cycle waveforms as PWM outputs The PIO pins are multifunctional and user programmable A serial real timer clock DS1337...

Страница 4: ... Flash for remote debugging With the DV P Kit support user application codes can be easily field programmed into and run out of the Flash A 512 byte serial EEPROM is included on board Two DMA driven serial ports from the Am186ES support high speed reliable serial communication at a rate of up to 115 200 baud All serial ports support 8 bit and 9 bit communication There are three 16 bit programmable...

Страница 5: ...2 bytes EE Controller Area Network CAN2 0B 20 TTL I Os Real time clock 2 serial ports PWM counters 4 ch 16 bit parallel high speed ADC AD7655 Hardware TCP IP stack for 100M Base T Ethernet CompactFlash card with FAT file system support 1 2 Physical Description The physical layout of the CAN Engine is shown in Figure 1 2 Figure 1 2 Physical layout of the CAN Engine ...

Страница 6: ...e sent out from serial port0 at 19200 baud for a CANE 40MHz or 9600 baud for a CANE 80MHz If the STEP 2 jumper is install ed the jump address located in the on board serial EE will be read out and then jump to that address A DEBUG kernel EE40_115 hex for the CANE 40MHz or EE80_115 hex for the CANE 80MHz can be downloaded residing in 0xFA000 of the 512KB on board flash chip The EE84_115 hex can als...

Страница 7: ...d ide or test ide Download code to target SRAM Edit compile link locate download and remote debug STEP 1 Debugging STEP 3 DV P Kit Generate application HEX file with DV P and ACTF Kit ACTF D to download L_29F400 HEX into SRAM Download application HEX file into FLASH Modify EEPROM jump address to 0x80000 Set STEP2 jumper Production There is no ROM socket on the board The user s application program ...

Страница 8: ...st have a Jump Address of 0xfa000 4 The STEP2 jumper must be installed on J2 pins 38 40 For further information on programming the CAN Engine refer to the manual on the TERN CD under tern_docs manuals software_kit pdf The CANE works with most TERN expansion boards including the P50 P100 P300 MotionC MMC and Eye0 Figure 1 4 CAN Engine is installed on the top of the MotionC P ...

Страница 9: ...hould be connected to one of your PC s COM Ports COM1 or COM2 2 2 2 Powering on the CAN Engine By factory default setting 1 The RED STEP2 Jumper is installed Default setting in factory 2 The DEBUG kernel is pre loaded into the on board flash starting at address of 0xFA000 Default setting in factory 3 The EEPROM is set to jump address of 0xFA000 Default setting in factory Connect 9 12V DC to the DC...

Страница 10: ...o connect to H1 See Appendix D Figure 2 1 Debug Cable Ser0 Power Plug and Step 2 Jumper shown NOTE Remember to watch for the double blink off the LED This indicates the Debug Kernel has been loaded with the jump address pointing to it This is mandatory to commence downloading code through the Paradigm environment Step 2 Jumper H1 Ser 0 IDE DB9 Debug Cable 9 12 Volt Power plug Center Negative CAN P...

Страница 11: ...wo pads allowing a 3V backup lithium battery is installed in two different positions 1 The battery s positive lead is installed in the pad which is away from the RTC supporting the RTC only No battery backup for the SRAM 2 The battery s positive lead is installed in the pad which is closer to the RTC supporting both RTC and SRAM In the future when the fast 10 ns and low standby power SRAM is avail...

Страница 12: ... order to increase noise immunity and transform slowly changing input signals to fast changing and jitter free signals As a result of this buffering these pins are capable of only acting as input These buffered external interrupt inputs require a falling edge HIGH to LOW to generate an interrupt The CAN Engine uses vector interrupt functions to respond to external interrupts Refer to the Am186ES U...

Страница 13: ...each timer can operate is 10 MHz since each timer is serviced once every fourth clock cycle Timer output takes up to six clock cycles to respond to clock or gate events See the sample programs timer02 c and ae_cnt1 c in the tern 186 samples ae directory 3 2 5 PWM outputs and PWD The Timer0 and Timer1 outputs can also be used to generate non repetitive or variable duty cycle waveforms The timer out...

Страница 14: ...n P7 A17 Normal U3 pin 22 A17 P8 A18 Normal U3 pin 23 A18 P9 A19 Normal J2 pin 10 A19 P10 Timer0 out Input with pull down J2 pin 12 Input with pull down P11 Timer0 in Input with pull up U7 EE pin 5 Input with pull up P12 DRQ0 INT5 Input with pull up J2 pin 5 Output for LED EE HWD P13 DRQ1 INT6 Input with pull up J2 pin 11 Input with pull up P14 MCS0 Input with pull up J2 pin 37 Input with pull up ...

Страница 15: ...t 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 th...

Страница 16: ...ogrammable wait state of 15 cycles still insufficient Due to the high bus speed of the system some components need to be attached to I O pins directly For details regarding the chip select unit please see Chapter 5 of the Am186ES User s Manual The table below shows more information about I O mapping I O space Select Location Usage 0x0000 0x00ff PCS0 J1 pin 19 P16 USER 0x0100 0x0103 PCS1 J2 pin 13 ...

Страница 17: ... several functions watchdog timer battery backup power on reset delay power supply monitoring and power failure warning These will significantly improve system reliability Watchdog Timer The watchdog timer is activated by setting a jumper on J5 of the CAN Engine The watchdog timer provides a means of verifying proper software execution In the user s application program calls to the function hitwd ...

Страница 18: ...an NMI service routine to take protect actions before the 5V drops and processor dies The following circuit shows how you might use the power failure detection logic within your application 47K 2K PFI pin 9 of MAX691 1 3 V min 8 35 V min 9 14 V C VCC 5V Using the supervisor chip for power failure detection Battery Backup Protection The backup battery protection protects data stored in the SRAM and...

Страница 19: ...ersion rate analog signal acquisition The AD7655 contains two low noise high bandwidth track and hold amplifiers that allow simultaneous sampling on two channels Each track and hold amplifier has a multiplexer in front to provide a total of 4 channels analog inputs The parallel ADC achieves very high throughput by requiring only two CPU I O operations one start one read to complete a 16 bit ADC re...

Страница 20: ...o connect CAN signals to an external standard DB9 CAN connector in the field 3 5 5 100 MHz BaseT Ethernet An WizNet Fast Ethernet Module can be installed to provide 100M Base T network connectivity This Ethernet module has a hardware LSI TCP IP stack It implements TCP IP UDP ICMP and ARP in hardware supporting internet protocol DLC and MAC It has 16KB internal transmit and receiving buffer which i...

Страница 21: ...wer via J2 39 VCC and J2 40 GND or J1 1 VCC and J1 2 GND 2 Unregulated 9V to 12V DC power via two pin screw ternimals T2 while a 5V linear regulator LM7805 U00 is installed All the input voltage has to drop to 5V it is generating a lot of heat With a 3 3V regulator U14 to power the Ethernet and R1120 CPU it requires regulated 5V DC power for the rest circuit DC 9 12V DC 5V ...

Страница 22: ...ders J1 and J2 There are two 20x2 0 1 spacing headers for expansion Most signals are directly routed to the Am186ES processor These signals are 5V only and any out of range voltages will most likely damage the board 3 6 2 H3 Connector for ADC 3 6 3 CAN and DAC voltage outputs Header ...

Страница 23: ... space and a memory address space I O address space ranges from 0x0000 to 0xffff or 64 KB Memory address space ranges from 0x00000 to 0xfffff in real mode or 1 MB These are accessed differently and not all addresses can be translated and handled correctly by hardware I O and memory mappings are done in software to define how translations are implemented by the hardware Implicit accesses to I O and...

Страница 24: ...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 th...

Страница 25: ...ress space starts 0x00000 with a maximum of 512K RAM Three wait state operation Reducing this value can improve performance Disables PSRAM and disables need for external ready outport 0xffa2 0x7fbf LMCS base Mem address 0x0000 Initialize MMCS and MPCS so that MCS0 and PCS0 PCS6 except for PCS4 are configured so MCS0 is mapped also to a 256K window at 0x80000 If used with MemCard this chip select l...

Страница 26: ...ES Microcontroller User s Manual TERN provides functions to enable disable all of the eight external interrupts The user can call any of the interrupt init functions listed below for this purpose The first argument indicates whether the particular interrupt should be enabled and the second is a function pointer to an appropriate interrupt service routine that should be used to handle the interrupt...

Страница 27: ...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 line...

Страница 28: ...ion the user will be able to achieve The timers can be used to time execution of your user defined code by reading the timer values before and after execution of any piece of code For a sample file demonstrating this application see the sample file timer c in the directory tern 186 samples ae Two of the timers Timer0 and Timer1 can be used to do pulse width modulation with a variable duty cycle Th...

Страница 29: ... 2 6 Other library functions On board supervisor MAX691 or LTC691 The watchdog timer offered by the MAX691 or LTC691 offers an excellent way to monitor improper program execution If the watchdog timer J5 jumper is set the function hitwd must be called every 1 6 seconds of program execution If this is not executed because of a run time error such as an infinite loop or stalled interrupt service rou...

Страница 30: ...rtc1_init Arguments char t Return value none This function is used to initialize and set a value into the real time clock The argument t should be a null terminated byte array that contains the new time value to be used The byte array should correspond to weekday year10 year1 month10 month1 day10 day1 hour10 hour1 minute10 minute1 second10 second1 0 If for example the time to be initialized into t...

Страница 31: ...ble to debug code directly written for serial port 0 Two asynchronous serial ports are integrated in the Am186ES CPU SER0 and SER1 Both ports have baud rates based on the 40 MHz clock and can operate at a maximum of 1 16 of that clock rate By default SER0 is used by the DEBUG ROM for application download debugging in Step One and Step Two We will use SER1 as the example in the following discussion...

Страница 32: ...efault mode of 8 bit 1 stop bit no parity After s1_init you can set up a new mode with different numbers for data bit stop bit or parity by directly accessing the Serial Port 0 1 Control Register SP0CT SP1CT if necessary as described in chapter 10 of the Am186ES manual for asynchronous serial ports Due to the nature of high speed baud rates and possible effects from the external environment serial...

Страница 33: ... HEX file is then transmitted out of SER0 This sample program can be found in tern 186 samples ae Software Interface Before using the serial ports they must be initialized There is a data structure containing important serial port state information that is passed as argument to the TERN library interface functions The COM structure should normally be manipulated only by TERN libraries It is provid...

Страница 34: ... will be disabled which means that no values will be transmitted This allows you to control when you wish the transmission of data within the outbound buffer to begin Once the interrupts are enabled it is dangerous to manipulate the values of the outbound buffer as well as the values of the buffer pointer putsern Arguments unsigned char outch COM c Return value int return_value This function place...

Страница 35: ...basic serial port communication lines for transmitting and receiving data Hardware flow control in the form of CTS Clear To Send and RTS Ready To Send is not implemented There are however functions available that allow you to check and set the value of these I O pins appropriate for whatever form of flow control you wish to implement Before using these functions you should once again be aware that...

Страница 36: ... over a Controller Area Network a popular protocol and bus standard for microcontroller communication BACKGROUND Controllers communicate over a CAN network using frames at a specified baud rate Controllers can send and receive equally on the CAN network with the underlying chipset handling collision detection and basic buffering In simplified form each transmitted frame consists primarily of Recip...

Страница 37: ...cane can_echo c int can_set_hw Arguments unsigned char board_type Return values none This function configures the CAN port according to the architecture of your board This function should be called first before any other CAN function is accessed Available board_type values are defined in can h If this call is not accurate the CAN port can not be accessed For the CAN Engine this call should read ca...

Страница 38: ... using SER1 RTS pin s1_rts 0 RTS1 low enable void can_hit Arguments none Return value non zero if packet received 0 if receive buffer is empty Use this function to determine whether a packet has been received and buffered Call this function before calling can_get to retrieve actual message void can_get Arguments CanMsg message Return value none This function is used to retrieve a CAN message after...

Страница 39: ...he processor s memory meaning they can be accessed directly from a pointer The existing driver code sits on top of the memory layer and provides easier interfaces to this underlying data The user application has full ability to set most all meaningful TCP UDP IP flags ranging from the obvious port address to the less obvious timeout options The provided drivers should work correctly under both sma...

Страница 40: ...ation between the 4 available sockets if needed after this is done the module can already be remotely ping ed at the above address See above section for more details establish a socket with appropriate type port parameters TCP stream server socket on port 80 for example regularly monitor the status of the socket using the select function as part of the main application loop ie respond to incoming ...

Страница 41: ...ned for the 586 Engine P board TERN_5E This must be explicitly defined for the 586 Drive controller TERN_P51 Indicates P51 expansion board and windowed access to the memory mapped module another macros also needed to indicate the Engine architecture you re working with I2CHIP_MMC Indicates MMC expansion board and also windowed access to module for the MM C make sure i2chip mmc c is also included i...

Страница 42: ...e you can ping the board From a PC located on the same LAN subnet open a DOS command prompt window In this window run the command ping xxx xxx xxx xxx where xxx corresponds to the address of your board such as 192 168 2 205 2 for the HTTP server code you can open up Internet Explorer and open up the URL http 192 168 2 205 3 for generic TCP server code you can open up a client connection On Windows...

Страница 43: ...When the request is finalized the file is closed Depending on the desired behavior it might be faster efficient to create a filesystem cache to load frequently read files rather than opening closing the same file every time a request is processed Note that you might need to add additional filesystem specific defines in order for httpd_fs c to operate correctly Familiarize yourself with filesytem c...

Страница 44: ... c the user application which connects serial TCP data socket c socket implementation as above i2chip_hw c hardware interfacce as above ae lib library for A R family of boards as above OR re lib tcp_echo This sample provides for a simple TCP echo server on 4 ports 4000 4001 4002 4003 The 4 sockets are established to listen to each of the 4 ports When a conection is established the program monitors...

Страница 45: ... void adc_init void UINT16 adc_rd UCHAR8 channel Related files socket c socket implementation as above i2chip_hw c hardware interfacce as above ae lib library for A R family of boards as above OR re lib dhcp_ip This sample program demonstrates how to interface to a DHCP server in order to dynamically set IP level addresses Instead of statically setting your IP address your controller can now query...

Страница 46: ... interface as above 586 lib 586 based system library filesy16 lib for integrated CompactFlash on 586 Engine P 5D boards filesys lib for expansion CompactFlash on MM C or FC 0 expansion boards mm16 lib for integrated CompactFlash on 5P 5D boards mma lib for expansion CompactFlash on MM C or FC 0 expansion boards i2chip mmc c for accessing MM C page window modes 4 6 9 Version info Version 1 00 Initi...

Страница 47: ...gine Layout CAN Engine 1 CAN Engine Layout All dimensions are in inches 0 117 0 125 0 175 0 275 1 433 0 075 3 442 0 125 3 183 2 217 1 233 2 267 0 483 2 267 0 333 2 217 3 575 2 333 3 367 2 175 0 0 2 408 0 058 ...

Страница 48: ...6 D0 7 D1 8 D2 9 D3 10 VCC 11 GND 12 D4 13 D5 14 D6 15 D7 16 WR 17 A5 18 A6 19 A7 20 A8 21 A16 22 A15 44 A14 43 A13 42 OE 41 UB 40 LB 39 D15 38 D14 37 D13 36 D12 35 GND 34 VCC 33 D11 32 D10 31 D9 30 D8 29 NC 28 A12 27 A11 26 A10 25 A9 24 A17 23 U3 RAM44 1 2 3 H3 120 CANH GND 1 2 3 4 5 6 7 8 9 10 J3 HDRD10 VB CANH CANL GND VCC TX0 RX0 CANH CANL VCC CANL GND RTS1 VA GND GND AA1 AA2 AG 1 AV 2 A0 3 BY...

Отзывы: