Other Parts Discussed in Thread:C2000WARE
請問一下有範例程式是使用 internal clock 來驅動 CAN bus 嗎??
我想確定 CAN sysCLK 多少來設定 bandrate 。
#define DEVICE_SETCLOCK_CFG (SYSCTL_OSCSRC_OSC1 | SYSCTL_IMULT(40) | \
SYSCTL_REFDIV(2) | SYSCTL_ODIV(2) | \
SYSCTL_SYSDIV(1) | SYSCTL_PLL_ENABLE | \
SYSCTL_DCC_BASE_0)
現在我知道的是 intrnal clock 是10Mhz ,DEVICE_SETCLOCK_CFG 換算下來是 100 Mhz
但這是 CAN_sysCLK 嗎? 還是還要再做除頻的動作??
另外我是不是還要使用這個功能 CAN_selectClockSource(uint32_t base, CAN_ClockSource source),來確定設定他 internal clock。
但現在 CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 250000, 20); 裡面的 DEVICE_SYSCLK_FREQ 不清楚要設定多少??
Green Deng:
你好,例程C:\ti\c2000\C2000Ware_3_03_00_00\driverlib\f28002x\examples\can就是用的内部时钟。
然后,芯片TRM中有介绍:The CAN bit timing clock is normally derived from the system clock (SYSCLK)
例程中有介绍CAN_setBitRate
//***************************************************************************** // //! Sets the CAN Bit Timing based on requested Bit Rate. //! //! \param base is the base address of the CAN controller. //! \param clock is the CAN module clock frequency before the bit rate //!prescaler (Hertz) //! \param bitRate is the desired bit rate (bits/sec) //! \param bitTime is the number of time quanta per bit required for desired //!bit time (Tq) and must be in the range from 8 to 25 //! //! This function sets the CAN bit timing values for the bit rate passed in the //! \e bitRate and \e bitTime parameters based on the \e clock parameter.The //! CAN bit clock is calculated to be an average timing value that should work //! for most systems.If tighter timing requirements are needed, then the //! CAN_setBitTiming() function is available for full customization of all of //! the CAN bit timing values. //! //! \note The CANBTR register values calculated by the function CAN_setBitRate //!may not be suitable for your network parameters. If this is the case //!and you have computed the correct values for your network, you could //!directly write those parameters in CANBTR register using the //!function CAN_setBitTiming. //! //! \return None. // //***************************************************************************** extern void CAN_setBitRate(uint32_t base, uint32_t clock, uint32_t bitRate,uint16_t bitTime);