CAN Bus @ 1mbps

Testing and development of Megasquirt 3

Moderators: jsmcortina, muythaibxr

Post Reply
DeltaP
MS/Extra Newbie
Posts: 7
Joined: Sat Feb 28, 2015 7:50 pm

CAN Bus @ 1mbps

Post by DeltaP »

Does anyone know the values that are required to set the can bus bit rate to 1mbps?
I tried (unsuccessfully):

Code: Select all

    CAN0BTR0 = 0xC0;            /* SJW=4,BR Prescaler= 1(8MHz CAN0 clk) */
    CAN0BTR1 = 0x05;            /* Set time quanta: tseg2 =1,tseg1=6  (8 Tq total including sync seg (=1)) */
What'd I miss? :?
DeltaP
MS/Extra Newbie
Posts: 7
Joined: Sat Feb 28, 2015 7:50 pm

Re: CAN Bus @ 1mbps

Post by DeltaP »

:RTFM: According to the example on page 10 of http://www.freescale.com/files/microcon ... AN1798.pdf
The settings for 1M with 8Mhz clock should be:
Prescaler = 1
Nominal Bit Time = 8
PROP_SEG = 4
PHASE_SEG1 = 1
PHASE_SEG2 = 2
SJW = 1

So in other words:

Code: Select all

    CAN0BTR0 = 0x00; /* SJW=0,BR Prescaler= 1(8MHz CAN0 clk) */
    CAN0BTR1 = 0x05; /* Set time quanta: tseg2 = 6(prop_seg + phase_seg2), tseg1=1 (8 Tq total including sync seg (=1)) */
Still no luck. :x
Any ideas?
jsmcortina
Site Admin
Posts: 39618
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN Bus @ 1mbps

Post by jsmcortina »

I've not tried, so don't know. What happens? Have you scoped the bus to see what's going on?

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
DeltaP
MS/Extra Newbie
Posts: 7
Joined: Sat Feb 28, 2015 7:50 pm

Re: CAN Bus @ 1mbps

Post by DeltaP »

I've not scoped it yet, but will when I find out what happened to channel 2 on the scope... :?
In the meantime, using an autobaud sniffer I can see the MS3X CAN broadcast messages at 500kbps with the stock settings (CAN0BTR0=0xC0; CAN0BTR1=0x1C;).
If I connect it to a known-to-be-working 1M bus (MoTeC PDM) - it kills the comms between the PC and PDM (i.e usb to canbus dies!).
The autobaud sniffer sees the PDM @1Mbps no worries and can send / receive messages.
I can't downgrade the PDM baud rate without shipping it back to MoTeC. :cry:
tpsretard2
Master MS/Extra'er
Posts: 662
Joined: Thu Feb 14, 2008 4:59 am

Re: CAN Bus @ 1mbps

Post by tpsretard2 »

I am going to watch this space carefully. Would be amazing if the ms3 can talk to the motec PDM.

Good luck.
jsmcortina
Site Admin
Posts: 39618
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN Bus @ 1mbps

Post by jsmcortina »

Are you sure that a return to base is required?

The PDM User Manual says the following on page 27.
"CAN Bus Bitrate
The PDM can be configured to operate at CAN bit rates of 250Kbps, 500Kbps
or 1Mbps.
PDM manager includes a CAN bitrate conversion tool in the Tools > Options >
Communications menu"

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
jsmcortina
Site Admin
Posts: 39618
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN Bus @ 1mbps

Post by jsmcortina »

Note that the MS3 CAN receiving doesn't presently support the "Compound id" method.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
krisr
Master MS/Extra'er
Posts: 799
Joined: Wed Aug 17, 2005 1:17 am
Location: Sydney, Australia

Re: CAN Bus @ 1mbps

Post by krisr »

Subscribed. If the ms3 could talk to a pdm or smartwire, that would be very relevant to my current needs.
Sydney, Australia
1971 Holden Monaro HQ
MS3X Sequentially fuelled 400 Pontiac
jsmcortina
Site Admin
Posts: 39618
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN Bus @ 1mbps

Post by jsmcortina »

Out of interest, what in particular do these third party products offer that you specifically need?

For basic I/O expansion, there's this: http://www.msextra.com/product-range/ex ... rt-io-box/

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
DeltaP
MS/Extra Newbie
Posts: 7
Joined: Sat Feb 28, 2015 7:50 pm

Re: CAN Bus @ 1mbps

Post by DeltaP »

jsmcortina wrote:Are you sure that a return to base is required?

The PDM User Manual says the following on page 27.
"CAN Bus Bitrate
The PDM can be configured to operate at CAN bit rates of 250Kbps, 500Kbps
or 1Mbps.
PDM manager includes a CAN bitrate conversion tool in the Tools > Options >
Communications menu"

James
Yup - tried that and got a message about the PDM Bootloader code being too old and must be updated (factory only) to use this functionality.
Once it's done, I'm sure I'll be able to switch it on the fly.
DeltaP
MS/Extra Newbie
Posts: 7
Joined: Sat Feb 28, 2015 7:50 pm

Re: CAN Bus @ 1mbps

Post by DeltaP »

jsmcortina wrote:Note that the MS3 CAN receiving doesn't presently support the "Compound id" method.

James
Don't need compound...even the Arduino CANSpy can talk to the PDM at 1M. I've left the two on the bench and they've been chatting all afternoon! :D
(The CANSpy also talks to the MS3X at 500k with no problems, but once we hit 1M things go pear shaped.)
DeltaP
MS/Extra Newbie
Posts: 7
Joined: Sat Feb 28, 2015 7:50 pm

Re: CAN Bus @ 1mbps

Post by DeltaP »

Just for $hits and giggles I tried the following:

Code: Select all

CAN0CTL1 = 0xC0; /* Set Can enable, use bus clock (100 MHz), clear rest */
CAN0BTR0 = 0x09; /* SJW=1,BR Prescaler= 5(100MHz CAN0 clk) */
CAN0BTR1 = 0x07; /* Set time quanta: tseg2 = 1(prop_seg + phase_seg2), tseg1=8 (10 Tq total including sync seg (=1)) */
Still no luck, but this was kind of expected. Even the Freescale documentation says using the PLL as the source is a bad thing due to jitter.
DeltaP
MS/Extra Newbie
Posts: 7
Joined: Sat Feb 28, 2015 7:50 pm

Re: CAN Bus @ 1mbps

Post by DeltaP »

This evening I managed to read RPM and CLT from the MS3X. :yeah!:
I dropped the baud rate back to 500k and had MoTeC load a new bootloader on the PDM that allows me to set the baud rate to 500k on it as well.
I now want to read the status of the Launch_In pin (from my clutch pedal).
Post Reply