我一直在玩这个,但没有效果。当生成事件时,它才生成。这就是为什么在处理事件之前我不检查ID的原因。我相信这是真的,因为第4452页的图片在OrthyYelHelp.PDF版本2.02V上回到了问题的症结,如果我只使用0x0作为掩码和过滤器,我会得到最低优先级的消息。我要找的是Mease0x10FFAAD2,所以我将过滤器设置为这个值。我把面具设为0x1FFF000,因为我想确定我没有在某个地方漏掉一些地址。对于这些设置,我从CAN中断中看不到任何东西。我想我会开始关注PLIB,但是为PLIB生成的和谐代码看起来很好:我知道的事情是:1)它是连接的,因为我可以通过0x0过滤器看到总线上的最低优先级消息。2)如果我把面罩/过滤器换成总线上的其他地址,它就不起作用了。我觉得这是一个平凡的细节,但我不知道会是什么。这种模式和它有什么关系吗?我只是在听留言,非常感谢您的建议。
以上来自于百度翻译
以下为原文
I've been playing around with this, but to no avail. When an event is generated, it's just generated. This is why I do not check for the ID until I handle the event. I believe this is true due to the image on page 4452 on version 2.02v of the harmony_help.pdf Back to the crux of the issue, if I just use 0x0 for the mask and filter, I get the lowest priority message. What I am looking for is message 0x10FFAAD2, so I set the filter to this value. I set the mask to 0x1FFFF000 because I wanted to be sure that I wasn't missing some address somewhere. For these settings, I see nothing from the CAN interrupt. I figured that I'd start to look at PLIB, but the Harmony code generated for PLIB looks pretty good:
void DRV_CAN0_Initialize(void)
{
/* Switch the CAN module ON */
PLIB_CAN_Enable(CAN_ID_1);
/* Switch the CAN module to Configuration mode. Wait until the switch is complete */
PLIB_CAN_OperationModeSelect(CAN_ID_1, CAN_CONFIGURATION_MODE);
while(PLIB_CAN_OperationModeGet(CAN_ID_1) != CAN_CONFIGURATION_MODE);
PLIB_CAN_PhaseSegment2LengthFreelyProgrammableEnable(CAN_ID_1);
//Set the Baud rate to 250 kbps
PLIB_CAN_PropagationTimeSegmentSet(CAN_ID_1, 1-1);
PLIB_CAN_PhaseSegment1LengthSet(CAN_ID_1, 3-1);
PLIB_CAN_PhaseSegment2LengthSet(CAN_ID_1, 3-1);
PLIB_CAN_SyncJumpWidthSet(CAN_ID_1, 1-1);
PLIB_CAN_BaudRatePrescaleSet(CAN_ID_1, 49); // set to 1 higher then ECAN tool
/* Assign the buffer area to the CAN module.
In this case assign enough memory for 2
channels, each with 8 message buffers.*/
PLIB_CAN_MemoryBufferAssign(CAN_ID_1, can_message_buffer0);
/* Configure CAN_ID_1 Channel for CAN_TX_RTR_DISABLED operation. Allocate 1 message buffer, and assign low medium priority for transmissions. */
PLIB_CAN_ChannelForTransmitSet(CAN_ID_1, CAN_CHANNEL0, 1, CAN_TX_RTR_DISABLED, CAN_LOW_MEDIUM_PRIORITY);
/* Configure CAN_ID_1 Channel for CAN_RX_FULL_RECEIVE operation. Allocate 1 message buffer, and assign low medium priority for transmissions. */
PLIB_CAN_ChannelForReceiveSet(CAN_ID_1, CAN_CHANNEL1, 1, CAN_RX_FULL_RECEIVE);
PLIB_CAN_FilterToChannelLink(CAN_ID_1, CAN_FILTER0, CAN_FILTER_MASK0, CAN_CHANNEL1);
PLIB_CAN_ChannelEventEnable(CAN_ID_1, CAN_CHANNEL1, CAN_RX_CHANNEL_NOT_EMPTY);
PLIB_CAN_FilterConfigure(CAN_ID_1, CAN_FILTER0, 0x10FFAAD2, CAN_EID);
PLIB_CAN_FilterEnable(CAN_ID_1, CAN_FILTER0);
PLIB_CAN_FilterMaskConfigure(CAN_ID_1, CAN_FILTER_MASK0, 0x1FFFF000, CAN_EID, CAN_FILTER_MASK_ANY_TYPE);
/* Switch the CAN module to Normal mode. Wait until the switch is complete */
PLIB_CAN_OperationModeSelect(CAN_ID_1, CAN_LISTEN_ALL_MESSAGES_MODE);
while(PLIB_CAN_OperationModeGet(CAN_ID_1) != CAN_LISTEN_ALL_MESSAGES_MODE);
PLIB_CAN_ModuleEventEnable(CAN_ID_1 , 0|CAN_All_EVENTS);
/* Setup CAN_ID_1 Interrupt */
PLIB_INT_SourceEnable(INT_ID_0,INT_SOURCE_CAN_1);
PLIB_INT_VectorPrioritySet(INT_ID_0,INT_VECTOR_CAN1, INT_PRIORITY_LEVEL3);
PLIB_INT_VectorSubPrioritySet(INT_ID_0,INT_VECTOR_CAN1, INT_SUBPRIORITY_LEVEL1);
}
The things that I know: 1) it's connected, as I can see the lowest priority message on the bus via the 0x0 filter. 2) I'm if I change the mask/filter to the other addresses on the bus, it doesn't work.
I feel that this is a mundane detail in the configuration, but I have no idea what that would be. Would the mode have something to do with it? I'm just listening to messages.
Any suggestions would be greatly appreciated.
我一直在玩这个,但没有效果。当生成事件时,它才生成。这就是为什么在处理事件之前我不检查ID的原因。我相信这是真的,因为第4452页的图片在OrthyYelHelp.PDF版本2.02V上回到了问题的症结,如果我只使用0x0作为掩码和过滤器,我会得到最低优先级的消息。我要找的是Mease0x10FFAAD2,所以我将过滤器设置为这个值。我把面具设为0x1FFF000,因为我想确定我没有在某个地方漏掉一些地址。对于这些设置,我从CAN中断中看不到任何东西。我想我会开始关注PLIB,但是为PLIB生成的和谐代码看起来很好:我知道的事情是:1)它是连接的,因为我可以通过0x0过滤器看到总线上的最低优先级消息。2)如果我把面罩/过滤器换成总线上的其他地址,它就不起作用了。我觉得这是一个平凡的细节,但我不知道会是什么。这种模式和它有什么关系吗?我只是在听留言,非常感谢您的建议。
以上来自于百度翻译
以下为原文
I've been playing around with this, but to no avail. When an event is generated, it's just generated. This is why I do not check for the ID until I handle the event. I believe this is true due to the image on page 4452 on version 2.02v of the harmony_help.pdf Back to the crux of the issue, if I just use 0x0 for the mask and filter, I get the lowest priority message. What I am looking for is message 0x10FFAAD2, so I set the filter to this value. I set the mask to 0x1FFFF000 because I wanted to be sure that I wasn't missing some address somewhere. For these settings, I see nothing from the CAN interrupt. I figured that I'd start to look at PLIB, but the Harmony code generated for PLIB looks pretty good:
void DRV_CAN0_Initialize(void)
{
/* Switch the CAN module ON */
PLIB_CAN_Enable(CAN_ID_1);
/* Switch the CAN module to Configuration mode. Wait until the switch is complete */
PLIB_CAN_OperationModeSelect(CAN_ID_1, CAN_CONFIGURATION_MODE);
while(PLIB_CAN_OperationModeGet(CAN_ID_1) != CAN_CONFIGURATION_MODE);
PLIB_CAN_PhaseSegment2LengthFreelyProgrammableEnable(CAN_ID_1);
//Set the Baud rate to 250 kbps
PLIB_CAN_PropagationTimeSegmentSet(CAN_ID_1, 1-1);
PLIB_CAN_PhaseSegment1LengthSet(CAN_ID_1, 3-1);
PLIB_CAN_PhaseSegment2LengthSet(CAN_ID_1, 3-1);
PLIB_CAN_SyncJumpWidthSet(CAN_ID_1, 1-1);
PLIB_CAN_BaudRatePrescaleSet(CAN_ID_1, 49); // set to 1 higher then ECAN tool
/* Assign the buffer area to the CAN module.
In this case assign enough memory for 2
channels, each with 8 message buffers.*/
PLIB_CAN_MemoryBufferAssign(CAN_ID_1, can_message_buffer0);
/* Configure CAN_ID_1 Channel for CAN_TX_RTR_DISABLED operation. Allocate 1 message buffer, and assign low medium priority for transmissions. */
PLIB_CAN_ChannelForTransmitSet(CAN_ID_1, CAN_CHANNEL0, 1, CAN_TX_RTR_DISABLED, CAN_LOW_MEDIUM_PRIORITY);
/* Configure CAN_ID_1 Channel for CAN_RX_FULL_RECEIVE operation. Allocate 1 message buffer, and assign low medium priority for transmissions. */
PLIB_CAN_ChannelForReceiveSet(CAN_ID_1, CAN_CHANNEL1, 1, CAN_RX_FULL_RECEIVE);
PLIB_CAN_FilterToChannelLink(CAN_ID_1, CAN_FILTER0, CAN_FILTER_MASK0, CAN_CHANNEL1);
PLIB_CAN_ChannelEventEnable(CAN_ID_1, CAN_CHANNEL1, CAN_RX_CHANNEL_NOT_EMPTY);
PLIB_CAN_FilterConfigure(CAN_ID_1, CAN_FILTER0, 0x10FFAAD2, CAN_EID);
PLIB_CAN_FilterEnable(CAN_ID_1, CAN_FILTER0);
PLIB_CAN_FilterMaskConfigure(CAN_ID_1, CAN_FILTER_MASK0, 0x1FFFF000, CAN_EID, CAN_FILTER_MASK_ANY_TYPE);
/* Switch the CAN module to Normal mode. Wait until the switch is complete */
PLIB_CAN_OperationModeSelect(CAN_ID_1, CAN_LISTEN_ALL_MESSAGES_MODE);
while(PLIB_CAN_OperationModeGet(CAN_ID_1) != CAN_LISTEN_ALL_MESSAGES_MODE);
PLIB_CAN_ModuleEventEnable(CAN_ID_1 , 0|CAN_All_EVENTS);
/* Setup CAN_ID_1 Interrupt */
PLIB_INT_SourceEnable(INT_ID_0,INT_SOURCE_CAN_1);
PLIB_INT_VectorPrioritySet(INT_ID_0,INT_VECTOR_CAN1, INT_PRIORITY_LEVEL3);
PLIB_INT_VectorSubPrioritySet(INT_ID_0,INT_VECTOR_CAN1, INT_SUBPRIORITY_LEVEL1);
}
The things that I know: 1) it's connected, as I can see the lowest priority message on the bus via the 0x0 filter. 2) I'm if I change the mask/filter to the other addresses on the bus, it doesn't work.
I feel that this is a mundane detail in the configuration, but I have no idea what that would be. Would the mode have something to do with it? I'm just listening to messages.
Any suggestions would be greatly appreciated.
举报