Part Number: LAUNCHXL-F28377S
Tool/software: TI C/C++ Compiler
Hi,
I spent two days to configure the CAN in RX mode. (TX mode works properly)
Bellow is my code base on examples (F2837xS v210).
What I am doing wrong,
I wil waiting for your answer
/*
* v1_main.c
*
* Created on: 21 lis 2017
* Author: Dariusz
*/
//###########################################################################
//
// FILE: can_moje_transmit.c
//
//! - CANA is on GPIO71 (CANTXA) and GPIO70 (CANRXA)
//
//!
//! \b Watch \b Variables \n
//! - TXCOUNT - Adjust to set the number of messages to be transmitted
//! - txMsgCount - A counter for the number of messages sent
//! - rxMsgCount - A counter for the number of messages received
//! - txMsgData - An array with the data being sent
//! - rxMsgData - An array with the data that was received
//! - errorFlag - A flag that indicates an error has occurred
//###########################################################################
//###########################################################################
//
// Included Files
//
#include "F28x_Project.h" // Device Headerfile and Examples Include File
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_can.h"
#include "driverlib/can.h"
//RX
unsigned char rxMsgData_103h[4];
tCANMsgObject sRXCANMessage_103h;
void main(void)
{
//
// Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
//
InitSysCtrl();
//
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
//
InitGpio();
//
// Setup GPIO pin mux for CAN-A TX/RX
//
GPIO_SetupPinMux(70, GPIO_MUX_CPU1, 5); //GPIO70 - CANRXA
GPIO_SetupPinOptions(70, GPIO_INPUT, GPIO_ASYNC);
GPIO_SetupPinMux(71, GPIO_MUX_CPU1, 5); //GPIO71 - CANTXA
GPIO_SetupPinOptions(71, GPIO_OUTPUT, GPIO_PUSHPULL);
//
// Initialize the CAN controllers
// CANInit(based adress of CAN)
CANInit(CANA_BASE);
//
//CANBitTimingSet(adress of CAN, points to the structure with the clock parameters (pClkParams))
//
//
// Setup CAN source clock. Select option
// CANClkSourceSelect(base adress of CAN, clock source) 0 - Selected CPU SYSCLKOUT
CANClkSourceSelect(CANA_BASE, 0); // 500kHz CAN-Clock
//
//Setup comunication parameters for CAN
// CANBitRateSet(base adress of CAN, clock freq for CAN in Hz, bit rate)
//250kb/s
CANBitRateSet(CANA_BASE, 200000000, 250000);
//
DINT;
//
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
//
InitPieCtrl();
//
// Disable CPU interrupts and clear all CPU interrupt flags
//
IER = 0x0000;
IFR = 0x0000;
// iniialization frame 103h
//frame_103h
sRXCANMessage_103h.ui32MsgID = 0x103; // either 11 or 29
sRXCANMessage_103h.ui32Flags = MSG_OBJ_RX_INT_ENABLE;
sRXCANMessage_103h.ui32MsgLen = sizeof(rxMsgData_103h);
sRXCANMessage_103h.pucMsgData = rxMsgData_103h;
CANEnable(CANA_BASE);
for(;;)
{
//Data from frame 103h
CANMessageSet(CANA_BASE,1, &sRXCANMessage_103h, MSG_OBJ_TYPE_RX);
}
} // end main
//
// End of File
//