2969 views|0 replies

1140

Posts

0

Resources
The OP
 

Summary of DSP's real clock system--Explained with TI's DSP TMS320F2812 as an example [Copy link]

Learn programming standards from TI code!!!

In fact, it is quite important to understand the system clock system. The following is a brief summary of the key points of the application.

1. First of all, let's clarify two issues. To make a system work, two important conditions must be met. One is to supply power to the system, which is generally achieved by using a switching power supply module. The other is the CPU, which is the heart of the entire system. To keep it running, it needs to be continuously provided with regular clock pulses.

Today's topic is to summarize the clock in depth:

Consider this from two perspectives:

1. From the hardware point of view, we generally use an external crystal oscillator with a frequency of 30MHz as the starting point for analysis. The external crystal oscillator provides the CPU with a clock pulse CLKIIN through the on-chip oscillator OSC and a clock module based on the phase-locked loop PLL multiplication logic.

The main function of the on-chip phase-locked loop (PLL) module integrated in the current DSP is to configure the on-chip peripheral clock in real time through software to improve the flexibility and reliability of the system. (We will not discuss the benefits of this design for the time being!!!)

TI routine - call the PLL function in the main function of the system initialization function, InitPll (0xA); assign values and calculate, and pass in parameter 10, which means 10 times the frequency.

void InitPll(Uint16 val)
{
volatile Uint16 iVol;

if (SysCtrlRegs.PLLCR.bit.DIV != val)
{

EALLOW;
SysCtrlRegs.PLLCR.bit.DIV = val;
EDIS;
DisableDog();
for(iVol= 0; iVol< ( (131072/2)/12 ); iVol++)
{

}
}
After calculation and multiplication by software, the clock signal of the CPU in DSP--SYSCLKOUT system clock is the maximum clock of 150MHz! ! !, and then distributed to each peripheral. However, peripherals are divided into high-speed peripheral clock and low-speed peripheral clock. Please pay special attention that these two concepts are only relative. They correspond to two registers: high-speed peripheral clock pre-scale register HISPCP (value range is 0~7) and low-speed external clock pre-scale register. In practice, we need to set these two registers through software! You can refer to the following code to understand. We need to enable the operation of the peripherals we need to use, and do not set the ones we do not need! You need to make corresponding settings in the peripheral clock control register PCLKCR. For details, please refer to the following setting code. This code can also be included in the system initialization program! ! !

void InitPeripheralClocks(void)
{
EALLOW;
// HISPCP/LOSPCP prescale register settings, normally it will be set to default values
SysCtrlRegs.HISPCP.all = 0x0001; 70MHZ
SysCtrlRegs.LOSPCP.all = 0x0002; 37.5MHz

// Peripheral clock enables set for the selected peripherals.
SysCtrlRegs.PCLKCR.bit.EVAENCLK=1;
SysCtrlRegs.PCLKCR.bit.EVBENCLK
=1
;
.MCBSPENCLK=1;
SysCtrlRegs.PCLKCR.bit.SPIENCLK=1;
SysCtrlRegs.PCLKCR.bit.ECANENCLK=1;
SysCtrlRegs.PCLKCR.bit.ADCENCLK=1;
EDIS;
} This code has been modularized. In practice, whether we want to modify the high-speed pre-calibration register or the low-speed pre-calibration register, we can do it in the initialization program. Just add one statement to operate

As follows: InitSysCtrl();

// HISPCP prescale register settings, normally it will be set to default values
EALLOW; // This is needed to write to EALLOW protected registers
SysCtrlRegs.HISPCP.all = 0x0000; // SYSCLKOUT/1   

This sentence sets the high-speed clock HSPCLK = 150MHz! ! !
EDIS; // This is needed to disable write to EALLOW protected registers

Next, let's move on to the specific peripherals. If we want to set them up, we usually set them up separately in modules! This is very important and is the programming specification!!!

Next, we will discuss setting the count clock for the universal timer TI in the EV module. The main settings are TPS2~TPS0 in the timer control register TxCON: input clock pre-scaling and the source of the TCLKS1~TCLKS0 clock source. Here we choose the source 00, internal clock (such as HSPCLK); 01 external clock (such as TCLKIN); 10, reserved; 11, QEP circuit (this may be used when we make the speed measurement QEP circuit). If these two parts are set, the timer clock is also determined! Then there is another question about the selection of the count mode. Four count modes are provided and can be set and selected in the two bits TMODE1~TMODE0 in the TxCON register! ! !

After the above settings are completed, the corresponding TIPR period register value can be calculated! T1PR=7500!!!

Next, you can set the dead zone register to set a dead zone time DBTCONx [8~11] bits to set the dead zone period value m, DBTCON [2~4] bits to set the dead zone timer pre-scaling factor x/p, the timer clock period is t, then the dead zone time tBD = m*p*t.

#define DBTCON_INIT_STATE ( DBT_VAL_15 + \ Change this bit, the corresponding is 15
EDBT3_EN + \
EDBT2_EN + \
EDBT1_EN + \ These three bits do not change! This is also an operation skill!
DBTPS_X1 ) Pre-mark P=32, change this bit

In this way, the dead time I set by counting is 3.2 microseconds!

Summary: In short, if we want to get the clock cycle we need from the original crystal oscillator source, we only need to configure the bits where the clock pre-scaling factor is located in a series of related registers to calculate the clock cycle we want.

This post is from DSP and ARM Processors
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list