Hi!
I'm try to use the ECAN Module on a dsPIC33EV256GM104 but i run into several problems.
First, it seems the ECAN Lib has changed from other dsPIC33 MCUs.
* The ECAN1DAMChannelInit command only accepts two parameters, not 3. The memory parameter is missing.
In the samples and documentation is written: ECAN1DmaChannelInit(0, 1, @ECAN1RxTxRAMBuffer);
but the compiler only accepts: ECAN1DmaChannelInit(0, 1);
in my code it ended up now as follow:
ECAN1DmaChannelInit(0, 1); // , @ECAN1RxTxRAMBuffer); // init dma channel 0 for
// dma to ECAN peripheral transfer
ECAN1DmaChannelInit(2, 0); //, @ECAN1RxTxRAMBuffer); // init dma channel 2 for
// ECAN peripheral to dma transfer
* I cannot send XTD Messages to the CAN BUS even when the _ECAN_TX_XTD_FRAME flag is cleared
Here the sniplets of my code:
Can_Send_Flags := _ECAN_TX_PRIORITY_0 and // form value to be used
_ECAN_TX_XTD_FRAME and // with CANSendMessage
_ECAN_TX_NO_RTR_FRAME;
ECAN1Write($1234, RxTx_Data, 8, Can_Send_Flags); ----> on the CAN Sniffer the Message appears with CANID $234
* I cannot receive anything. Even in the loopback and listen_all mode?
I set the MASK and Filters like i did in a other project (on a dsPIC33EP...), but it will not work at all.
This is my last attempt to set all MASKs and Filters to accept every message.
ECAN1SetMask(_ECAN_MASK_0, 0, _ECAN_CONFIG_ALL_VALID_MSG); // set all mask1 bits to ones
ECAN1SetMask(_ECAN_MASK_1, 0, _ECAN_CONFIG_MATCH_MSG_TYPE and _ECAN_CONFIG_XTD_MSG); // set all mask2 bits to ones
ECAN1SetMask(_ECAN_MASK_2, 0, _ECAN_CONFIG_MATCH_MSG_TYPE and _ECAN_CONFIG_STD_MSG); // set all mask3 bits to ones
ECAN1SetFilter(_ECAN_RX_FILTER_0, -1, _ECAN_MASK_2, _ECAN_RX_BUFFER_7, _ECAN_CONFIG_STD_MSG); // set id of filter10 to 2nd node ID
I even noticed that the _ECAN_FILTER_x canged to _ECAN_RX_Filter?
Msg_Rcvd := ECAN1Read(Rx_ID , RxTx_Data , Rx_Data_Len); ---> Msg_Rcvd stays at 0.
No idea how to setup everything correct?!
Is there any (new) sample or documentation how to work with the ECAN Module on the dsPIC33EV... series?
Thank you,
Christian
ECAN on dsPIC33EV256GM104, no XTD Messages, no Receive
- petar.suknjaja
- mikroElektronika team
- Posts: 683
- Joined: 05 Mar 2018 09:44
- Location: Belgrade
Re: ECAN on dsPIC33EV256GM104, no XTD Messages, no Receive
Hi,
Have you read the following datasheet regarding the ECAN in dsPIC33?
http://ww1.microchip.com/downloads/en/D ... 70353C.pdf
Can you attach your zipped project files so we could review it?
Kind regards,
Petar
Have you read the following datasheet regarding the ECAN in dsPIC33?
http://ww1.microchip.com/downloads/en/D ... 70353C.pdf
Can you attach your zipped project files so we could review it?
Kind regards,
Petar
Re: ECAN on dsPIC33EV256GM104, no XTD Messages, no Receive
Hi Petar!
Thanks for your reply.
Yes, i know that datasheet, and i already had success with ECAN and the dsPIC33EP series.
The problem is only with the dsPIC33EV.
In the ZIP File you'll find one very simple (Echoing) Test Project.
One time compiled for a dsPIC33EP128, this one is working.
The other one is modified for a dsPIC33EV256 which shows the problems of not able to send a 29BIT MSGs and no receive possible.
I use a CAN Bus sniffer Software to investigate and to communicate on the CAN Bus.
Thank you for your time.
Christian
Thanks for your reply.
Yes, i know that datasheet, and i already had success with ECAN and the dsPIC33EP series.
The problem is only with the dsPIC33EV.
In the ZIP File you'll find one very simple (Echoing) Test Project.
One time compiled for a dsPIC33EP128, this one is working.
The other one is modified for a dsPIC33EV256 which shows the problems of not able to send a 29BIT MSGs and no receive possible.
I use a CAN Bus sniffer Software to investigate and to communicate on the CAN Bus.
Thank you for your time.
Christian
- Attachments
-
- dspic33ECANtest.zip
- (195.32 KiB) Downloaded 108 times
Re: ECAN on dsPIC33EV256GM104, no XTD Messages, no Receive
After some more investigation into this problem i was able to narrow down at least the Can Write XTD Message problem. It's caused by the ECAN Library.
Look at the disassembly:
It's only possible to send XTD Messages when NO OTHER Flags (i.e. Priority) are used.
For the no receive problem i still have no clue what's going wrong, but when i take a look at the first lines of the code ....
... i become just more confused?! Why checking _MsgBuffer+15 (at this point)? Where is _MsgBuffer filled? It looks completely different from the dsPIC33EP!?
Look at the disassembly:
Code: Select all
_ECAN1Write:
0x0A10 0xFA0000 LNK #0
; ECAN_TX_MSG_FLAGS start address is: 2 (W1)
0x0A12 0x97B8CE MOV [W14-8], W1
0x0A14 0x200F70 MOV #247, W0 <<--- !!!!
0x0A16 0xE10800 CP W1, W0 <<--- !!!!
0x0A18 0x3A0019 BRA NZ L__ECAN1Write126
For the no receive problem i still have no clue what's going wrong, but when i take a look at the first lines of the code ....
Code: Select all
_ECAN1Read:
0x07D0 0xFA0000 LNK #0
0x07D2 0x210270 MOV #lo_addr(_MsgBuffer+15), W0
0x07D4 0xFB8010 ZE [W0], W0
0x07D6 0xE10065 CP W0, #5
0x07D8 0x3A0117 BRA NZ L__ECAN1Read143
L__ECAN1Read219:
0x07DA 0x210260 MOV #lo_addr(_MsgBuffer+14), W0
; buffer start address is: 12 (W6)
0x07DC 0x784310 MOV.B [W0], W6
0x07DE 0x210260 MOV #lo_addr(_MsgBuffer+14), W0
0x07E0 0xFB8010 ZE [W0], W0
- petar.suknjaja
- mikroElektronika team
- Posts: 683
- Joined: 05 Mar 2018 09:44
- Location: Belgrade
Re: ECAN on dsPIC33EV256GM104, no XTD Messages, no Receive
Hi,
We talked about this on helpdesk.
As i've said, i'll try to reproduce this behaviour.
I'll keep you informed.
Kind regards,
Petar
We talked about this on helpdesk.
As i've said, i'll try to reproduce this behaviour.
I'll keep you informed.
Kind regards,
Petar