Hi Everyone, I have 3 controllers, all using SILABS C8051F040 SOC. They perfrom various functions on there own and communicate via CAN. They are working well together (I fixed one major problem I will detail further down). The transmission of data is handled by configuring message boxes on the fly and transmitting them and works well. The reception is handled by an interupt routine activated by a message that passes the arbritation filters. When the interupt routine is called, it calls a function I named cancieve(). Here is a sample of the beggining of one conrollers cancieve function
xdata unsigned int rx_buff[4]; xdata union { float floater; unsigned long int longinter; unsigned char string[4]; unsigned long int mscounter; unsigned int interger[2]; } float_char; unsigned char org_msgnum; unsigned char PRI_LEV; org_msgnum= CAN_sep_ident(CAN_receive_data (msg_number, rx_buff), &PRI_LEV); if ((PRI_LEV==7)&&(org_msgnum==5)) { exc_noCAN_cntr=0; //reset exciter no value counter float_char.interger[0]=rx_buff[0]; float_char.interger[1]=rx_buff[1]; EXC_STATUS1=float_char.string[0]; EXC_STATUS2=float_char.string[1]; return; }
bdata unsigned char EXC_STATUS3; sbit I_LEAD_OV =EXC_STATUS3^0; //current lead over voltage sbit RECIRC_DIODE_OT=EXC_STATUS3^1; //re-circulating diode over temp sbit ABORT_RES_OT =EXC_STATUS3^2; //dump resistor over temp sbit ABORT_IGBT_OT =EXC_STATUS3^3; sbit AMB_TEMP_OT =EXC_STATUS3^5; sbit SHNTFLT_SOFT =EXC_STATUS3^6; sbit SYS_HEARTBEET =EXC_STATUS3^7;
volatile unsigned char bdata EXC_STATUS3; sbit I_LEAD_OV =EXC_STATUS3^0; //current lead over voltage sbit RECIRC_DIODE_OT=EXC_STATUS3^1; //re-circulating diode over temp sbit ABORT_RES_OT =EXC_STATUS3^2; //dump resistor over temp sbit ABORT_IGBT_OT =EXC_STATUS3^3; sbit AMB_TEMP_OT =EXC_STATUS3^5; sbit SHNTFLT_SOFT =EXC_STATUS3^6; sbit SYS_HEARTBEET =EXC_STATUS3^7;