Hi,
I'm currently trying to debug the CAN frame receive by polling mode on stellaris launchpad.
Here below are my source code:
//Can Init:
void vCanInit(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB4_CAN0RX);
GPIOPinConfigure(GPIO_PB5_CAN0TX);
GPIOPinTypeCAN(CAN0_BASE, GPIO_PIN_4 | GPIO_PIN_5);
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
CANInit(CAN0_BASE);
CANBitRateSet(CAN0_BASE, SysCtlClockGet(), 500000);
CANEnable(CAN0_BASE);
}
// receive frame
void vReceiveFrame(void)
{
static uint32_t u32ActiveObjectsCANTemp = 0;
tCANMsgObject sCANMessageRx;
if(u32ActiveObjectsCANTemp == 0)
{
u32ActiveObjectsCANTemp = (CANStatusGet(CAN0_BASE, CAN_STS_NEWDAT)); //Issue
u32ActiveObjectsCANTemp = u32ActiveObjectsCANTemp & u32RXLowPrioFlags;
}
if(u32ActiveObjectsCANTemp!=0)
{
CANMessageGet(CAN0_BASE,1,&sCANMessageRx,false);
u32ActiveObjectsCANTemp =0; //Delete Message Object Flag
}
}
I used the CANStatusGet(CAN0_BASE, CAN_STS_NEWDAT) to judge if there is any new frame received and indeed when I simulate to send a frame from PCAN to launchpad, the bit CAN_STS_NEWDAT will be set.
However, it can not be cleared after I receive the frame. How can I clear this bit?
Thanks.