使用can_ex4_simple_transmit例程,仅仅改了引脚,接线正确,无法识别波特率,can总线一直不通是什么原因?
下面是程序:
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Defines
//
#define TXCOUNT 100000
#define MSG_DATA_LENGTH 8
#define TX_MSG_OBJ_ID 1
//
// Globals
//
volatile unsigned long i;
volatile uint32_t txMsgCount = 0;
uint16_t txMsgData[8];
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
// on module A
//
Device_initGPIO();
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXB);
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXB);
//
// Initialize the CAN controllers
//
CAN_initModule(CANB_BASE);
//
// Set up the CAN bus bit rate to 500kHz for each module
// Refer to the Driver Library User Guide for information on how to set
// tighter timing control. Additionally, consult the device data sheet
// for more information about the CAN module clocking.
//
CAN_setBitRate(CANB_BASE, DEVICE_SYSCLK_FREQ, 500000, 16);
//
// Initialize the transmit message object used for sending CAN messages.
// Message Object Parameters:
// CAN Module: A
// Message Object ID Number: 1
// Message Identifier: 0x95555555
// Message Frame: Extended
// Message Type: Transmit
// Message ID Mask: 0x0
// Message Object Flags: None
// Message Data Length: 4 Bytes
//
CAN_setupMessageObject(CANB_BASE, TX_MSG_OBJ_ID, 0x00000000,
CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_TX, 0,
CAN_MSG_OBJ_NO_FLAGS, MSG_DATA_LENGTH);
//
// Initialize the transmit message object data buffer to be sent
//
txMsgData[0] = 0x01;
txMsgData[1] = 0x23;
txMsgData[2] = 0x45;
txMsgData[3] = 0x67;
txMsgData[4] = 0x89;
txMsgData[5] = 0xAB;
txMsgData[6] = 0xCD;
txMsgData[7] = 0xEF;
//
// Start CAN module A operations
//
CAN_startModule(CANB_BASE);
//
// Transmit messages from CAN-A
//
while(1)
//
// Comment for infinite transmissions
//
//for(i = 0; i < TXCOUNT; i++)
//
{
CAN_sendMessage(CANB_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH, txMsgData);
//
// Poll TxOk bit in CAN_ES register to check completion of transmission
//
//while(((HWREGH(CANB_BASE + CAN_O_ES) & CAN_ES_TXOK)) != CAN_ES_TXOK)
{
}
DEVICE_DELAY_US(100000);
}
//
// Stop application
//
asm("ESTOP0");
}
//
// End of File
//
Susan Yang:
请您以附件形式上传图片,谢谢
运行该例程需要:
//! \b Hardware \b Required \n
//!- A C2000 board with CAN transceiver and another CAN node configured
//!for the same bit-rate to provide the ACK.您是否有使用CAN收发器以及另外的CAN节点?
,
zhao dongao:
您好,我是将dsp和usbcan模块进行相连的,使用对应的上位机发现无法匹配波特率,接收到的全是错误帧
,
zhao dongao:
我现在如果接地线连接后上位机能正常发送数据,但是加载了例程后就无法识别出波特率了,也无法发送数据,这是为什么?
,
Susan Yang:
如之前所说,该例程需要使用CAN收发器以及另外的CAN节点。该launchpad是集成了CAN收发器的
CAN Interface with integrated transceiver
您现在使用的是usbcan模块功能是使PC可以通过USB总线连接至CAN网络?
那这样的话,连接是没有问题的。
请问您现在修改的是什么引脚?是下面的引脚?
#define DEVICE_GPIO_CFG_CANRXB GPIO_10_CANRXB // "pinConfig" for CANB RX
#define DEVICE_GPIO_CFG_CANTXB GPIO_8_CANTXB // "pinConfig" for CANB TX
您可以看一下launchpad的原理图,是包含了 SN65HVD234DR CAN收发器的。但请记住,在启动板上您将只能使用一个CAN模块(即CANB)。
您需要使用下面的引脚,也就是说,您需要预定义_LAUNCHXL_F28379D
#define DEVICE_GPIO_CFG_CANRXBGPIO_17_CANRXB// "pinConfig" for CANB RX #define DEVICE_GPIO_CFG_CANTXBGPIO_12_CANTXB// "pinConfig" for CANB TX// // GPIO assignment for CAN-A and CAN-B // #ifdef _LAUNCHXL_F28379D #define DEVICE_GPIO_CFG_CANRXAGPIO_36_CANRXA// "pinConfig" for CANA RX #define DEVICE_GPIO_CFG_CANTXAGPIO_37_CANTXA// "pinConfig" for CANA TX #define DEVICE_GPIO_CFG_CANRXBGPIO_17_CANRXB// "pinConfig" for CANB RX #define DEVICE_GPIO_CFG_CANTXBGPIO_12_CANTXB// "pinConfig" for CANB TX #else #define DEVICE_GPIO_CFG_CANRXAGPIO_30_CANRXA// "pinConfig" for CANA RX #define DEVICE_GPIO_CFG_CANTXAGPIO_31_CANTXA// "pinConfig" for CANA TX #define DEVICE_GPIO_CFG_CANRXBGPIO_10_CANRXB// "pinConfig" for CANB RX #define DEVICE_GPIO_CFG_CANTXBGPIO_8_CANTXB// "pinConfig" for CANB TX