Tool/software: Code Composer Studio
Hello!
I try to send can message from my TM4C microcontroler to NI can, but I can't receive can messages on NI can. Here is my program:
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/can.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
int main(void)
{
tCANMsgObject sMsgObjectTx;
uint8_t pui8BufferOut[8];
uint32_t ui32SysClock=SysCtlClockGet();
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//pin f3 config
GPIOPinConfigure(GPIO_PF3_CAN0TX);
GPIOPinTypeCAN(GPIO_PORTF_BASE, GPIO_PIN_3);
//pin f0 config
GPIOPinConfigure(GPIO_PF0_CAN0RX);
GPIOPinTypeCAN(GPIO_PORTF_BASE, GPIO_PIN_0);
//
// Enable the CAN0 module.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
//
// Wait for the CAN0 module to be ready.
//
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_CAN0))
{
}
//
// Enable the CAN1 module.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN1);
//
// Wait for the CAN1 module to be ready.
//
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_CAN1))
{
}
//
// Reset the state of all the message objects and the state of the CAN
// module to a known state.
//
CANInit(CAN0_BASE);
CANInit(CAN1_BASE);
//
// Configure the controller for 1 Mbit operation.
//
CANBitRateSet(CAN0_BASE, ui32SysClock, 1000000);
CANBitRateSet(CAN1_BASE, ui32SysClock, 1000000);
//
// Take the CAN0 and CAN1 device out of INIT state.
//
CANEnable(CAN0_BASE);
CANEnable(CAN1_BASE);
//
// Configure a receive object.
//
while(1)
{
sMsgObjectTx.ui32MsgID = 0x400;
sMsgObjectTx.ui32Flags = 0;
sMsgObjectTx.ui32MsgLen = 1;
sMsgObjectTx.pui8MsgData = pui8BufferOut;
CANMessageSet(CAN0_BASE, 2u, &sMsgObjectTx, MSG_OBJ_TYPE_TX);
}
}
And my settings in NI can:
What can be the problem?
Best Regards,
Gondos Andor
#include <stdbool.h>#include <stdint.h>#include "inc/hw_ints.h"#include "inc/hw_memmap.h"#include "inc/hw_types.h"#include "driverlib/sysctl.h"#include "driverlib/can.h"#include "driverlib/gpio.h"#include "driverlib/pin_map.h"
int main(void){//tCANMsgObject sMsgObjectRx;tCANMsgObject sMsgObjectTx;//uint8_t pui8BufferIn[8];uint8_t pui8BufferOut[8];uint32_t ui32SysClock=SysCtlClockGet();
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//pin f3 config GPIOPinConfigure(GPIO_PF3_CAN0TX); GPIOPinTypeCAN(GPIO_PORTF_BASE, GPIO_PIN_3);//pin f0 config GPIOPinConfigure(GPIO_PF0_CAN0RX); GPIOPinTypeCAN(GPIO_PORTF_BASE, GPIO_PIN_0);
//// Enable the CAN0 module.//SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);//// Wait for the CAN0 module to be ready.//while(!SysCtlPeripheralReady(SYSCTL_PERIPH_CAN0)){}//// Enable the CAN1 module.//SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN1);//// Wait for the CAN1 module to be ready.//while(!SysCtlPeripheralReady(SYSCTL_PERIPH_CAN1)){}//// Reset the state of all the message objects and the state of the CAN// module to a known state.//CANInit(CAN0_BASE);CANInit(CAN1_BASE);//// Configure the controller for 1 Mbit operation.//CANBitRateSet(CAN0_BASE, ui32SysClock, 1000000);CANBitRateSet(CAN1_BASE, ui32SysClock, 1000000);//// Take the CAN0 and CAN1 device out of INIT state.//CANEnable(CAN0_BASE);CANEnable(CAN1_BASE);//// Configure a receive object.///*sMsgObjectRx.ui32MsgID = 0x400;sMsgObjectRx.ui32MsgIDMask = 0x7f8u;sMsgObjectRx.ui32Flags = MSG_OBJ_USE_ID_FILTER;sMsgObjectRx.pui8MsgData = pui8BufferIn;CANMessageSet(CAN1_BASE, 4u, &sMsgObjectRx, MSG_OBJ_TYPE_RX);*///// Configure and start transmit of message object.//while(1){sMsgObjectTx.ui32MsgID = 0x400;sMsgObjectTx.ui32Flags = 0;sMsgObjectTx.ui32MsgLen = 1;sMsgObjectTx.pui8MsgData = pui8BufferOut;CANMessageSet(CAN0_BASE, 2u, &sMsgObjectTx, MSG_OBJ_TYPE_TX);}//// Wait for new data to become available by checking bit 4 (0x08u).///*while((CANStatusGet(CAN1_BASE, CAN_STS_NEWDAT) & 0x08u) == 0u){}//// Read the message out of the message object 4.//CANMessageGet(CAN1_BASE, 4u, &sMsgObjectRx, true);//// Process new data in sMsgObjectRx.pucMsgData.// * */
}