Content originally posted in LPCWare by rails on Thu Sep 08 02:36:20 MST 2011
Hey,
I am playing around with the LPC1769 CAN Bus at the moment, but somehow the only thing I get if I send Messages are Stuff Errors with Tolerate Dominant Bit Error. I use the "lpc17xx_can.h" as driver. What did I miss?
Here's the Code:
#include "lpc17xx_can.h"
int main ()
{
CAN_Init(LPC_CAN2, 125000);
// P0.4 and P0.5
PINSEL_CFG_Type PinCfg;
PinCfg.Funcnum = 2;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Portnum = 0;
PinCfg.Pinnum = 4;;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 5;
PINSEL_ConfigPin(&PinCfg);
CAN_PinCFG_Type can_pincfg;
can_pincfg.RD = CAN_RD2_P0_4;
can_pincfg.TD = CAN_TD2_P0_5;
CAN_MSG_Type can_msg;
can_msg.dataA[0] = 0xDE;
can_msg.dataA[1] = 0xAD;
can_msg.dataA[2] = 0xAA;
can_msg.dataA[3] = 0xAA;
can_msg.dataB[0] = 0x00;
can_msg.dataB[1] = 0x00;
can_msg.dataB[2] = 0xAA;
can_msg.dataB[3] = 0xAA;
can_msg.format = STD_ID_FORMAT;
can_msg.id = 100;
can_msg.len = 8;
can_msg.type = DATA_FRAME;
CAN_IRQCmd(LPC_CAN2, CANINT_TIE1, ENABLE);
CAN_SetAFMode(LPC_CANAF,CAN_AccOff);
//Enable CAN Interrupt
NVIC_EnableIRQ(CAN_IRQn);
int i;
while(1) {
CAN_SendMsg(LPC_CAN2, &can_msg);
for(i=0;i<10000000;i++){};
}
while(1){};
return 0;
}