Hi, Bro
We use DEMO CODE:RD9Z1_638_12VLA_DEMO on MM9Z1638 Borad to test msCAN interface,and we don't placed a Oscillator,
so I modified two places:PICTURE 1
but I can't get correct rusult,500kbps,
actually get 833.3kbps PICTURE2。
Is there some thing has to set,or make some mistakes。
THANKS FOR YOUR HELP
Solved! Go to Solution.
Can you please specify which hardware you use?
Your desired CAN speed is 500kBaud?
In principle you have to configure a mail box for a receiving message object:
Example:
- in the msCANID.h file configure a message object and the desired CAN ID:
/* Message Object 2 */
#define MO2_ID_TYPE_CAN0 CAN_STANDARD
#define MO2_ID_CAN0 0x303
- initialze mail box for message object 2 (e.g. in main.c)
Config_CAN_MB(CAN0, 2, RXDF, 2); //configure mail box 2 for RXDF for message object 2
- check mail box 2 (e.g. in main.c)
// read message object .....
(void) Check_CAN_MB_Status(CAN0, 2, &mbStat);
if((mbStat.Status == NEWDATA)||(mbStat.Status == OVERRUN)) { // new data ?
Also check out the CAN driver Manual (in the Sources/drivers/msCANDriver/Manual/Manual.pdf file)
Hi,
-what hardware do you use KIT9Z1J638EVM?
-CAN will require an external oscillator to achieve the required CAN clock accuracy
-the CAN bit timing (time quanta, etc.) is set in the msCANcfg.h file:
/****************************************************************************** * Define msCAN module clock source: BUSCLK or MCGERCLK * Permitted values: BUSCLK: Bus clock is used as clock source * MCGERCLK: Oscillator clock is used as clock source ******************************************************************************/ #define CLKSRC_CAN0 MCGERCLK /****************************************************************************** * Define clock prescaler for msCAN module: permitted values 1 to 64 * msCAN module clock = CLKSRC_CAN / PRESCALER_CAN * Set different Prescaler for all CAN Channels, in case the Oscillator Frequency is 8M * Note: User can carefully change this part to get different bitrate ******************************************************************************/ //#define PRESCALER_CAN0 (1) // 1000kbps, if CANBTR0 AND CANBTR1 IN the driver not changed #define PRESCALER_CAN0 (2) // 500kbps, if CANBTR0 AND CANBTR1 IN the driver not changed /****************************************************************************** * Define msCAN module bit timing * * Permitted values: * PHASE_SEG1_CAN: 1 to 16 time quanta * PHASE_SEG2_CAN: 1 to 8 time quanta * Bit time = (1 + TIME_SEG1_CAN + TIME_SEG2_CAN) * time quanta * Note: User can carefully change this part to get different bitrate ******************************************************************************/ #define TIME_SEG1_CAN0 (7) #define TIME_SEG2_CAN0 (8) /****************************************************************************** * Define msCAN module re-synchronisation jump width * Permitted values: 1 to smaller of 4 and PHASE_SEG1_CAN time quanta ******************************************************************************/ #define RJW_CAN0 (2)
Thanks for your helps.
I adjusted the one paramete,
CHANGED "REFDIV(16)" TO "REFDIV(8)"
and now I can send data from the CAN bus, through CAN- Monitor connected PC, PC can get the correct data, however, PC sends data to the board, the board can't receive PC data ("SET FRAME ID: 0x10"), can't get "NEWDATA" ,
I use the oscilloscope to test the TX and RX pin on board, oddly, TX and RX when sending data have the same waveform.
I don't know where's wrong. Can you give me some advice, or an example.
Can you please specify which hardware you use?
Your desired CAN speed is 500kBaud?
In principle you have to configure a mail box for a receiving message object:
Example:
- in the msCANID.h file configure a message object and the desired CAN ID:
/* Message Object 2 */
#define MO2_ID_TYPE_CAN0 CAN_STANDARD
#define MO2_ID_CAN0 0x303
- initialze mail box for message object 2 (e.g. in main.c)
Config_CAN_MB(CAN0, 2, RXDF, 2); //configure mail box 2 for RXDF for message object 2
- check mail box 2 (e.g. in main.c)
// read message object .....
(void) Check_CAN_MB_Status(CAN0, 2, &mbStat);
if((mbStat.Status == NEWDATA)||(mbStat.Status == OVERRUN)) { // new data ?
Also check out the CAN driver Manual (in the Sources/drivers/msCANDriver/Manual/Manual.pdf file)
THANK YOU FOR YOUR HELP!
I have set 800k Baud and goten RX and TX correct data 。thankyou!