The questions that I have are:stevevp wrote:Firstly you have to open up the receive buffers to allow all can message in
in CanInit()then the interrupt routine needs to handle MSG_STDCode: Select all
/* Set identifier acceptance and mask registers to accept 11 and 29 bit messages from all devices */ CANIDMR0 = 0xFF; // anything ok in IDR0(var offset) CANIDMR1 = 0xFF; //was 0xE7; // anything ok for var_off cont'd, msgtype CANIDMR2 = 0xFF; //was 0xF0; // can be from any other device CANIDMR3 = 0xFF; // any var_blk, spare, rtr CANIDAR1 = 0x00; //was 0x18; // 0,0,0,SRR=IDE=1 CANIDAR2 = 0x00; //was can_id; // rcv msg must be to can_id, but now accepts any /* 2nd 32-bit filter bank */ CANIDMR4 = 0xFF; // anything ok in IDR0(var offset) CANIDMR5 = 0xFF; //0xE7; // anything ok for var_off cont'd, msgtype CANIDMR6 = 0xFF; //0xF0; // can be from any other device CANIDMR7 = 0xFF; // any var_blk, spare, rtr CANIDAR5 = 0x00; //0x18; // 0,0,0,SRR=IDE=1 CANIDAR6 = 0x00; //0x0F; // rcv msg can be to everyone (id=15), and
in CanRxIsr()then we need to process the STD 11 bit messageCode: Select all
if([b]CAN0RFLG[/b] & 0x01) { var_off = ((unsigned short)CAN0_RB_IDR0 << 3) | (([b]CAN0_RB_IDR1[/b] & 0xE0) >> 5); [b] msg_IDE[/b] = [b](CAN0_RB_IDR1 & 0x08);[/b] msg_type = MSG_CMD; if (msg_IDE) { if ((CAN0_RB_DLR & 0x0F)==15){// &0x0F = 00001111, get first 4 bits msg_type = (CAN0_RB_IDR1 & 0x07); } } else { msg_type = MSG_STD; } rcv_id = [b]CAN0_RB_IDR2[/b] >> 4; // message from device rcv_id var_blk = [b]CAN0_RB_IDR3[/b] >> 4; var_byt = ([b]CAN0_RB_DLR[/b] & 0x0F); // &0x0F = 00001111, get first 4 bits switch(msg_type) { case MSG_STD: // message to be processed msgID = ([b]CAN0_RB_IDR0[/b] << 3); msgID = msgID + ([b]CAN0_RB_IDR1[/b] >> 5); // 8 high bits in IDR0, 3 low bits in IDR1 // update variable value with received data data[0] = CAN0_RB_DSR0; //Changed to add the "0". For ex: CAN_RB_DSR0 changed to CAN0_RB_DSR0 data[1] = CAN0_RB_DSR1; data[2] = CAN0_RB_DSR2; data[3] = CAN0_RB_DSR3; data[4] = CAN0_RB_DSR4; data[5] = CAN0_RB_DSR5; data[6] = CAN0_RB_DSR6; data[7] = CAN0_RB_DSR7; STD11_receive_CAN(msgID,data,var_byt,MSG_STD) ; case MSG_CMD: // message for this ecu to set a variable to value in message break;
Code: Select all
void STD11_receive_CAN(unsigned int Rx_id, unsigned char *Rx_data, unsigned char Rx_dataLen, unsigned char flags) { // Receive Message Variables // unsigned int Rx_id; // unsigned char Rx_data[8]; // unsigned char Rx_dataLen; // enable the following for debug if required // ECANSendMessage(Rx_id+1, Rx_data, Rx_dataLen, MSG_STD); if (flags == MSG_STD) { flags = MSG_STD; } if (Rx_id == 0x4B0) // ID of ABS wheel speed sensors. Byte 0,1 = LF; 2,3 = RF; 4,5 = RR; 6,7 = LR { [b]datax1.vss1_16 = (((Rx_data[0]) /100) /256);[/b] }
1. Where to put data coming from abs computer? I think this might be pulsed data, but not sure. If I read correctly, James said that remote vss information should be in one of four fields: datax1.vss1_16, datax1_8, datax1.pwm32, or datax1.pwm16, but which field?
2. Does the code look correct? I am fairly certain that it is correct, I just made some minor adjustments to work for MS3. The problem that I have is when I load the firmware, then turn off and on the MS3, I get a settings error on TunerStudio, followed by TS going offline. I try to reload firmware the normal way, but have to bootjump to load. I think this might be caused by me not knowing where to properly store the incoming CAN data. Thanks guys for your help. I really appreciate all you do!