dsPIC33EP_CAN_RXTX project after moments don't read more mex

General discussion on mikroC PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
deltaprog
Posts: 23
Joined: 29 Sep 2014 11:00

dsPIC33EP_CAN_RXTX project after moments don't read more mex

#1 Post by deltaprog » 17 Apr 2015 15:09

Hi All,
in the example project dsPIC33EP_CAN_RXTX, the CAN communication work fine but only for a little time.
The Tx communication work properly ever, but the Rx communication after a little time stop the read CAN message (the led stop of blink).

I try to send from PC to PIC three CAN message (200h at 10ms, 311h at 20ms and 420h at 30ms), [I need to update data very often.]
and so, initially work good and after fews moments the PIC don't read more message. The Tx continue to work fine.

Maybe, there is a buffer that fills? How can I do?

Thanks.
Attachments
dsPIC33EP_CAN_RXTX.zip
Example project (found on Internet)
(226.09 KiB) Downloaded 110 times

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: dsPIC33EP_CAN_RXTX project after moments don't read more

#2 Post by marina.petrovic » 20 Apr 2015 14:09

Hi,

Please, can you try to use ECAN1Read() routine outside the interrupt routine to see whether you have the same behavior in that situation?

Also you can try to increase ECAN1RAMBUFFERSIZE buffer on 32?

Whether you test this project in debug mode to see in which moment problem occurs?

Best regards,
Marina

deltaprog
Posts: 23
Joined: 29 Sep 2014 11:00

Re: dsPIC33EP_CAN_RXTX project after moments don't read more

#3 Post by deltaprog » 20 Apr 2015 15:36

Thank you Marina for the response.
marina.petrovic wrote: Please, can you try to use ECAN1Read() routine outside the interrupt routine to see whether you have the same behavior in that situation?
Now I write the while cycle as follow (attachment project):

Code: Select all

 while(1)
 {
  LATD.B1 ^=1;  // Blink Led RD1
  TemperatureRaw = ADC1_Get_Sample(0);  // read LM35 Voltage
  CanWrite();   // Write CAN messages
  Msg_Rcvd = ECAN1Read(&RxID,RxData,&RxDataLen,&Can_Rcv_Flags);
  if(Msg_Rcvd!=0)
  {
    switch (RxID)
   {
     case 0x200 :
     LATD.B2 ^=1;   // Blink Led RD2
     break;
     case 0x311:
     LATD.B3 ^=1;  // Blink Led RD3
     break;
     case 0x420 :
     LATD.B4 ^=1;  // Blink Led RD4
     break;
   }// end switch case
  }
  Delay_ms(1); // Reduced from 50 to 1
 }
}
but I have the same problem.
marina.petrovic wrote: Also you can try to increase ECAN1RAMBUFFERSIZE buffer on 32?
I set

Code: Select all

#define ECAN1RAMBUFFERSIZE 32
but the result is the same.

Where I found the program with CAN communication that work fine?
Have you another suggestion?
Attachments
dsPIC33EP_CAN_RXTX.zip
In this version I put ECAN1Read in while cycle and I reduce delay from 50 to 1.
(224.69 KiB) Downloaded 99 times

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: dsPIC33EP_CAN_RXTX project after moments don't read more

#4 Post by marina.petrovic » 21 Apr 2015 10:38

Hi,

Please, take a look at this example from LibStock Website:
http://www.libstock.com/projects/view/985/can-dspic33ep

Best regards,
Marina

deltaprog
Posts: 23
Joined: 29 Sep 2014 11:00

Re: dsPIC33EP_CAN_RXTX project after moments don't read more

#5 Post by deltaprog » 21 Apr 2015 14:54

marina.petrovic wrote:Hi,

Please, take a look at this example from LibStock Website:
http://www.libstock.com/projects/view/985/can-dspic33ep

Best regards,
Marina
Thank you Marina,
I had already tryed with this example and it works good but only if I send messages at 100ms or more.
I need a message with a frequency of about 10 ms. In this example and with these frequency, the communication stop after a few seconds.

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: dsPIC33EP_CAN_RXTX project after moments don't read more

#6 Post by marina.petrovic » 23 Apr 2015 08:32

Hi,

Maybe you need to have some additional settings/adjustments in your code (maybe you can find some additional explanation
in MCU datasheet or errata).

You can use CANculator to check settings of the baud rate and other parameters:
http://www.libstock.com/projects/view/360/canculator

Best regards,
Marina

Post Reply

Return to “mikroC PRO for dsPIC30/33 and PIC24 General”