CAN消息读取错误

时间:2014-02-17 19:46:11

标签: microcontroller can-bus

我正在使用Infineon XC2768X microcontroller。问题出在if语句的行。 'uwspeed'是我从外部CAN总线接收的电机速度。当代码到达此行时,它不会打开LED P10_6和P10_7。我该如何解决这个问题?

void read_Motorspeed () {
    stCAN_SWObj SW_obj1;
    ubyte i;
    ADC0_vStartSeq0ReqChNum(0,0,0,0);
    uwbesch = ADC0_uwGetResultData(RESULT_REG_0); //Read gaspedal
    CAN_vReleaseObj(1);
    CAN_vGetMsgObj(1, &SW_obj1);
    uwspeed1 = SW_obj1.ubData[0]; //Receiving high byte
    uwspeed2 = SW_obj1.ubData[1]; //Receiving low byte
    IO_vSetPin(IO_P10_8);         //Initially motor is series connected by pin 10.8

    if((uwspeed1 < 0x0b && IO_P10_8 == 1)) { //If the speed is less than 0x0b and series connected
        IO_vResetPin(IO_P10_8); //Disconnect series
        IO_vSetPin(IO_P10_6);   //Here pin 10.6 is on
        IO_vSetPin(IO_P10_7);   //Here pin 10.7 is on
        CAN_MODATA3LL = 0x00;   //Send 0 torque to hybrid kit
        CAN_vTransmit(3);
    }

0 个答案:

没有答案