• AVR Freaks

Hot![Resolved] 18F4680 eCAN 20Mhz - BRGCON1/BRGCON2/BRGCON3

Author
huttojb
Super Member
  • Total Posts : 591
  • Reward points : 0
  • Joined: 2006/03/04 15:34:49
  • Location: Birmingham England
  • Status: offline
2020/06/04 03:39:53 (permalink)
0

[Resolved] 18F4680 eCAN 20Mhz - BRGCON1/BRGCON2/BRGCON3

Morning all
 
I spent a few hours last night trying to set BRGCON1/BRGCON2/BRGCON3 registers to send and  receive CAN at a Baud rate of 1Mbps.  
 
I have managed for a few years successfully send out and receive at 500kbps, but I have now a device that needs a 1Mbps rate.  I am using a PIC18F4680 with a 20Mhz External OSC
 
My previous set up for 500kbps is, Using the ECAN Library;
ECAN_SJW_VAL 2
ECAN_BRP VAL 1
ECAN_PHSEG1_VAL 8
ECAN_PHSEG_VAL 8
ECAN_PROPSEG_VAL 3
 
I think I got these values along time ago, from either from a utility tool or working it out, I know I did have alot of issues trying to identify and work these values out but in the end I managed it.
 
So, this is great, I have the 500kbp working and have been for a few years, trying to test to get the 1Mbps working is proving difficult, I know the success is also determined on the OSC Speed but a 20Mhz OSC, should be sufficient, I believe!
 
SO I have sat there for hours and worked out (Obviously wrongly) that for a 1Mbps should be;
 
ECAN_SJW_VAL 2
ECAN_BRP VAL 0
ECAN_PHSEG1_VAL 5
ECAN_PHSEG_VAL 3
ECAN_PROPSEG_VAL 1
 
When looking at the CANbus on the Scope, it seems ok and seems to have a nice valid wave form, but when trying to read it via CANalyser at 1Mbps, all I reading is error frames... I would image I have not set up the timings correctly, can anyone help me?  And if someone can help me with the math so I actually fully understand it for next time that would be great.  
 
The hardware is fine as it was working with 500kbps, the ability to read 1Mbps was ok because I was able to read the other device at this speed..  I know it's my timing set-up.
 
Thanks in advise and stay safe all.  
 
Jason
#Staysafe
post edited by huttojb - 2020/06/04 06:18:08
#1

1 Reply Related Threads

    huttojb
    Super Member
    • Total Posts : 591
    • Reward points : 0
    • Joined: 2006/03/04 15:34:49
    • Location: Birmingham England
    • Status: offline
    Re: 18F4680 eCAN 20Mhz - BRGCON1/BRGCON2/BRGCON3 2020/06/04 06:16:57 (permalink)
    +1 (1)
    All
     
    I have final resolved my issue after 2 days or reading and calculating.  Silly Mistake, ECAN_BRP VAL has a range of 1-8.  Putting Zero didn't cut it!!!  Have no idea where I got 0 from, but hey-ho.. onwards and upwards.  
     
    Thank you all that read the post.  
     
    #Staysafe
    #2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5