I have made tables for CAN_SetTiming() for the STR912 at 48 MHZ
Company  
ST Home | Microcontrollers

Index  »  CAN  »  I have made tables for CAN_SetTiming() for the STR912 at 48 MHZ
     
   I have made tables for CAN_SetTiming() for the STR912 at 48 MHZ
 Moderated by :   »  Jatin

Author
beginning argument    ( Replies received: 2 )
rgreenthal   Posted 15-10-2008 at 18:31   



Registered on :
02-07-2009

Messages : 43

 OFF-Line

Hi
Hope my calculations are correct
Please check & get back if they aren't
I got help from Hitex.com
White paper Hitex_Str912.pdf by Trevor Martin & Michael Beach
Page 131 area



// ***************************************************************************************
// ***************************************************************************************
// 1000 Kbps CAN Bus Calculations for AHB of 48 MHZ
// ***************************************************************************************
// ***************************************************************************************
// Baud Rate Prescaler(BRP) (Range 0 - 63)
// Bit rate = PCLK/(BRP * (1 + TSEG1 + TSEG2))
// Setting QUANTA = (1 + TSEG1 + TSEG2)
// Bit rate = PCLK/(BRP * QUANTA)
// BRP = PCLK / (Bit Rate * QUANTA)
// BRP = 48 MHZ / (1000 kbits * QUANTA)
// We can have between 8 and 25 quanta in a time period
// So we need a spreadsheet to calc an integer quanta
// 8 <= (1 + TSEG1 + TSEG2) <= 25
// also TSEG1 >= TSEG2 ??????
// at 1000 KHZ BRP = 48/QUANTA
// BRP = 6, 4, or 2
// So QUANTA(1 + TSEG1 + TSEG2) = 8, 12, or 24
// So if QUANTA = 8 i.e. TSEG1 = 5 & TSEG2 = 2
// So if QUANTA = 12 i.e. TSEG1 = 8 & TSEG2 = 3
// So if QUANTA = 24 i.e. TSEG1 = 15 & TSEG2 = 8
//
// Also to Calc Syncronous Jump Width (SJW),
// probably want it around 66% so we can handle jitter
// if TSEG2 > 5, then SJW = 4
// if TSEG2 < 4, then SJW = TSEG2 -1
//
// The Sample Point in Percent = ((1 + TSEG1)/QUANTA) * 100
//
// CAN_SetTiming(5, 2, 1, 6); // Sample Point = 62.5%
//
// CAN_SetTiming(8, 3, 2, 4); // Sample Point = 75%
//
// CAN_SetTiming(15, 8, 4, 2); // Sample Point = 66.7%
//
// ***************************************************************************************
// ***************************************************************************************
// ***************************************************************************************
// 500 Kbps CAN Bus Calculations for AHB of 48 MHZ
// ***************************************************************************************
// ***************************************************************************************
// Baud Rate Prescaler(BRP) (Range 0 - 63)
// BRP = 48 MHZ / (500 kbits * QUANTA)
// We can have between 8 and 25 quanta in a time period
// 8 <= (1 + TSEG1 + TSEG2) <= 25
// at 500 KHZ BRP = 96/QUANTA
// BRP = 8, 6, or 4
// So QUANTA(1 + TSEG1 + TSEG2) = 12, 16, or 24
// So if QUANTA = 12 i.e. TSEG1 = 7 & TSEG2 = 4
// So if QUANTA = 16 i.e. TSEG1 = 11 & TSEG2 = 4
// So if QUANTA = 24 i.e. TSEG1 = 15 & TSEG2 = 8
//
// Also to Calc Syncronous Jump Width (SJW),
// probably want it around 66% so we can handle jitter
// if TSEG2 > 5, then SJW = 4
// if TSEG2 < 4, then SJW = TSEG2 -1
//
// The Sample Point in Percent = ((1 + TSEG1)/QUANTA) * 100
//
// CAN_SetTiming(8, 3, 2, 8); // Sample Point = 75%
// CAN_SetTiming(7, 4, 3, 8); // Sample Point = 66.7%
// CAN_SetTiming(6, 5, 4, 8); // Sample Point = 58.3%
//
// CAN_SetTiming(12, 3, 2, 6); // Sample Point = 81.25%
// CAN_SetTiming(11, 4, 3, 6); // Sample Point = 75%
// CAN_SetTiming(10, 5, 4, 6); // Sample Point = 68.75%
// CAN_SetTiming( 9, 6, 4, 6); // Sample Point = 62.5%
//
// CAN_SetTiming(15, 8, 4, 4); // Sample Point = 66.7%
//
// ***************************************************************************************
// ***************************************************************************************
// ***************************************************************************************
// 250 Kbps CAN Bus Calculations for AHB of 48 MHZ
// ***************************************************************************************
// ***************************************************************************************
// Baud Rate Prescaler(BRP) (Range 0 - 63)
// Bit rate = PCLK/(BRP * (1 + TSEG1 + TSEG2))
// BRP = PCLK / (Bit Rate * QUANTA)
// BRP = 48 MHZ / (250 kbits * QUANTA)
// We can have between 8 and 25 quanta in a time period
// 8 <= (1 + TSEG1 + TSEG2) <= 25
// also TSEG1 >= TSEG2 ??????
// at 250 KHZ BRP = 192/QUANTA
// BRP = 12, 16, 24
// So QUANTA(1 + TSEG1 + TSEG2) = 16, 12 ,8
// So if QUANTA = 16 i.e. TSEG1 = 10 & TSEG2 = 5
// So if QUANTA = 12 i.e. TSEG1 = 7 & TSEG2 = 4
// So if QUANTA = i.e. TSEG1 = & TSEG2 =
//
// Also to Calc Syncronous Jump Width (SJW),
// probably want it around 66% so we can handle jitter
// if TSEG2 > 5, then SJW = 4
// if TSEG2 < 4, then SJW = TSEG2 -1
//
// The Sample Point in Percent = ((1 + TSEG1)/QUANTA) * 100
//
// CAN_SetTiming(10, 5, 2, 12); // Sample Point = 68.75%
//
// CAN_SetTiming(6, 5, 4, 16); // Sample Point = 58.3%
// CAN_SetTiming(7, 4, 3, 16); // Sample Point = 75%
//
// CAN_SetTiming(4, 3, 2, 24); // Sample Point = 50%
// CAN_SetTiming(5, 2, 1, 24); // Sample Point = 75%
//
// ***************************************************************************************
// ***************************************************************************************
// ***************************************************************************************
// 125 Kbps CAN Bus Calculations for AHB of 48 MHZ
// ***************************************************************************************
// ***************************************************************************************
// Baud Rate Prescaler(BRP) (Range 0 - 63)
// Bit rate = PCLK/(BRP * (1 + TSEG1 + TSEG2))
// Setting QUANTA = (1 + TSEG1 + TSEG2)
// Bit rate = PCLK/(BRP * QUANTA)
// BRP = PCLK / (Bit Rate * QUANTA)
// BRP = 48 MHZ / (125 kbits * QUANTA)
// We can have between 8 and 25 quanta in a time period
// 8 <= (1 + TSEG1 + TSEG2) <= 25
// at 125 KHZ BRP = 384/QUANTA
// BRP = 24, 32, 48
// So QUANTA(1 + TSEG1 + TSEG2) = 16, 12, 8
// So if QUANTA = 16 i.e. TSEG1 = 10 & TSEG2 = 5
// So if QUANTA = 12 i.e. TSEG1 = 7 & TSEG2 = 4
// So if QUANTA = 8 i.e. TSEG1 = 5 & TSEG2 = 2
//
// Also to Calc Syncronous Jump Width (SJW),
// probably want it around 66% so we can handle jitter
// if TSEG2 > 5, then SJW = 4
// if TSEG2 < 4, then SJW = TSEG2 -1
//
// CAN_SetTiming(10, 5, 4, 24); // Sample Point = 68.75%
//
// CAN_SetTiming(7, 4, 3, 32); // Sample Point = 75%
//
// CAN_SetTiming(5, 2, 1, 48); // Sample Point = 62.5%
//
// ***************************************************************************************
// ***************************************************************************************
// ***************************************************************************************
// 100 Kbps CAN Bus Calculations for AHB of 48 MHZ
// ***************************************************************************************
// ***************************************************************************************
// Baud Rate Prescaler(BRP) (Range 0 - 63)
// Bit rate = PCLK/(BRP * (1 + TSEG1 + TSEG2))
// Setting QUANTA = (1 + TSEG1 + TSEG2)
// Bit rate = PCLK/(BRP * QUANTA)
// BRP = PCLK / (Bit Rate * QUANTA)
// BRP = 48 MHZ / (100 kbits * QUANTA)
// We can have between 8 and 25 quanta in a time period
// 8 <= (1 + TSEG1 + TSEG2) <= 25
// at 100 KHZ BRP = 480/QUANTA
// BRP = 48, 40, 24, or 20
// So QUANTA(1 + TSEG1 + TSEG2) = 10, 12, 20, 24
// So if QUANTA = 10 i.e. TSEG1 = 6 & TSEG2 = 3
// So if QUANTA = 12 i.e. TSEG1 = 7 & TSEG2 = 4
// So if QUANTA = 20 i.e. TSEG1 = 13 & TSEG2 = 6
// So if QUANTA = 24 i.e. TSEG1 = 15 & TSEG2 = 8
//
// if TSEG2 > 5, then SJW = 4
// if TSEG2 < 4, then SJW = TSEG2 -1
//
// The Sample Point in Percent = ((1 + TSEG1)/QUANTA) * 100
//
// CAN_SetTiming(6, 3, 2, 48); // Sample Point = 60%
//
// CAN_SetTiming(6, 5, 2, 40); // Sample Point = 58.3%
// CAN_SetTiming(7, 4, 2, 40); // Sample Point = 75%
//
// CAN_SetTiming(13, 6, 4, 20); // Sample Point = 65%
//
// CAN_SetTiming(15, 8, 4, 24); // Sample Point = 66.7%
//
// ***************************************************************************************




 Profile   Quote  
rgreenthal   Posted 15-10-2008 at 19:47   



Registered on :
02-07-2009

Messages : 43

 OFF-Line

Sorry found a mistake in the Hitex white paper
SJW is only 2 bits so its range is 0x00 - 0x03
Here are the recalculations


* ************************************************************************
* ************************************************************************
* 1000 Kbps CAN Bus Calculations for AHB of 48 MHZ
* ************************************************************************
* ************************************************************************
* Baud Rate Prescaler(BRP) (Range 0 - 63)
* Bit rate = PCLK/(BRP * (1 + TSEG1 + TSEG2))
* Setting QUANTA = (1 + TSEG1 + TSEG2)
* Bit rate = PCLK/(BRP * QUANTA)
* BRP = PCLK / (Bit Rate * QUANTA)
* BRP = 48 MHZ / (1000 kbits * QUANTA)
* We can have between 8 and 25 quanta in a time period
* So we need a spreadsheet to calc an integer quanta
* 8 <= (1 + TSEG1 + TSEG2) <= 25
* also TSEG1 >= TSEG2 ?
* at 1000 KHZ BRP = 48/QUANTA
* BRP = 6, 4, or 2
* So QUANTA(1 + TSEG1 + TSEG2) = 8, 12, or 24
* So if QUANTA = 8 i.e. TSEG1 = 5 & TSEG2 = 2
* So if QUANTA = 12 i.e. TSEG1 = 8 & TSEG2 = 3
* So if QUANTA = 24 i.e. TSEG1 = 15 & TSEG2 = 8
*
* Also to Calc Syncronous Jump Width (SJW),
* probably want it around 66% so we can handle jitter
* if TSEG2 > 4, then SJW = 3
* if TSEG2 < 3, then SJW = TSEG2 -1
*
* The Sample Point in Percent = ((1 + TSEG1)/QUANTA) * 100
*
* CAN_SetTiming(5, 2, 1, 6); // Sample Point = 62.5%
*
* CAN_SetTiming(8, 3, 2, 4); // Sample Point = 75%
*
* CAN_SetTiming(15, 8, 3, 2); // Sample Point = 66.7%
*
* ************************************************************************
* ************************************************************************
* 500 Kbps CAN Bus Calculations for AHB of 48 MHZ
* ************************************************************************
* ************************************************************************
* Baud Rate Prescaler(BRP) (Range 0 - 63)
* BRP = 48 MHZ / (500 kbits * QUANTA)
* We can have between 8 and 25 quanta in a time period
* 8 <= (1 + TSEG1 + TSEG2) <= 25
* at 500 KHZ BRP = 96/QUANTA
* BRP = 8, 6, or 4
* So QUANTA(1 + TSEG1 + TSEG2) = 12, 16, or 24
* So if QUANTA = 12 i.e. TSEG1 = 7 & TSEG2 = 4
* So if QUANTA = 16 i.e. TSEG1 = 11 & TSEG2 = 4
* So if QUANTA = 24 i.e. TSEG1 = 15 & TSEG2 = 8
*
* Also to Calc Syncronous Jump Width (SJW),
* probably want it around 66% so we can handle jitter
* if TSEG2 > 4, then SJW = 3
* if TSEG2 < 3, then SJW = TSEG2 -1
*
* The Sample Point in Percent = ((1 + TSEG1)/QUANTA) * 100
*
* CAN_SetTiming(8, 3, 2, 8); // Sample Point = 75%
* CAN_SetTiming(7, 4, 3, 8); // Sample Point = 66.7%
* CAN_SetTiming(6, 5, 3, 8); // Sample Point = 58.3%
*
* CAN_SetTiming(12, 3, 2, 6); // Sample Point = 81.25%
* CAN_SetTiming(11, 4, 3, 6); // Sample Point = 75%
* CAN_SetTiming(10, 5, 3, 6); // Sample Point = 68.75%
* CAN_SetTiming( 9, 6, 3, 6); // Sample Point = 62.5%
*
* CAN_SetTiming(15, 8, 3, 4); // Sample Point = 66.7%
*
* ************************************************************************
* ************************************************************************
* 250 Kbps CAN Bus Calculations for AHB of 48 MHZ
* ************************************************************************
* ************************************************************************
* Baud Rate Prescaler(BRP) (Range 0 - 63)
* Bit rate = PCLK/(BRP * (1 + TSEG1 + TSEG2))
* BRP = PCLK / (Bit Rate * QUANTA)
* BRP = 48 MHZ / (250 kbits * QUANTA)
* We can have between 8 and 25 quanta in a time period
* 8 <= (1 + TSEG1 + TSEG2) <= 25
* at 250 KHZ BRP = 192/QUANTA
* BRP = 12, 16, 24
* So QUANTA(1 + TSEG1 + TSEG2) = 16, 12 ,8
* So if QUANTA = 16 i.e. TSEG1 = 10 & TSEG2 = 5
* So if QUANTA = 12 i.e. TSEG1 = 7 & TSEG2 = 4
* So if QUANTA = i.e. TSEG1 = & TSEG2 =
*
* Also to Calc Syncronous Jump Width (SJW),
* probably want it around 66% so we can handle jitter
* if TSEG2 > 4, then SJW = 3
* if TSEG2 < 3, then SJW = TSEG2 -1
*
* The Sample Point in Percent = ((1 + TSEG1)/QUANTA) * 100
*
* CAN_SetTiming(10, 5, 2, 12); // Sample Point = 68.75%
*
* CAN_SetTiming(6, 5, 3, 16); // Sample Point = 58.3%
* CAN_SetTiming(7, 4, 3, 16); // Sample Point = 75%
*
* CAN_SetTiming(4, 3, 2, 24); // Sample Point = 50%
* CAN_SetTiming(5, 2, 1, 24); // Sample Point = 75%
*
* ************************************************************************
* ************************************************************************
* 125 Kbps CAN Bus Calculations for AHB of 48 MHZ
* ************************************************************************
* ************************************************************************
* Baud Rate Prescaler(BRP) (Range 0 - 63)
* Bit rate = PCLK/(BRP * (1 + TSEG1 + TSEG2))
* Setting QUANTA = (1 + TSEG1 + TSEG2)
* Bit rate = PCLK/(BRP * QUANTA)
* BRP = PCLK / (Bit Rate * QUANTA)
* BRP = 48 MHZ / (125 kbits * QUANTA)
* We can have between 8 and 25 quanta in a time period
* 8 <= (1 + TSEG1 + TSEG2) <= 25
* at 125 KHZ BRP = 384/QUANTA
* BRP = 24, 32, 48
* So QUANTA(1 + TSEG1 + TSEG2) = 16, 12, 8
* So if QUANTA = 16 i.e. TSEG1 = 10 & TSEG2 = 5
* So if QUANTA = 12 i.e. TSEG1 = 7 & TSEG2 = 4
* So if QUANTA = 8 i.e. TSEG1 = 5 & TSEG2 = 2
*
* Also to Calc Syncronous Jump Width (SJW),
* probably want it around 66% so we can handle jitter
* if TSEG2 > 4, then SJW = 3
* if TSEG2 < 3, then SJW = TSEG2 -1
*
* CAN_SetTiming(10, 5, 3, 24); // Sample Point = 68.75%
*
* CAN_SetTiming(7, 4, 3, 32); // Sample Point = 75%
*
* CAN_SetTiming(5, 2, 1, 48); // Sample Point = 62.5%
*
* ************************************************************************
* ************************************************************************
* 100 Kbps CAN Bus Calculations for AHB of 48 MHZ
* ************************************************************************
* ************************************************************************
* Baud Rate Prescaler(BRP) (Range 0 - 63)
* Bit rate = PCLK/(BRP * (1 + TSEG1 + TSEG2))
* Setting QUANTA = (1 + TSEG1 + TSEG2)
* Bit rate = PCLK/(BRP * QUANTA)
* BRP = PCLK / (Bit Rate * QUANTA)
* BRP = 48 MHZ / (100 kbits * QUANTA)
* We can have between 8 and 25 quanta in a time period
* 8 <= (1 + TSEG1 + TSEG2) <= 25
* at 100 KHZ BRP = 480/QUANTA
* BRP = 48, 40, 24, or 20
* So QUANTA(1 + TSEG1 + TSEG2) = 10, 12, 20, 24
* So if QUANTA = 10 i.e. TSEG1 = 6 & TSEG2 = 3
* So if QUANTA = 12 i.e. TSEG1 = 7 & TSEG2 = 4
* So if QUANTA = 20 i.e. TSEG1 = 13 & TSEG2 = 6
* So if QUANTA = 24 i.e. TSEG1 = 15 & TSEG2 = 8
*
* if TSEG2 > 4, then SJW = 3
* if TSEG2 < 3, then SJW = TSEG2 -1
*
* The Sample Point in Percent = ((1 + TSEG1)/QUANTA) * 100
*
* CAN_SetTiming(6, 3, 2, 48); // Sample Point = 60%
*
* CAN_SetTiming(6, 5, 3, 40); // Sample Point = 58.3%
* CAN_SetTiming(7, 4, 3, 40); // Sample Point = 75%
*
* CAN_SetTiming(13, 6, 3, 20); // Sample Point = 65%
*
* CAN_SetTiming(15, 8, 3, 24); // Sample Point = 66.7%
*
* ************************************************************************





 Profile   Quote  
DocHell   Posted 24-11-2008 at 17:05   



Registered on :
04-12-2004

From Brazil

Messages : 3

 OFF-Line

Nice work rgreenthal!
I only tested @ 1Mbit, but worked flawlessly !!!

Greetings





 Profile  Email   www   Quote  
On Top

Search in the forums
 
Jump To