Part Number: TM4C1294NCPDT
Tool/software: Code Composer Studio
Hi All,
I am using TM4C1294NCPDT micro controller for my new development, In this I am using timer, I2C, UART and other peripheral's well.
Now I want to CAN module establishment communication with my salve board, for this I try to use CAN0 module with PA0, PA1.
I am new to CAN module one.
I wrote code with example studied in online. I think the data transmission not working properly.
Screen shots attached below and I pasted my code below. Interrupt handler working fine I think
unsigned char can_tx_buff[100];
int main(void)
{
SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_CAN0RX);
GPIOPinConfigure(GPIO_PA1_CAN0TX);
GPIOPinTypeCAN(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
CANInit(CAN0_BASE);
CANBitRateSet(CAN0_BASE, SysCtlClockGet(), 500000);
CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
IntEnable(INT_CAN0);
CANEnable(CAN0_BASE);
tCANMsgObject sCANMessage;
uint8_t *pui8MsgData;
can_tx_buff[0] = 11;
can_tx_buff[1] = 0x0f;
can_tx_buff[2] = 0;
can_tx_buff[3] = 0;
can_tx_buff[4] = 0;
can_tx_buff[5] = 0;
can_tx_buff[6] = 0;
can_tx_buff[7] = 1;
pui8MsgData = (uint8_t *)&can_tx_buff;
while(1)
{
sCANMessage.ui32MsgID = 1;
sCANMessage.ui32MsgIDMask = 0;
sCANMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
sCANMessage.ui32MsgLen = 8;
sCANMessage.pui8MsgData = pui8MsgData;
set.Spindle_Operating_Mode = 1;
/*machine Sequence*/
if(set.Spindle_Operating_Mode == 0)
{
//check_all_moto_stat();
//process_manual_oper();
CANMessageSet(CAN0_BASE, 1, &sCANMessage, MSG_OBJ_TYPE_TX);
}
// Now wait 1 second before continuing
SimpleDelay();
}
}
//*****************************************************************************
void CANIntHandler(void)
{
uint32_t ui32Status;
// Read the CAN interrupt status to find the cause of the interrupt
ui32Status = CANIntStatus(CAN0_BASE, CAN_INT_STS_CAUSE);
if(ui32Status == CAN_INT_INTID_STATUS)
{
ui32Status = CANStatusGet(CAN0_BASE, CAN_STS_CONTROL);
}
else if(ui32Status == 1)
{
CANIntClear(CAN0_BASE, 1);
}
else
{
// Spurious interrupt handling can go here.
}
}
Regards
Yuvaraj