This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
.syscfg文件中CAN配置:
can1.$name = "CAN"; can1.enableInterrupt = true; can1.interruptFlags = ["CAN_INT_ERROR","CAN_INT_IE0","CAN_INT_IE1","CAN_INT_STATUS"]; can1.interruptLine = ["CAN_GLOBAL_INT_CANINT0","CAN_GLOBAL_INT_CANINT1"]; can1.can.$assign = "CANA"; can1.can.can_rxPin.$assign = "GPIO30"; can1.can.can_txPin.$assign = "GPIO31";
生成borad.c文件中CAN初始化代码:
void CAN_init(){ //CAN initialization CAN_initModule(CAN_BASE); // 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(CAN_BASE, DEVICE_SYSCLK_FREQ, 500000, 20); // Enable CAN Interrupts CAN_enableInterrupt(CAN_BASE, CAN_INT_ERROR|CAN_INT_IE0,CAN_INT_IE1,CAN_INT_STATUS); CAN_enableGlobalInterrupt(CAN_BASE, CAN_GLOBAL_INT_CANINT0); CAN_enableGlobalInterrupt(CAN_BASE, CAN_GLOBAL_INT_CANINT1); }
C2000WARE中CAN_enableInterrupt原型:
static inline void CAN_enableInterrupt(uint32_t base, uint32_t intFlags);
Sysconfig生成的board.c文件与C2000WARE的CAN_enableInterrupt不对应。导致编译错误。
编译错误提示:
简单来说:
sysconfig生成的文件中,CAN_init部分实际生成:
CAN_enableInterrupt(CAN_BASE, CAN_INT_ERROR|CAN_INT_IE0,CAN_INT_IE1,CAN_INT_STATUS);
正确应该生成:
CAN_enableInterrupt(CAN_BASE, CAN_INT_ERROR | CAN_INT_IE0 | CAN_INT_IE1 | CAN_INT_STATUS);
更简单地说:就是中断标志应该用或("|")运算而不是使用逗号,使用逗号使一个参数变成了多个参数。
下面有一个关于如何将 C2000Ware/driverlib 支持添加到现有 SYS/BIOS 项目的教程:
https://e2e.ti.com/support/microcontrollers/c2000/f/c2000-microcontrollers-forum/989425/faq-how-do-i-use-c2000ware-files-in-a-sys-bios-project
创建 C2000Ware+SYS/BIOS 项目后,请按照本教程将 SysConfig 添加到现有项目:
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/910829/faq-how-do-i-add-sysconfig-support-pinmux-and-peripheral-initialization-to-an-existing-driverlib-project
我大体试了一下,并没有编译错误。
能否给出您的工程?