Hi there,
Can somebody help me with the configuration of the Enhanced CAN peripheral of dsPIC33FJ128GP804 ?
I'm using a CAN driver (unfortunately i'm obliged to use it) that realizes communication with messages that use standard ID (11bits).
For the purpose of making the application compatible to other stuff, i have to handle also extended ID messages. So I figured out that the quickest way for me to sort it would be to initialize another filter in the can peripheral, which would be dedicated to extended ID messages.
To do so, i tried to modify the Can_Init() function, in which i could find already the settings of the other filters which were already used for standard messages.
Here the part of code related to the filters and masks of the peripheral:
// Assign Number of Buffers Used by ECAN Module in DMA Memory Space
C1FCTRLbits.DMABS=0b010; // 4 CAN Messages to be buffered in DMA RAM and
// FIFO Start Area TX/RX buffer TRB0
C1CTRL1bits.WIN=0b1; // enable window to access the filter configuration registers
// ------------------------------ Set Up Filters and Masks -------------------------------
C1FMSKSEL1bits.F0MSK=0; // select acceptance mask 0 filter 0
C1RXM0SID=CAN_FILTERMASK2REG_SID(0x7FF);
w = (FILTRO_NMT_ERR_CTRL << 7) + id;
C1RXF0SID = CAN_FILTERMASK2REG_SID(w);
C1RXM0SID=CAN_SETMIDE(C1RXM0SID); // set filter to check for standard ID and accept standard id only
C1RXF0SID=CAN_FILTERSTD(C1RXF0SID);
C1BUFPNT1bits.F0BP=0b0001; // acceptance filter to use buffer 1 for incoming messages
C1FEN1bits.FLTEN0=1; // enable filter 0
C1FMSKSEL1bits.F1MSK=0; // select acceptance mask 0 filter 1
w = (FILTRO_RSDO1 << 7) + id;
C1RXF1SID=CAN_FILTERMASK2REG_SID(w);
C1RXM1SID=CAN_SETMIDE(C1RXM1SID); // set filter to check for standard ID and accept standard id only
C1RXF1SID=CAN_FILTERSTD(C1RXF1SID);
C1BUFPNT1bits.F1BP=0b0010; // acceptance filter to use buffer 2 for incoming messages
C1FEN1bits.FLTEN1=1; // enable filter 1
C1FMSKSEL1bits.F2MSK=0; // select acceptance mask 0 filter 2
//w = (FILTRO_NMT << 7) + id;
w = (FILTRO_NMT << 7);
C1RXF2SID=CAN_FILTERMASK2REG_SID(w);
C1RXM2SID=CAN_SETMIDE(C1RXM2SID); // set filter to check for standard ID and accept standard id only
C1RXF2SID=CAN_FILTERSTD(C1RXF2SID);
C1BUFPNT1bits.F2BP=0b0011; // acceptance filter to use buffer 3 for incoming messages
C1FEN1bits.FLTEN2=1; // enable filter 2
After i saw this bunch of code, i tried adding mine in a similar way to the other filters, to configure filter 3, that was not used already.
Unfortunately, even if the code was practically identical, i could not find a way to modify SFRs: C1RXF3SID and C1RXF3EID (simply assigning random values to them did not affect them) .
I am sure of what i am saying because i can look at the memory while executing the code, with ICD 3 debugger.
Can somebody help me?