![Infineon 82C900 Скачать руководство пользователя страница 46](http://html1.mh-extra.com/html/infineon/82c900/82c900_application-note_2055171046.webp)
AP29002
Standalone TwinCAN Controller
Using special features of the 82C900
Application Note
45
V 1.0, 2004-02
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); // set bit CCE in ACR
SSC_SendByte(ABTR,0x17); // set SJW=1, BRP=17
SSC_SendByte(ABTR+1,0x23); //set DIV8X=0,TSEG2=3,TSEG1=4
SSC_SendByte(AIMR0,0x01);// take IMC0 into acount for INTID generation
SSC_SendByte(ACR,0x00); // clear INIT, CCE in ACR
}
// configures MSGOBJ(obj_nr) for node with the direction dir, id and
// by_nr data bytes
void SSC_init_MSG(int node, int obj_nr, int dir, int by_nr, int id)
{
unsigned char cfg=0x00;
SSC_SendByte(MSG_OBJ_BASE(MSGCTRn, 0x55);
SSC_SendByte(MSG_OBJ_BASE(1, 0x55);
if( 1 == node) cfg |= 0x02; // node B(node='1')
if( 1 == dir) cfg |= 0x08; // transmitobject(dir='1')
cfg |= by_nr<<4;
// number of bytes(by_nr)
SSC_SendByte(MSG_OBJ_BASE(MSGCFGn, cfg);// send configuration
SSC_SendByte(MSG_OBJ_BASE(2, id<<2);// set ID(id)
SSC_SendByte(MSG_OBJ_BASE(MSGCTRn, 0xBF); // MSG valite
}