CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

18F25K80 CAN Transmit issue

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
2xhp



Joined: 14 Jan 2019
Posts: 39

View user's profile Send private message

18F25K80 CAN Transmit issue
PostPosted: Fri Dec 29, 2023 7:40 pm     Reply with quote

I'm using an 18F25K80 with PCH 5.105 and attempting to do what I've done before with this version of compiler and the same chip - even using the same basic code. I did change from the MCP2551 CAN transceiver to the MCP2561FD (which is working fine on a different MCU).

I'm scoping the transmit pin from the MCU, and getting a repeated pulse at 21.74 kHz.

If I don't transmit any messages from the MCU, there is no pulse.

I'm hoping this sounds familiar to someone and they can point me in the right direction. I'm a bit lost right now.

Thanks in advance!
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sat Dec 30, 2023 2:09 am     Reply with quote

First thing, is the oscillator the same as your previous version?.
The pulse time suggests possibly a speed problem.
What CAN bus rate are you using?.
Then how is pin8 wired?. Difference between the chips, the 2551 allows
a resistor on this pin to control the slope speed. The 2561 does
not support this.

What does the RX pin have on it?. With CAN, the RX receives what is sent.
If this is not happening the drive code will error and may behave as you
are seeing.
2xhp



Joined: 14 Jan 2019
Posts: 39

View user's profile Send private message

PostPosted: Sat Dec 30, 2023 12:12 pm     Reply with quote

Hi Ttelmah - thank you for the response.

Your first question hit the nail on the head. I have used the same setup for so long that when I changed from the 10 MHz crystal to an 8 MHz oscillator, I didn't think to change the CAN timing registers. I did that.

My CAN bus rate is 500 kbaud.

Pin 8 (Standby) is tied to ground (standby mode disabled).

Rx pin was receiving what was sent.

I looked more carefully at the Tx pin waveform on the scope and after measuring, see it is not rising to the 5 V Vdd value - only getting up to about 3.5 V. The 2561 does have a pullup on the Tx line. I added another 10 k to Vdd which did bring it nearly to the 5 V, but still no luck. I then tried setting CAN_ENABLE_DRIVE_HIGH to 1 and that got it working.

So in summary, I did the following:

    Set the CAN timing registers
    Set CAN_ENABLE_DRIVE_HIGH to 1

I'm just stumped now why I need CAN_ENABLE_DRIVE_HIGH set to 1. With the pullup resistor, it doesn't seem that should be necessary.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sun Dec 31, 2023 10:56 am     Reply with quote

Glad you got it working.
10K is a rather large resistor for a signal clocking at 500KHz. Depending
on the line capacotance the rise tme may be too slow without the active
drive.

If you look Vih of the older transceiver is 2v. For the new one 0.7Vdd.
Huge difference in how high the signal needs to go!....
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Sun Dec 31, 2023 11:57 am     Reply with quote

My first CAN project I faced the same issue: http://www.ccsinfo.com/forum/viewtopic.php?t=23825&highlight=canenabledrivehigh

It's another CCS thing. We old-timers don't bat an eye at such things anymore, but mightily frustrating to any newcomers.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group