Home
MC683xx to NEURONR CHIP Parallel I/O Interface - Rcl
Contents
1. t token always followed by read display display if pio in len 0 for index 0 index lt pio_in len index tt putc pio in data index stdout pio in len 0 clear length byte Exhibit B Filename neuron h neuron definition file for parallel i o interface Version 1 0 define ACKSYN 0x07 define EOM 0x00 define HSMASK 0x01 define NUL TOKEN 0x00 define RESYNC 0x5a define XFER 0x01 struct neuron unsigned char data unsigned ET unsigned hs PT MOTOROLA LonWorks TECHNOLOGY AN1247 AL 373 k k kx k k Ky de de de de de de de de str Filename definition file for MC68332 Systems Version fine fine fine fine fine fine fine fine uct sim int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int AN1247 AL 374 m332sim h 0 CSOPT2 0x5b30 CSOPT3 0x7830 CSOPT4 0x7b30 PORT8 M500SEC 0x0108 M125SEC 0x0102 M62SEC 0x0101 M32SE 0x2000 C Ox00fE picr pitr SWSY unused 1 tstmsra tstmsrb tstsca tstrc creg dreg unused 2 unused 3 cspdr unused 4 unused 5 unused 6 unused 7 cspar0 csparl csbarbt csorbt csbar0 csor0 csbarl csorl csbar2 csor2 csbar3 GBOr3 csbar4 csor4 c
2. that need to be enabled In addition the function of pio_init C source line of mcmsim picr 0x041c may be modified as required to select the interrupt level generated by the periodic interval timer To select the periodic interval timer interrupt time period modify function pio init and C source line of mcsim pitr M125SEC Note that file m68sim h contains several predefined values for ease in setting this time period To select the location of the NEURON CHIP in the MC683xx memory map modify function pic_init and the C source statement of mcsim csbar5 0x0200 Retain the 2K block size during this modification Source slave nc Description The file sLave nc is a NEURON C source file that resides on the NEURON CHIP connected to the MC68332 The I O pin definition for this node selects the I O object mode of parallel s1ave_b which uses all 11 pins as a parallel interface bus to a host processor Following the I O definition a structure is defined to con tain the length and data fields to be passed from the NEURON CuiP to the MC68332 and from the MC68332 to the NEURON Cuip The next two variables are defined using this structure definition The two variables p_in and p_out are for an incoming data string and an outgoing data string The network variable definitions shown next are nv_ status nv_data_out and nv_data_in Network vari able nv_status is used as a ready indicator of this node having completed its resync operation and ma
3. MOTOROLA SEMICONDUCTOR TECHNICAL DATA AN1247 MCG683xx to Neurone Curip Parallel 1 0 Interface Introduction This example interfaces a Motorola MC683xx family microcontroller to a LoNWoRKs NEURON CHIP through the parallel I O object model interface The actual example uses the MC68332 microcontroller however with minor modifi cations any MC683xx family member may be used With additional hardware and minor software modifications a MC680x0 microprocessor may be used in the example The example code shown for the MC68332 is written in C and the code for the NEURON CHIP is written in NEURON C The example moves data from the NEURON CHIP to the MC68332 and from the MC68332 to the NEURON CHP Figure 1 shows the various components of the example The node called auxnode is a test node for this example and generates a character string of either LEFT or RIGHT and passes this string to the node containing the MC68332 and NEURON CHIP combination The sending of these data strings is triggered by the left and right input buttons on a Gizmo 2 I O module from Echelon The NEURON CHIP in the MC68332 NEURON CHIP based node then passes this data to the MC68332 where the string is displayed on a terminal attached to the MC68332 s serial port Although the example is relatively MC68332 MC68332 NEURON CHIP BASED NODE simple it may be modified to implement an actual user ap plication Parallel I O Ove
4. T or RIGHT to the MC68332 NEURON combination node This node has the same data structure definition of parallel in as found in slave nc The network variables of nv data in and nv data out are defined with this data type Adapting this Example to a Real Application In a real application both s1ave nc and 332 c must be modified The file 332 c must be modified to reflect not only AN1247 AL 370 the application that the MC68332 is to perform but also the data to be sent from the MC68332 to the NEURON CHIP across the parallel interface In addition the file sLave nc must be modified to reflect the data coming into the NEURON CHIP from the network that is to be passed to the MC68332 across the parallel interface Summary Application nodes in LonWorks networks requiring fea tures beyond that of the NEURON CHIP s application proces sor can easily be designed using an M68xxx host connected via a parallel interface to a NEURON CHIP The example shown using the MC68332 demonsirated the hardware and the driver software required to interface an M68000 based processor architecture to the NEURON CHIP Modifications for the C source programs necessary for various processor chips were discussed and documented These parallel inter face drivers should aid in reducing the program development cycle a key feature of LonWorks control technology and its ability for short time to market Disclaimer Although this software has been
5. bus p in len MAX IN io in parallel bus amp p in for i 0 i lt MAX_IN i nv data out buffer i p in buffer i nv data out len p in len when nv_update_occurs nv_data_in for i 0 i lt MAX_IN i p out buffer i nv data in buffer i p out len nv data in len io out request parallel bus AN1247 MOTOROLA LonWorks TECHNOLOGY AL 376 Exhibit G aux node nc IO l1 output oneshot clock 7 led IO 3 input bit right switch IO 7 input bit left switch define MAX IN 20 define OUT LEN 7 typedef struct unsigned int len unsigned int buffer MAX_IN parallel in network input char nv status in network input parallel in nv data in network output parallel in nv data out unsigned int i parallel in string in string in aux string out when nv update occurs nv status in io out 1ed 10000 when nv update occurs nv data in string out len nv data in len for i 0 i MAX IN i string out buffer i nv data in buffer i io out led 10000 when io changes right switch to 0 nv data out len string in len for i 0 i MAX IN i nv data out buffer i string in buffer i io out 1ed 10000 when io changes left switch to 0 nv data out len string in aux len for i 0 i MAX IN i nv data out buffer i string in aux buffer i io out 1led 10000 when wink when reset io_out led 10000 string_in len 6 memcpy string_i
6. carefully reviewed and is believed to be reliable neither Motorola nor the author as sume any liability arising from its use This software may be freely used modified or distributed with user end product s at no cost or obligation to the user MOTOROLA LonWorks TECHNOLOGY Exhibit A Filename 332 c MC68332 to Neuron Parallel I O demo Version 1 0 May 1993 E include lt stdio h gt include neuron h include m332sim h define TRUE 0x01 define FALSE 0x00 define MAX 30 pragma separate port pragma separate mcsim struct neuron port struct sim mcsim char token s data ch int error index struct parallel io unsigned char len unsigned char data MAX struct parallel_io pio_out pio_in interrupt vector initialization and enable _CASM void vector_init move 1 _pit 00000070 move w 2300 sr putc pio out data index stdout main p init data init display for debug purp error master init index 0 pio_out len 0 while TRUE if kbhit TRUE ch getc stdin putc ch stdout pio_out data inde if ch 0x0d S data index break index t pio out len tt if index MAX p_init int temp temp mcsim cspar0 temp temp amp OxOfff PORT8 mcsim cspar0O temp mcsim csbar5 0x0200 mcsim csor5 CSOPT2 MOTOROLA LonWorks TECHNOLOGY OSes x TRU 0 brea x e
7. data to or from the NEURON CHIP To transfer data between the MC68332 and the NEURON CHIP the MC68332 must have the token To transfer data be tween the NEURON CHIP and the MC68332 the NEURON CHIP must have the token This token is given to the MC68332 on initialization of the I O interface Then the MC68332 trans fers the token to the NEURON CHIP either after completing a transfer of data or by just passing a null data byte to it When the token is obtained the NEURON CuiP will pass this token back to the MC68332 through the transfer of a null byte if no data is to be sent to the MC68332 or by the NEURON CHIP transferring data and then giving the token back to the MC68332 Initialization of the parallel I O object module and initial es tablishment of the token ownership is performed by the host CPU sending a RESYNC command to the NEURON CHIP which responds with a ACKSYNC command to the host At this point the host has the token and the interface is ready for use For additional detail refer to the NEURON CuiP data sheet parallel I O description Host CPU System Requirements As previously mentioned this example uses the MC68332 microcontroller however any MC68000 family member may be used The following hardware and software features are required by the host processor for implementation of this ex ample a A CPU with a Motorola MC68000 instruction set b Memory map chip select logic for enabling the NEURON CHIP Thi
8. ed by the tick timer and either sends a data string across the MC68332 to NEURON ChP interface or sends a null token The decision to send data or a null token is based on the current value of the flag s data The last function listed display is for debug purposes and sends the characters from pio in to the standard out put Integrating this example into the desired user application requires rewriting main such that the real user application is performed The function p init must be modified if a dif ferent MC683xx processor was to be used Master init pio write pio read t token tx hs and pit will probably not need modification The routines of data init and display are for demonstration purposes only and could be removed in a real application program Software Options at Compile Time The following software options may be selected at compile time by modifying either initial values of variables or C lan guage define statement values or lines of source code For an understanding of MC68332 register initialization values refer to the MC68332 user manual MC68332 3222 slave nv_status nv_status blink led gt nv data out nv data in x string_out D nv_data_in To set MC68332 exception interrupt levels for the tick timer modify file 332 c the macro of enable_interrupts the MC68000 instruction immediate data field of or w 0300 d1 Move the interrupt mask up or down as required by the interrupt levels
9. efined earlier in the listing The flag s data Which is used to indicate if data is ready to be trans mitted to the slave NEURON CHIP is initialized to false The function master_init performs the resync opera tion as outlined in the NEURON CHIP data book Successful MOTOROLA LonWorks TECHNOLOGY completion of this operation leaves the data transfer token with the microprocessor The function pio write transmits a string of data to the NEURON CHIP by enclosing the data in a packet with the XFER byte and length byte at the beginning of the string and the EOM value at the end of the string The function pio read reads a string of data from the parallel I O interface of the NEURON Cuip The string is re turned in the pio in function which consists of a length byte followed by the data bytes The function of t token transfers a null token to the NEURON CHIP and sets the token flag to false The function of tx hs waits for the handshake line to be come low false The function of data_init initializes a test data string in pio_out In this example the data string consists of the al phabet This function is for demonstration purposes The function of pit is an interrupt service routine The _1IH in front of the function name indicates to the compiler that a return from exception RTE instruction should be placed at the end of the function instead of the normal return from subroutine RTS instruction This interrupt handler is trigger
10. h k AN1247 AL 371 mcsim pitr M125SEC init pit to 125 msec interval mcsim picr 0x041c init pit to level 4 and vector 28 vector init call interrupt init and enable S data FALSE no data to send master_init tx_hs port data RESYNC tx_hs port data EOM tx_hs if port data ACKSYN error 0 token TRUE else error 1 return error pio write int port data XFER tx hst s port data pio_out len tx_hs for i 0 i pio out len itt port data pio out data i tx hs port data EOM tx_hs token FALSE pio read int index count if port hs if port data XFER tx_hs pio_in len port data count pio_in len while index lt count tx_hs pio_in data index port data index tx hs token TRUE t_token port data NULL_TOKEN tx hs port data EOM tx hs token FALSE tx hs while port hs AN1247 MOTOROLA LonWorks TECHNOLOGY AL 372 data_init int d pio out len 5 for i 0 i lt MAX 1 itt pio out data i 0x41 i the following routine is an interrupt service routine IH void pit if s data pio write pio out len 0 pio read t token always followed by read S data FALSE no data to send else t token pio read
11. n buffer RIGHT n 6 string_in_aux len 5 memcpy string_in_aux buffer LEFT n 5 MOTOROLA LonWorks TECHNOLOGY AN1247 AL 377
12. ng to a PROM programmer or development system slave nc NEURON Cur C file for downloading from a LONBUILDER to the parallel I O based node aux node nc NEURON CHIP C file for downloading from a LoNBUILDER to an auxiliary node for exercising the parallel I O node Source 332 c Description The file 332 c contains the C program of main functions for MC68332 initialization read and write functions to the NEURON CHP and interrupt handlers for a tick timer Follow ing is a brief description of each of these functions The function main calls p init data init mas ter init and proceeds to look for a keyboard input from the console The function kohit has been added to the C standard library and returns true upon detecting that a key has been hit and is false otherwise If a key has been hit the value of the key is read by getc and added to the end of a data string of MAX length Upon receipt of a carriage return the flag s data is set true This will be used later to signal that there is a string of characters to be transmitted to the slave NEURON CHIP The function p init initializes the MC68332 system in tegration module SIM for driving the NEURON CHIP with a chip select line CS5 Also the interrupt vector for the PIT tick timer is initialized and microprocessor interrupts are enabled The interrupt vector initialization and enabling of in terrupts is done by using a compiler macro labeled vec tor init Which is d
13. rview The parallel I O model is one of the standard I O objects supplied with a NEURON CHIP Information on operation of this I O object is found in the NEURON CHiP Data Sheet and the NEURON C Programmer s Guide Two versions of this I O ob ject allow either the connection of two NEURON CHIPS for com munication with each other or the connection of a single NEURON CHIP to a microcontroller These two versions are re ferred to as parallel I O slave A mode and parallel I O slave B mode For this example parallel I O mode b is used Figure 2 shows the MC68332 to NEURON CuiP hardware connection The connection uses all 11 pins of the NEURON CHP I O port for connection to a host via an 8 bit data bus R W chip select and an address pin By selecting parallel I O slave B mode the address pin IO 8 allows the NEURON CHIP to occupy two memory locations in the memory map of the host processor These two memory locations are used for selection of a data transfer memory location and a hand shake memory location MC143150 NEURON CHIP LONWORKS NETWORK slave nc TEST NODE auxnode nc Figure 1 LonWorks Parallel I O to MC68332 MOTOROLA LonWorks TECHNOLOGY AN1247 AL 367 MC68332 MC143150 CS5 O 8 D8 D15 8 lO 0 10 7 A0 R W lO 10 10 9 VDD GND SLAVE B MODE Figure 2 MC68332 to MC143150 Interface The parallel I O interface uses the concept of a token to allow initiation of transfer of
14. s logic may either be contained in the CPU as it is in the MC68332 or provided by external hardware C A periodic interval timer PIT recommended but not re quired tick capable of generating an interrupt to the CPU The time period of this timer should be in the range of 20 to 200 ms d Data storage RAM of approximately 100 bytes e Driver program size approximately 500 bytes Development Tools The M68000 C compiler and linker used to create the ob ject file for this example was release 8 2 available from Inter metrics Although the C programming language is somewhat universal data sizes methods of dealing with in terrupt routines and embedded assembly language may dif fer with other C compilers Therefore modifications may be required to adapt to other compilers AN1247 AL 368 Software The files provided for the software example consist of the following see Exhibits A thru G 332 c main executable code for example neuron h C language header file describing registers for the NEURON CHIP m332sim h C language header file describing the MC68332 SIM System Integration Module registers 332 1c memory locate file for the Intermetrics C com piler 332 bat DOS batch file containing command lines for compiling C language source header files and linking compil er output modules to a single executable object module The final entry in the batch file produces S records for down loadi
15. sbar5 esor5 csbar6 caQr6j csbar7 csor7 csbar8 csor8 csbar9 csor9 csbar10 csor10 Exhibit C Intergration Module of 500 of 125 OL F362 of 32 msec msec msec msec for for for for value value value value pitr pitr pitr pitr not in book not in book not in book SIM MOTOROLA LonWorks TECHNOLOGY Exhibit D OCATE S mcsim FFFA22 jOCATE S port 420000 jOCATE init 5000 jOCATE code AFTER 5000 jOCATE data 4f00 Exhibit E rem 332 bat rem C69332 3392wC p Hie HL rr errorl llink 332 01 _L itools rtlibs 1ib332 lib 1ib332 c 332 1c o err error form 332 ab ec usep isep MOTOROLA LonWorks TECHNOLOGY AN1247 AL 375 Exhibit F slave nc IO 0 parallel slave b parallel bus define MAX IN 21 maximum length of input data expected define OUT LEN 7 output length can be equal to or less than the max define MAX OUT 13 maximum array length typedef struct unsigned int len unsigned int buffer MAX_IN parallel in unsigned int i parallel in p in p out network output char nv status network output parallel in nv data out network input parallel in nv data in when reset nv status R indicate slave in resync when io_out_ready parallel_bus io_out parallel_bus amp p_out when io_in_ready parallel_
16. y not be re quired in actual application The network variables nv data in and nv data out are of type parallel in and are used to move data from the combination MC68332 NEURON node and the network and network to the MC68332 NEURON node The network in this case is node aux node Refer to Figure 3 for a pictorial description of how their network variables are bound together with the aux node aux node nv data out string in Figure 3 Network Variable Binding MOTOROLA LonWorks TECHNOLOGY AN1247 AL 369 The remainder of this source code consists of 4 NEURON CHiP when clauses when reset when io out ready when io in ready and nv update occurs The task definition of when reset common to almost all NEURON C programs assigns the ASCII value of R to network variable nv status The task definition of when io out ready performs an io out operation when the parallel bus is in a state where it can be written to and the io out function was previously invoked The task definition of when io in ready does an io in whenever a message arrives on the parallel bus that must be read The task definition of when nv update occurs processes any incoming information from the network and triggers an io out request Source aux node nc Description This NEURON C source program is used for testing the MC68332 NEURON CuiP combination node The node func tion is to send either the character string of LEF
Download Pdf Manuals
Related Search
Related Contents
IM 12180033 BL9310A-GS 20140707.indd ebola : le traitement naturel dont personne ne parle ! N°16, Avril 2007 - Aéroport de Toulouse Sony XS-GT6937A Marketing Specifications Samsung SPE-400B Sony XAV-65 Operating Instructions 2 - Datatail ケータイアップデート操作手順 THE GSM/GPRS/CDMA MODEM USER'S GUIDE ME1203 Copyright © All rights reserved.
Failed to retrieve file