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.
dsPIC33EP_CAN_RXTX project after moments don't read more mex
dsPIC33EP_CAN_RXTX project after moments don't read more mex
- Attachments
-
- dsPIC33EP_CAN_RXTX.zip
- Example project (found on Internet)
- (226.09 KiB) Downloaded 110 times
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: dsPIC33EP_CAN_RXTX project after moments don't read more
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
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
Re: dsPIC33EP_CAN_RXTX project after moments don't read more
Thank you Marina for the response.
but I have the same problem.
but the result is the same.
Where I found the program with CAN communication that work fine?
Have you another suggestion?
Now I write the while cycle as follow (attachment project):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?
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
}
}
I setmarina.petrovic wrote: Also you can try to increase ECAN1RAMBUFFERSIZE buffer on 32?
Code: Select all
#define ECAN1RAMBUFFERSIZE 32
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
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: dsPIC33EP_CAN_RXTX project after moments don't read more
Hi,
Please, take a look at this example from LibStock Website:
http://www.libstock.com/projects/view/985/can-dspic33ep
Best regards,
Marina
Please, take a look at this example from LibStock Website:
http://www.libstock.com/projects/view/985/can-dspic33ep
Best regards,
Marina
Re: dsPIC33EP_CAN_RXTX project after moments don't read more
Thank you Marina,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
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.
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: dsPIC33EP_CAN_RXTX project after moments don't read more
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
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