PDA

View Full Version : CANBUS Timing at HALFSPEEDCPU


Pacetech
09-03-04, 12:12 AM
I'm banging my head on my computer trying to figure this out.

Here is my CAN Init Routine

: INIT-CAN
01 0D80 ! \ SOFT RESET
81 0D81 ! \ CAN ENABLE, IPBus CLK - more stable
01 0D82 ! \ 0 SYNC, 2 PRESCALE
23 0D83 ! \ 500K CLK
20 0D88 ! \ 8 8-BIT FILTERS
INIT-CAN-FILTERS
00 0D80 ! \ RELEASE SOFT RESET
; EEWORD

Works great, but I have one ISOPOD running at HALFSPEED CPU in order to communicate with a 300 baud device.

The IPBus freq is 40 MHz at full speed and 20MHz at half speed.

I've tried many combinations, but I cannot seem to get this halfspeed ISOPOD to talk to the other fullspeed ISOPODs using the following routine (or variants)

: INIT-CAN
01 0D80 ! \ SOFT RESET
81 0D81 ! \ CAN ENABLE, IPBus CLK - more stable
00 0D82 ! \ 0 SYNC, 1 PRESCALE *** FOR HALFSPEEDCPU
23 0D83 ! \ 500K CLK
20 0D88 ! \ 8 8-BIT FILTERS
INIT-CAN-FILTERS
00 0D80 ! \ RELEASE SOFT RESET
; EEWORD

I would think that cutting the prescaler in half would do the trick. But I know I'm doing something wrong.

RMDumse
09-03-04, 05:15 PM
I do a very similar initialization in one of my CAN applications:

: INITCAN
1 D80 ! ( SOFT RESET
80 D81 ! ( MSCAN ON, EXTAL CLK
01 D82 ! ( 0 SYNC, 2 PRESCALE
23 D83 ! ( 500K CLK

00 D88 ! ( 2 32BIT FILTER

FF D94 ! ( DONT CARE ALL BITS
FF D95 ! ( DONT CARE ALL BITS
FF D96 ! ( DONT CARE ALL BITS
FF D97 ! ( DONT CARE ALL BITS
FF D98 ! ( DONT CARE ALL BITS
FF D9D ! ( DONT CARE ALL BITS
FF D9E ! ( DONT CARE ALL BITS
FF D9F ! ( DONT CARE ALL BITS

0 D80 ! ( RELEASE RESET
; EEWORD


Now what worries me about changing the prescale, is, I have the impression this was about as fast as I could set the CAN to go with full speed operation. That would mean it didn't have any reserve to go "faster". So just changing the prescaler probably isn't it, but it bears some further research with the user manual for the chip.

RMDumse
09-03-04, 05:28 PM
From the User Manual, "Figure 8-9 illustrates the structure of the MSCAN clock generation circuitry. With this flexible clocking scheme, the MSCAN is able to handle CAN bus rates ranging from 10 Kbps up to 1Mbps."

Now just from memory, I don't recall ever getting the system to work at 1M. My memory is I had to have a prescale of 2.

If you're set up, please try this. Set your two non-half-speed ones for a prescale of 1, and see if they can talk. If they can't talk with a prescale of 1, then I don't suppose the halfspeed one will either.

Pacetech
09-07-04, 12:23 AM
I'll try that tommorow when I get back to work. I was out of town for the holiday and brought along the MSCAN documentation, but I don't remember anything about the prescale having to be more than 1, but there may have been some limitations on the time-quanta stuff.

But, I think I may have figured out my problem.

I started using the IPBus because the MSCAN chapter said it was more stable (no jitter). But the IPBus runs at 40 MHz for full speed and 20MHz for half speed.

The other clock option is EXTALi, which is 8MHz right? So by using the IPBus clock as the MSCAN clock, then its automatically faster.

So have I been running my CANBUS at 2.5 MB/s?

RMDumse
09-07-04, 09:17 AM
When I set up the CAN bus parameters, I figured the external crystal couldn't be much less stable than the IP bus, which is derived from the external crystal. I never really bothered to check these assumptions. Once it started working reliably, I didn't concern myself further with it. But the IP clock is made by phaselock looping the 8MHz clock up. So it will have some longer term stability possibly, which was how I read the manual.

Yes, I used the external clock. The manual says the maximum speed the CAN can operate is 1mbit. I don't think you were really operating at 2.5, but I guess you could look with a scope (I'm still at home, so don't have one here). That's how I checked my speed when I was first experimenting with the CAN interface.

Pacetech
09-07-04, 02:18 PM
Ok, I used the EXTALi clock instead of the IPBus since the XTAL is always 8MHz at fullspeed and halfspeed and it works fine at 500 MB/s.