Re: 關於dsPIC33EV256GM106 with CAN baud

作者 vaughn 於 2019年06月11日 15:52:50
Hi 版大您好~
非常感激您的指導,
目前有商借到dsPIC33EV 5V CAN-LIN Starter Kit,
使用其Demo code~
500Kbps可以設定成功給其他CAN裝置溝通無異常:
void InitCAN(void)
{
// drive the CAN STANDBY driver pin low
_TRISG9 = 0;
_LATG9 = 0;
_TRISF1 = 0;
_TRISF0 = 1;

// remap the CAN module to the proper pins on the board

RPINR26 = 0x60; // connect CAN RX to RPI96
RPOR9 = 0x000E; // connect CAN TX to RP97

C1CTRL1bits.REQOP = 4;

while (C1CTRL1bits.OPMODE != 4);
C1CTRL1bits.WIN = 0;

/* Set up the CAN module for 250kbps speed with 10 Tq per bit. */

//C1CFG1 = 0x47; // BRP = 8 SJW = 2 Tq
//C1CFG2 = 0x2D2;//SEG2PH=2 TQ;SEG1PH 17 TQ;(PRSEG=010 TQ)

/* Set up the CAN module for 500kbps speed with Tq per bit. */

C1CFG1 = 0x07; // BRP = 8 SJW = 1 Tq
C1CFG2 = 0x0C8; //SEG2PH=1 TQ;SEG1PH 7 TQ;(PRSEG=1 TQ)

機板上X1僅8Mhz,但應該可以設定到CAN bit rate:1Mbps~
但目前嘗試多組設定仍無法達成1Mbps bit rate設定.

來自: http://www.microchip.com.tw/newbb/viewtopic.php?forum=2&topic_id=22669&post_id=79718