• AVR Freaks

AnsweredHot!CAN BUS Receiving again

Author
dobrosoft
Starting Member
  • Total Posts : 31
  • Reward points : 0
  • Joined: 2019/05/20 04:44:55
  • Location: 0
  • Status: offline
2019/10/22 10:35:09 (permalink)
0

CAN BUS Receiving again

Hello All. Can any help with next problem? From CAN BUS analyser I send data, PIC32MX Starter kit receives data, but repeatedly the same. From Analyser I send only one message, but I have lot of receiving the same message:
 
This is code:
 
channelEventRX = PLIB_CAN_ChannelEventGet(CAN_ID_1, CAN_CHANNEL1);
if((channelEventRX & (CAN_RX_CHANNEL_NOT_EMPTY | CAN_RX_CHANNEL_FULL)) != 0)
{
   // This means that either RX Channel 2 is not empty
   // or the Channel is full.
   receivedMsg = (CAN_RX_MSG_BUFFER *)PLIB_CAN_ReceivedMessageGet(CAN_ID_1, CAN_CHANNEL1);
   if(receivedMsg != NULL){
     DLC = receivedMsg->msgEID.data_length_code;
     ID = receivedMsg->msgSID.sid;
        if (ID != 0x00){
            if (receivedMsg->data[0]==0x05)
            {
               LED2On();
               SYS_CONSOLE_PRINT("\r\nPrislo 0x05");
            } else if (receivedMsg->data[0]==0x06){
               LED2Off();
               SYS_CONSOLE_PRINT("\r\nPrislo 0x06");
            }
         } 
     PLIB_CAN_ChannelUpdate(CAN_ID_1, CAN_CHANNEL1);
     }

}
#1
nigelwright7557
Super Member
  • Total Posts : 310
  • Reward points : 0
  • Joined: 2006/11/06 08:15:51
  • Location: 0
  • Status: offline
Re: CAN BUS Receiving again 2019/10/22 10:37:57 (permalink) ☼ Best Answerby dobrosoft 2019/10/22 10:44:17
0
If there is a receive error the transmitting end will keep on sending.
 
#2
dobrosoft
Starting Member
  • Total Posts : 31
  • Reward points : 0
  • Joined: 2019/05/20 04:44:55
  • Location: 0
  • Status: offline
Re: CAN BUS Receiving again 2019/10/22 10:46:00 (permalink)
0
but I get correct data. How to inform transceiver about it?
#3
laffelt
Super Member
  • Total Posts : 152
  • Reward points : 0
  • Joined: 2008/05/08 18:05:53
  • Location: 0
  • Status: offline
Re: CAN BUS Receiving again 2019/12/02 13:21:25 (permalink)
0
I had a similiar problem with the Harmony CAN code constantly informing my code that there was data in the receive buffer so I wound up having to write my own driver.
 
One important thing after successfully receiving a CAN packet is to increment the FIFO so the message is ignored. I am not sure how that works with the Harmony code but here is what I needed to do:
 
// increment the FIFO
C1FIFOCON1bits.UINC = 1;
 
Larry
#4
Paul PortSol
Super Member
  • Total Posts : 534
  • Reward points : 0
  • Joined: 2015/07/03 11:52:03
  • Location: Newfoundland, Canada
  • Status: offline
Re: CAN BUS Receiving again 2019/12/04 12:16:43 (permalink)
0
laffelt,
Possible to share your driver?
 
Paul
 
#5
Jetoleg
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/08/19 06:43:41
  • Location: 0
  • Status: offline
Re: CAN BUS Receiving again 2019/12/10 11:12:24 (permalink)
0
I have similar issue with PIC32MZ. Interrupt driven CAN driver practically unusable. Callback keep triggering on same data packet over and over. I resorted to disabling CAN interrupt and  just poll RX buffer for new data periodically on timer.
#6
Jump to:
© 2019 APG vNext Commercial Version 4.5