LPC11C24 CAN BT register

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC11C24 CAN BT register

3,274件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CasperH on Mon Jan 30 05:54:42 MST 2012
Hi guys

I have a problem with my CAN bus, when I connect a CAN sniffer to my CAN bus, I get a CAN bus error within 2 to 9 messages. I'm not sure about my CAN initialization. The baudrate should be 250k and my init looks like this:

uint32_t ClkInitTable[2] = {
    0x00000005UL, // CANCLKDIV
    0x00000107UL  // CAN_BTR
};


Can anyone confirm that this is correct?

Best regards
Casper
0 件の賞賛
返信
16 返答(返信)

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CasperH on Thu Feb 09 00:52:48 MST 2012
And after 5 calculators, I've got the right value

0x00000005UL, // CANCLKDIV
0x00001C01UL  // CAN_BTR


Thanks for your time!
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Feb 07 06:34:32 MST 2012

Quote: CasperH
I have tried with a calculator online, and it calculated the following:

uint32_t ClkInitTable[2] = {
    0x00000000UL, // CANCLKDIV
    0x0000051CUL  // CAN_BTR
};



Yes, blame the calculator :eek:  BRP_val  = 0x1C is dividing by 29 :rolleyes:
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CasperH on Tue Feb 07 05:50:44 MST 2012
The "Silent Mode" was not the answer to the problem, I still have some errors and I'm having a hard time setting the right BTR value.

I have tried with a calculator online, and it calculated the following:

uint32_t ClkInitTable[2] = {
    0x00000000UL, // CANCLKDIV
    0x0000051CUL  // CAN_BTR
};

Samlpe point = 87.5%

The settings does not work, infact the whole CAN bus is down using that settings.

I'm running on an 12MHz crystal, boosted to 48MHz with PLL and a baudrate of 250k.

Can any one help me with the right settings for BTR?
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CasperH on Mon Feb 06 00:46:33 MST 2012
"Silent mode" solved the problem :)
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Jan 31 08:16:09 MST 2012

Quote: CasperH
... J1939 demands... :)




Quote:

Sample points in the high 80% range are required for industry standards J1939 (250K BPS) and J2284 (500K BPS)

:eek::eek:
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CasperH on Tue Jan 31 08:10:37 MST 2012
Tha CAN bus is a J1939 with a few meters of non-twisted cable. The sniffer is running 250k baudrate like the J1939 demands. I think the "Silent mode" maybe is the key here :)
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Jan 31 08:01:48 MST 2012
Your sniffer isn't able to read messages without ACK them :eek:

Does your sniffer inform you which sampling point it is using?

Is your sniffer able to transmit messages?

Are these messages received by other nodes?

Did you try to slow down your baud rate to 100k?

Is there something special about your CAN bus, or is it just a standard short (few meter) twisted pair ?
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CasperH on Tue Jan 31 07:43:21 MST 2012
The CAN bus is terminated with a 120 Ohm resistor at each end of the bus. I have connected the sniffer to the bus as a normal CAN node.

I have not yet scoped the signal, and unfortunately my CAN sniffer does not have the "silent mode" option.
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Jan 31 07:13:38 MST 2012
So how are your nodes and this 'sniffer' terminated ?

Seems to be a 'sniffer' problem :rolleyes:

Did you scope your bus already?

Which sampling point is your sniffer using?

Did you switch your sniffer to silent mode?
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CasperH on Tue Jan 31 07:05:55 MST 2012
When I only connect the CAN sniffer and one other module, the sniffer works perfectly, when I connect one more module, the sniffer detects a CAN bus error after 2 to 9 messages. If I connect a third module plus the sniffer, all the communication goes wrong. If I connect 3+ modules without the sniffer, there is no problem. I have been trying with 3 different sniffers, all with the same result.
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OXO on Tue Jan 31 03:17:25 MST 2012
What else is on your canbus?

If you have only one device and the can sniffer, then probably you won't be getting an acknowledge. I doubt the can sniffer would do the ack.
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jan 30 08:02:33 MST 2012
Then it's time to check your hardware, so use test function and scope your CAN

#define TEST_LOOP

/* CAN CTRL register */
#define CTRL_INIT        (1 << 0)
#define CTRL_IE            (1 << 1)
#define CTRL_SIE        (1 << 2)
#define CTRL_EIE        (1 << 3)
#define CTRL_DAR        (1 << 5)
#define CTRL_CCE        (1 << 6)
#define CTRL_TEST        (1 << 7)

#ifdef TEST_LOOP
 if (!(LPC_CAN->CNTL & CTRL_INIT))        //if no init
 {
  LPC_CAN->CNTL |= CTRL_INIT;            //init
 }
 LPC_CAN->CNTL |= CTRL_TEST;            //
 LPC_CAN->TEST = (1<<4);                //CANTEST LOOP
 LPC_CAN->CNTL &= ~CTRL_INIT;            //end init
 while ( LPC_CAN->CNTL & CTRL_INIT );    //wait init end
#endif
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CasperH on Mon Jan 30 07:51:51 MST 2012
It is the CAN sniffer that reports the bus error. I did try other testpoints and different sniffers, alle with the same result :(
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jan 30 07:25:38 MST 2012

Quote:
...I get a CAN bus error within 2 to 9 messages...

Who's reporting this error? LPC11C24 or CAN sniffer?

Did you try a different sample point?
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CasperH on Mon Jan 30 07:21:27 MST 2012
Yes I'm running 48MHz. The termination is fine, i'm just not sure about my CAN setup. I'm confused about the BTR value, I can't figure out if it is right.
0 件の賞賛
返信

3,150件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jan 30 06:00:49 MST 2012
If you are running 48MHz:

Baud rate = 48Mhz / (5+1) / (7+1) / 4 = 0.25 MHz :eek:

Did you check your termination?
0 件の賞賛
返信