How to set two can for LPC1778

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set two can for LPC1778

704 Views
1668834026
Contributor I

一个关于CAN设置硬件过滤ID的问题,目前CAN1、CAN2都设置相同的组扩展过滤,会出现收不到数据的情况。

组扩展标识符表设置如下。
/* The table of ranges of Extended Identifiers must contain an even number of entries */
CAN_EXT_ID_RANGE_ENTRY_T EffGrpSection[] =
{
    {{0, 0x100}, {0, 0x120}},
    {{0, 0x00F00400}, {0, 0x1CF004FF}},
    {{1, 0x100}, {1, 0x120}},
    {{1, 0x00F00400}, {1, 0x1CF004FF}}
};只设置一路CAN过滤ID的话,没有问题
看数据手册里面没有找到相关的说明,测试如果两路CAN设置不同的过滤ID是能正常接收数据帧,请问我设置LPC1778两路CAN组扩展标识符相同怎么设置,我查看库函数貌似不支持这样的设置。

Labels (1)
0 Kudos
2 Replies

616 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Zhou,

The CAN is a bus architecture, one CAN bus supports multiple nodes, from CAN protocol, it supports broadcast mode, in other words, one CAN node can transmit frame, multiple CAN nodes can receive the same CAN frame, no problem.

But if you configure the CAN0 and CAN1 of the same LPC1778  to receive the same frame by setting up the same receiving ID, in the case, when both CAN0/1 receive the same frame, both CAN0 and CAN1 interrupt will be triggered almost simultaneously, probably it has problem. BTW, why do you set up both CAN0 and CAN1 receive the same frame?

BR

XiangJun Rong

0 Kudos

616 Views
1668834026
Contributor I

Hi,rong,

      Both CAN0 and CAN1 not use two at the same time, and CAN1 interface is used as reserve. I want to archieve the function that both CAN receice the same frame, and how to do?

           Function of SDK not support the setting, and SDK make a protect for frame. But I can am not receiving data after removing the protection. The following is a library function.

   

STATIC Status setupEXTSection(uint32_t *pCANAFRamAddr, CAN_EXT_ID_ENTRY_T *pExtCANSec, uint16_t EntryNum)
{
uint16_t i;
uint32_t CurID = 0;
uint32_t Entry;
uint16_t EntryCnt = 0;

/* Setup FullCAN section */
for (i = 0; i < EntryNum; i++) {
if (CurID > pExtCANSec[i].ID_29) {   //Ascending protection
return ERROR;
}
CurID = pExtCANSec[i].ID_29;
Entry = createExtIDEntry(&pExtCANSec[i]);
pCANAFRamAddr[EntryCnt] = Entry;
EntryCnt++;
}
return SUCCESS;

}
/* Setup Group Extended ID section */
STATIC Status setupEXTRangeSection(uint32_t *pCANAFRamAddr,
CAN_EXT_ID_RANGE_ENTRY_T *pExtRangeCANSec,
uint16_t EntryNum)
{
return setupEXTSection(pCANAFRamAddr, (CAN_EXT_ID_ENTRY_T *) pExtRangeCANSec, EntryNum * 2);
}

CAN Acceptance filter:

pastedImage_1.png

write data:

CAN_EXT_ID_RANGE_ENTRY_T EffGrpSection[] = {
{{CAN_CTRL_NO, ((1 << 11) | 0x300)}, {CAN_CTRL_NO, ((1 << 11) | 0x400)}},
{{CAN_CTRL_NO, ((1 << 11) | 0x500)}, {CAN_CTRL_NO, ((1 << 11) | 0x600)}},
{{CAN_CTRL_NO, ((1 << 11) | 0x700)}, {CAN_CTRL_NO, ((1 << 11) | 0x780)}},

{{1, ((1 << 11) | 0x300)}, {1, ((1 << 11) | 0x400)}},
{{1, ((1 << 11) | 0x500)}, {1, ((1 << 11) | 0x600)}},
{{1, ((1 << 11) | 0x700)}, {1, ((1 << 11) | 0x780)}},
};

0 Kudos