![Infineon 82C900 Скачать руководство пользователя страница 37](http://html1.mh-extra.com/html/infineon/82c900/82c900_application-note_2055171037.webp)
AP29002
Standalone TwinCAN Controller
Using special features of the 82C900
Application Note
36
V 1.0, 2004-02
void init_NodeB(void)
{
P_SendByte(BCR,0x41); // set bit CCE in BCR
P_SendByte(BBTR,0x17);
// set BRP=0x17
P_SendByte(BBTR+1,0x23);// set DIV8X=0, TSEG2=3, TSEG1=4, SJW=1
P_SendByte(BIMR0,0x01); // take IMC0 into acount for INTID gen.
P_SendByte(BCR,0x00); // clear INIT, CCE in BCR
}
The next function can be used to configure a message object for the Shared-Gateway-
Mode:
// init the MSGOBJ obj_nr as shared gateway as descriped in the
// usersmanual
void init_shared_gateway( char obj_nr, char GDFC, char SRREN)
{
word cfg = 0x0500 |(obj_nr&0x1F);
// set MMC=’101’ and CANPTR to obj_nr
P_SendWord(MSG_OBJ_BASE(M2,cfg);
cfg = 0x0000; // reset FSIZE,IDC, DLCC
if(GDFC) cfg |= 0x0100;
// automatic transmission on destinationsite
if(SRREN) cfg |= 0x0200; // waiting on remoteframes
P_SendWord(MSG_OBJ_BASE(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.
init_NodeA();// init node A for 1 MBaute
init_NodeB();// init node B for 125KBaute
init_MSG(0,0,0,1,0x0001);//MSGOBJ0, node A, 1 Databyte, ID 1
init_shared_gateway( 0, 1,0);// enable shared gateway for OBJ0
init_MSG(1,1,0,1,0x0002);// MSGOBJ1, node B, 1 Databyte, ID 2
init_shared_gateway( 1, 1, 0);// enable gateway for OBJ1
while(1);
// USER CODE END
}