Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: SN65HVD230, EK-TM4C123GXL, SYSCONFIG
I currently have the launchpad connected to a WaveShare CAN device stuck in a breadboard. It seems to have a 120 ohm resistor on it and the other 120ohm resistor is on the other side of the cable. The other end of the cable is plugged into a PEAK USB to CAN adapter. Both sides are setup at 500k and I use the cansend command on my PC to send 123#DEADBEEF. However upon hearing this the TM4C begins repeating as fast as it can: "CAN interrupt 0x8000 0x65" I think indicating that there was a Bit 0 error.
Searching around I found:
Check your resistors - Good, pretty sure
Check your bitrates - Good
Scope CANH and CANRX - Both can be decoded by my scope
Does anyone have any ideas?
This is my CAN code in it's entirety right now. The pin setup is done by pinmux.
#include <stdbool.h>
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/hal/Hwi.h>
#include <inc/hw_memmap.h>
#include <inc/hw_ints.h>
#include <inc/hw_can.h>
#include <driverlib/can.h>
#include <driverlib/interrupt.h>
#include <driverlib/sysctl.h>
#include "candrv.h"
#define CAN0RXID 0
#define RXOBJECT 1
static tCANMsgObject RxMessage;
static uint8_t RxMsgData[8];
void CanDriverHwiHandler(UArg a0)
{
uint32_t status;
uint32_t errStatus = 0;
System_printf("CAN HWI Handler called\n");
System_flush();
status = CANIntStatus(CAN0_BASE, CAN_INT_STS_CAUSE);
if (status == CAN_INT_INTID_STATUS)
{
errStatus = CANStatusGet(CAN0_BASE, CAN_STS_CONTROL);
}
CANIntClear(CAN0_BASE, status);
System_printf("CAN interrupt 0x%x 0x%x\n", status, errStatus);
System_flush();
}
void CreateRtosPrimitives()
{
Hwi_Handle hwi;
Error_Block eb;
Error_init(&eb);
hwi = Hwi_create(INT_CAN0, CanDriverHwiHandler, NULL, &eb);
if (hwi == NULL)
{
System_abort("Can't create HWI for CAN\n");
}
System_printf("Successfully Created primitives for CAN\n");
System_flush();
}
void InitCanDriver()
{
CreateRtosPrimitives();
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
CANInit(CAN0_BASE);
CANBitRateSet(CAN0_BASE, SysCtlClockGet(), 500000);
CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
CANEnable(CAN0_BASE);
System_printf("CAN0 Enabled\n");
System_flush();
RxMessage.ui32MsgID = CAN0RXID;
RxMessage.ui32MsgIDMask = 0;
RxMessage.ui32Flags = MSG_OBJ_RX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER;
RxMessage.ui32MsgLen = sizeof(RxMsgData);
RxMessage.pui8MsgData = RxMsgData;
CANMessageSet(CAN0_BASE, RXOBJECT, &RxMessage, MSG_OBJ_TYPE_RX);
}
