Infineon 82C900 Application Note

Standalone twincan controller

Advertisement

Quick Links

A p p l i c a t i o n N o t e , V 1 . 0 , F e b . 2 0 0 4
AP29002
82C900
Sta nda lo ne TwinCAN Co n tro ller
Micr ocon tro l lers
N e v e r
s t o p
t h i n k i n g .

Advertisement

Table of Contents
loading

Summary of Contents for Infineon 82C900

  • Page 1 A p p l i c a t i o n N o t e , V 1 . 0 , F e b . 2 0 0 4 AP29002 82C900 Sta nda lo ne TwinCAN Co n tro ller...
  • Page 2 Previous Version: Page Subjects (major changes since last revision) Updated Layout to Infineon Corporate Design, updated release to 1.0, Content unchanged! We Listen to Your Comments Any information within this document that you feel is wrong, unclear or missing at all? Your feedback will help us to continuously improve the quality of this document.
  • Page 3 Infineon Technologies Components may only be used in life-support devices or systems with the express written approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure of that life-support device or system, or to affect the safety or effectiveness of that device or system.
  • Page 4: Table Of Contents

    CAN protocol overview.................. 2 Using special features of the 82C900 ............2 Using the 82C900 with SSC interface ............2 Using the parallel interface of the 82C900 ............ 2 Hardware Gateway functionality..............2 Normal Gateway Mode.................. 2 Shared Gateway ................... 2 Stand Alone mode..................
  • Page 5: Product Overview

    In addition, a 16-bit frame count/time-stamp is implemented for each message object. The 82C900's analyzing mode, during which no dominant bits are sent, makes it ideal for diagnostic applications.
  • Page 6 AP29002 Standalone TwinCAN Controller Product Overview The Infineon 82C900 comes with many useful features, such as: • Handles two independent CAN buses autonomously • 32 message objects can be independently assigned to one of the two buses • Complies with CAN protocol version 2.0B (active) •...
  • Page 7: Can Protocol Overview

    AP29002 Standalone TwinCAN Controller CAN protocol overview CAN protocol overview CAN is an asynchronous serial bus system with one logical bus line. A CAN bus consists of two or more nodes. The number of nodes on the bus may be changed dynamically without disturbing the communication of other nodes.
  • Page 8 AP29002 Standalone TwinCAN Controller CAN protocol overview In this kind of frame, the identifier field has a length up to 11 bits giving 2048 message identifiers. But “extended CAN” specifications allow a 29 bits identifier field giving 536 Million messages identifiers. In this application note, only “standard CAN” will be used but C167CR and CS also support “extended CAN”...
  • Page 9: Using Special Features Of The 82C900

    (plus one for each interrupt you want to use). The default baud rate of the SSC interface on the 82C900 is 100 KBaud. But it can work with a speed up to 6.25 MBaud in slave- and 12.5 MBaud in master mode.
  • Page 10 Standalone TwinCAN Controller Using special features of the 82C900 An example using the SSC Slave mode of the 82C900 was implemented using the 82C900 evaluation board and an Infineon C167CR as the host microcontroller. The 82C900 evaluation board was connected directly to the Phytec KitCON167 evaluation board for the C167CR.
  • Page 11 For transferring data to a register we need to specify its 11-bit address. But since the SSC interface on the 82C900 is only able to handle 8 bits at a time and one of these is used for Read/Write indication, the rest of the address has to be specified in a different way.
  • Page 12 SLS = 1; // set SLS=1, communication sequence end The 82C900 extends the SSC interface by a ready signal (RDY). This is necessary, because both CAN and SSC interfaces use the same memory area. As long as there is CAN access to the registers, the SSC will be suspended by using the RDY signal to avoid collisions.
  • Page 13 SSC. Then the data byte is transferred completing the communication sequence. This procedure is the same for all Infineon microcontrollers containing a SSC peripheral. Reading a byte from the 82C900 works similar to writing: First the four MSB bits are extracted from the address as they specify the page.
  • Page 14 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 After that the address and a dummy byte are transferred to the 82C900. The C function shown below the returns the data byte read from the 82C900 byte SSC_ReadByte(word StartAddress) SSC_SetPage(StartAddress >>...
  • Page 15 This part of the code initializes the microcontroller and sets up CAN node A in the 82C900 for operation at 1 MBaud. To be able to change the configuration, bit CCE in ACR must be set and then be reset again after the configuration has been changed.
  • Page 16 . Then you can configure the message object, set the data MSGVAL MSGCTRn direction, data length and associated interrupt node. In the 82C900 there are two interrupt pins available, that can be associated with up to 4 interrupt nodes each by configuring the register. Then you can associate GLOBCTR the single message objects with one interrupt node each.
  • Page 17 Using special features of the 82C900 Now the transmit message object is set up by setting the corresponding register in the 82C900. It works similar to the receive object, only the data direction and identifier are different and no interrupt node is needed.
  • Page 18 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 void INT_viIsrEx3(void) interrupt CC11INT unsigned char databuffer, checkTXRQ; databuffer = SSC_ReadByte(MSG_OBJ_BASE(0)+MSGDRn0); // get data from received message checkTXRQ = SSC_ReadByte(MSG_OBJ_BASE(1)+MSGCTRn+1) | 0x10; // checkTXRQ holds LSB of TXRQ if(checkTXRQ) // TXRQ='01', no transmission requested, ok to send SSC_SendByte(MSG_OBJ_BASE(1)+MSGCTRn+1,0xFB);...
  • Page 19: Using The Parallel Interface Of The 82C900

    Using special features of the 82C900 Using the parallel interface of the 82C900 The 82C900 can also be configured via parallel interface. The host CPU must support an 8-Bit Infineon or Motorola compatible multiplexed bus and 4 control signals: /ALE, /CS, /WR and /RD for an Infineon compatible parallel bus.
  • Page 20 JP42 2-3 closed The 82C900 is configured for a long read access by setting bit LAE in the GLOBCTR- Register to ‘1’ (default ‘0’). Configurations for the /CS3 signal on the C167CR For this example a 4K memory window with start address 0x200000 is used. In this address range the address/data-bus is an 8-Bit multiplexed bus.
  • Page 21 (/WR high to next ALE) for C167CR whlh > 5MHz, the functions for the write access of the 82C900 must be copied into the IRAM of the microcontroller. Therefore a user class must be defined with the following entries in the target options window of the Keil-Compiler.
  • Page 22 _82C900 ((unsigned char volatile xhuge*) 0x200000) It is the base address of the 82C900 with the described configuration for BUSCON3. Next is the source code of the functions to access the 82C900. The following functions will be copied into the IRAM. They are located in the file P_ACS.C (short for “Parallel Access”).
  • Page 23 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 The following functions send a byte/word or n bytes to the 82C900: // sends one byte to the 82C900 at address 'startaddress' void P_SendByte(word startaddress, unsigned char data) // set Pagenumber A10-A7 P_Write((PAGE&0x00ff), (unsigned char)(startaddress>>7)&0x0E);...
  • Page 24 P_ReadnBytes(word startaddress, unsigned char *data, int bytecount) int i; for( i = 0; i < bytecount; i++) data[i] = P_ReadByte(startaddress+i); Following functions can be used to configure the 82C900 easily: // set the GLOBCTR for long read access // copy transferfunctions in the IRAM void Parallel_init()
  • Page 25 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 // configure the interrupt and the interruptnode for the MSGOBJ msg_obj void init_INT(char msg_obj, char INT_Node) unsigned char dir; unsigned int INT = 1, node, help = 0; // configures the (A/B)IMR0 register for the MSGOBJINT node = (P_ReadByte(MSG_OBJ_BASE(msg_obj)+MSGCFGn)&0x02)>>1;// 1 if...
  • Page 26 Standalone TwinCAN Controller Using special features of the 82C900 Functions to transmit data via CAN-Bus or to read received data from the 82C900: // load wd_nr bytes into the MSGOBJ and transmit them via CAN-BUS void SendData(int msg_obj, unsigned char *data, int bt_nr) msg_dat=MSG_OBJ_BASE(msg_obj)+MSGDRn0;...
  • Page 27 CC10INT (pin 2.10 of C167CR) is triggered from INT0 (OUT0 of 82C900). The interrupt function reads the data from the 82C900 and sends it back via message object 2 with the ID 0x0002. The transfers can be watched with a CAN-Analyzer or an Oscilloscope.
  • Page 28 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 The interrupt function reads only the received data from MSGOBJ0 and sends it back via MSGOBJ2. void INT_viIsrEx2(void) interrupt CC10INT // USER CODE BEGIN (IR_IsrEx2,1) unsigned char data[2]={0x00,0x00}; ReadData(0,data,2); SendData(2,data,2);...
  • Page 29 // USER CODE BEGIN (Main,1) unsigned char data[2]={0x55,0xAA}; // USER CODE END // USER CODE BEGIN (Main,2) Parallel_init(); // set GLOBCTR of the 82C900 Project_Init(); init_NodeA(); // init node A init_NodeB(); // init node B init_MSG(0,0,0,2,0x0001);//MSG0 is a receive OBJ, Node A, 2 Databytes init_INT(0,0);...
  • Page 30: Hardware Gateway Functionality

    Using special features of the 82C900 Hardware Gateway functionality The 82C900 also provides the possibility to act as a gateway between two CAN- Busses. It doesn’t matter if the CAN-Busses work at the same speed. So it can be used to connect a High- and a Low-speed CAN Bus with or without any control of a microcontroller.
  • Page 31 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 C A N - B U S 1 1 M B a u d C A N - B U S 2 1 2 5 K B a u d...
  • Page 32 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 Now message object 0 is configured as receive object for the normal gateway mode without FIFO-Buffering. The gateway capability is configured in the Message Object n FIFO/Gateway Control Register MSGFGCR.
  • Page 33 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 Table 4 Settings for the MSGFGCR-Register for the receiving object FSIZE = “0x00” Turns the FIFO-Buffer off Received message will be automatically transmitted GDFS = ‘1’ from the transmitting object.
  • Page 34 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 Table 5 Settings for the MSGFGCR-Register for the transmitting object FSIZE = “0x00” Turns the FIFO-Buffer off A remote frame, received from the destination SRREN = ‘1’ object, will be send from the source object.
  • Page 35: Shared Gateway

    AP29002 Standalone TwinCAN Controller Using special features of the 82C900 Shared Gateway The following application creates an bi-directional gateway between CAN-Bus1 (1M Baud) and CAN-BUS2 (125K Baud) using message objects one and two in shared gateway mode. The objects transmit the received data automatically on the destination side and switch than back to the source side to wait for the next message.
  • Page 36 Figure 8 Configuration of the 82C900 for the Shared-Gateway-Mode The parallel interface is used to configure the 82C900. See the description of the used functions in the description of the parallel interface. The following functions configure Node A for 1M Baud and Node B for 125K Baud:...
  • Page 37 |= 0x0100; // automatic transmission on destinationsite if(SRREN) cfg |= 0x0200; // waiting on remoteframes P_SendWord(MSG_OBJ_BASE(obj_nr)+MSGFGCRn,cfg); Main function of the example application, that configures the 82C900 as described above: void main(void) Project_Init(); // USER CODE BEGIN (Main,2) Parallel_init();// configure 82C900 for long readaccess.
  • Page 38: Stand Alone Mode

    SPI-EEPROM. SPI Master Mode If the mode pins are both high during reset, the 82C900 works as master for a SPI- data transfer. So it can be easily connected to an SPI-compatible EEPROM. The communication protocol is described in the 82C900 users manual in chapter 2.2.1.
  • Page 39 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 Table 7 Jumper settings for SSC-Master-Mode JP10 3-4 connected: SLS on EEPROM JP32 Open JP33 Open JP38 All open 3-7 closed, JP39 1-2 open 8 open JP40 All open The Table 8 shows the EEPROM-data for configuring CAN-Node A (1Mbaud) and Message object 0 as the configuration object for the initialization via CAN-Bus.
  • Page 40 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 C A N - B U S 1 M B a u d 8 2 C 9 0 0 R e g is t e r - S e t...
  • Page 41 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 2 Data bytes => 0x0044(CANINIT) 0x000D Message object 0 is init object. Init via CAN enabled. Initcode is 0xAA 1 Data byte => 0x0314(MSGCFG0) 0x0011 Messageobject0 is receiving object of Node A with 7 Data bytes 1 Data byte =>...
  • Page 42: Configuration Via Can-Bus

    Using special features of the 82C900 Configuration via CAN-Bus After the configuration of one Node and one message object, the 82C900 can be configured via CAN-Bus. These initmessages contain as a first byte the Initcode (here 0xAA), then two bytes of address and one to four bytes of data. The following sequence will configure the second Node for 125 KBaud and 2 more message objects so that 82C900 will work as unidirectional gateway between the two CAN-Busses.
  • Page 43 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 Table 9 Data Bytes of CAN Messages used to configure the 82C900 Init- Description code Set INIT and CCE in 0xAA BCR(0x0240) BBTR(0x024C) set Node to 0xAA 125KBaute BMIR0(0x0258) INT pending...
  • Page 44: Using The Parallel Port As General Purpose I/O

    Using the parallel port as general purpose I/O If the 82C900 is used in the SSC/SPI mode (Slave or Master), it is possible to configure the port pin P1-P8 as general purpose I/O port. The function of each pin can be configured in the registers IOMODE0/2.
  • Page 45 82C900 is made in the registers IOMODE0/2 and for IN/OUTMSG in the register CANIO. If the 82C900 receives a message in OUTMSG with an ID of 1, it puts the first data byte automatically in OUTREG. The contents of the register can be seen on all pins that are configured as output (P4-P7).
  • Page 46 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 The complete source files for this application are located in the “P_Port_GPIO” directory. Function to configure node A and the message objects via SSC: // configures node A for a CAN-Bus speed of 125KBaud void NodeA(void) SSC_SendByte(ACR,0x41);...
  • Page 47 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 Main function of the example application: void main(void) // USER CODE BEGIN (Main,1) // USER CODE END Project_Init(); // USER CODE BEGIN (Main,2) NodeA(); SSC_init_MSG(0,0,0,1,1);// MSG0, receive, Node A, id = 1 SSC_init_MSG(0,1,1,1,2);// MSG1, transmit, Node A, id = 2...
  • Page 48: The Fifo-Capability Of The 82C900

    This can be useful to minimize the time where the microcontroller communicates with the 82C900 or to minimize the risk of data loss during times of high CPU-loads or especially when the 82C900 acts as normal gateway between two CAN- Busses with different speeds.
  • Page 49 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 void LoadRemoteData(int msg_obj, unsigned char *data, int bt_nr) msg_dat=MSG_OBJ_BASE(msg_obj)+MSGDRn0; // address of the MSGOBJ-data P_SendWord(MSG_OBJ_BASE(msg_obj)+MSGCTRn, 0xFB7F); //inhibit transmission. P_SendnBytes(msg_dat,data,bt_nr);// send new data to the MSGOBJ P_SendWord(MSG_OBJ_BASE(msg_obj)+MSGCTRn, 0xF6BD);// enable data This function can be used to initialize a FIFO-buffer and to send or read data: // initialize FSIZE(see users manual) MSGOBJ for on FIFO-Buffer using // MSGOBJ(base) as baseobject.
  • Page 50 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 The following functions can be used to up/download data from/to the FIFO-buffer. The load-function automatically searches for the next free object. If there is no free message object in the buffer the function returns with zero. The read-function searches for and reads the data from the first message object, where the NEWDAT-flag is set.
  • Page 51 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 // reads the data from the next OBJ with the NEWDAT flag set. // return: // 0 data read OK // 1 data can be invalid MSGLST was set // -1 no OBJ in the FIFO with set NEWDAT flag int read_FifoObj(int base, unsigned char* data) int by_nr, next, i=0,FSIZE, obj, ret;...
  • Page 52 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 load_FifoObj(16,data,0); // copy data to transmitting fifo if(1 == read) // messages got lost data[0] = 0xFF; // mark as invaltite SendData(0,data,4); // send alert else// readout other MSGOBJ ReadData(obj,data,4);...
  • Page 53 Setting the base object invalid won’t stop the transmission until CANPTR=base object. If the FIFO is configured for answering remote frames (TXRQ is not set) the 82C900 starts transmitting messages when the base object is valid and a remote frame is received.
  • Page 54: Using The Fifo-Buffering In A Gateway Application

    CAN- Bus. The 82C900 provides a solution for this problem, using a FIFO-Buffer as a destination-object. The FIFO-Buffer must be configured in the same way as the transmitting Buffer in the last example.
  • Page 55 AP29002 Standalone TwinCAN Controller Using special features of the 82C900 The source code of this application example is located in the “FIFO_GATEWAY” directory. This function configures a MSGOBJ for Normal Gateway Mode with a FIFO-Buffer as destination object: // initialize an existing object as source-object(obj), for an existing...
  • Page 56 Standalone TwinCAN Controller Using special features of the 82C900 The 82C900 does not provide the possibility to use a FIFO-Buffer as source object. So you need to use it only as destination-object. And it is also not possible to forward remote frames from the destination side to the source side.
  • Page 57: Power Saving Modes

    The 82C900 provides two different types of power-saving modes. If the 82C900 is in Sleep Mode, the TwinCAN, the SSC and the 8-Bit port logic are gated off. But the clock is still running. So it is possible to wake it up with a falling edge on /CS, /SLS or /RESET or with CAN messages on node A or B, if the bits CANAWU or CANBWU in CLKCTR are set.
  • Page 58 // set the 82C900 in the power down mode. void PowerDown(void) P_SendByte(CLKCTR,0x80); // set PWD in CLKCTR // this function configures the 82C900 for the sleep mode, and set // the wake up modes CANAWU(actA) and CANBWU(actB) void sleep(char actA, char actB) char cfg;...
  • Page 59 : / / w w w . i n f i n e o n . c o m Published by Infineon Technologies AG...

Table of Contents