Detailed explanation of S3C2440 clock system

Publisher:火星Latest update time:2017-01-07 Source: eefocusKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Before talking about the system clock, because these devices are all dependent on the system clock, we must first talk about the system clock. The clock system of S3C2440 is as follows


There are two types of external clock sources, crystal oscillator or external frequency, which are selected by om3-2. The clock circuit also has two types according to the two choices.


We can draw the following conclusions by analyzing the clock diagram: The selected external clock enters MPLL and is multiplied by the phase-locked loop. After passing through the phase-locked loop, the clock MPLL_IN is divided into three parts, namely FCLK, HCLK, and PCLK. Among them, HCLK and PCLK are obtained by dividing the HCLK. Finally, the ARM920T system kernel module obtains two clocks, HCLK and FCLK. The DMA controller, LCD controller, memory controller, bus controller, external nand controller and TIC, and the camera interface all come from the HCLK clock. The LCD controller, nand controller, and cam camera controller clocks can be selected to be cut off from the bus, IIC WDT IIS PWM SDI GPIO ADC RTC UART012 SPI These AC97 peripherals are all connected to the PCLK bus, and except for WDT, they can be disconnected from the bus. In addition, the USB clock is directly obtained from the MPLL_IN multiplier to generate UCLK. The USB host clock can choose UCLK or HCLK, and the USB device clock can choose UCLK or PCLK. Therefore, sometimes it is a good choice to look at the picture when you first come into contact with the chip. The text is more detailed, and looking at the picture can quickly browse the whole picture. Through our analysis, we can get the following simplified document

 

 

Input Clock

MPLL

FCLK

HCLK

Memory controller, interrupt controller, nand controller, tic controller, etc., system kernel 920T, DMA controller

PCLK

Basic peripherals RTC, UART, spi and other peripherals

Only supplies the system kernel,

USB PLL

UCLK

USB host clock, USB device clock

This is the basic distribution of the system clock. The remaining details are nothing more than how to divide the frequency, how to enable the clock and stop the clock, the phase-locked loop configuration, etc. First, focus on MPLL


This is the PLL lock time. Generally, you can set it smaller to check whether the lock is successful.


These three values ​​can be combined to select different MCLKs. There is a formula in the data sheet. After MPLL multiplication, the system master clock FCLK (that is, the ARM920T clock) is successfully obtained.


Use this register to enable and cut off the clock. Don't forget this register when using peripherals.


This register determines the ratio at which FCLK is divided into HCLK and PCLK.

At this point, we have basically described the system clock. As long as we understand the framework, the clock is actually quite simple, the frequency division coefficient, power control, and the most important thing is to understand which device uses which clock.

 

Next, we will show you a code to calculate the system clock (the process of setting the clock can be found in 2440init.s, which you can refer to)

 

Clock.c

#include "clock.h"

#define FIN (12000000)	

U32 FCLK;
U32 HCLK;
U32 PCLK;
U32 UCLK;


void CalcBusClk(void) //Calculate bus frequency
{
	U32 val,UPLL;
	U8 m, p, s;
	val = rMPLLCON;
	m = (val >> 12) & 0xff;
	p = (val >> 4) & 0x3f;
	s = val & 3;

	FCLK = ((m+8)*(FIN/100)*2)/((p+2)*(1<> 1) & 3;
	p = val & 1;	
	val = rCAMDIVN;
	s = val >> 8;
	
	switch (m) 
	{
		case 0:
			HCLK = FCLK;
			break;
		case 1:
			HCLK = FCLK >> 1;
			break;
		case 2:
			if(s & 2)
				HCLK = FCLK >> 3;
			else
				HCLK = FCLK >> 2;
			break;
		case 3:
			if(s & 1)
				HCLK = FCLK / 6;
			else
				HCLK = FCLK / 3;
			break;
	}
	
	if(p)
		PCLK = HCLK >> 1;
	else
		PCLK = HCLK;
		
	val = rUPLLCON;
	m = (val >> 12) & 0xff;
	p = (val >> 4) & 0x3f;
	s = val & 3;
	UPLL = ((m+8)*FIN)/((p+2)*(1<>1):UPLL;
}

//************************[HCLK, PCLK]************************ **********
void ChangeClockDivider(int hdivn_val,int pdivn_val)
{
	int hdivn=2, pdivn=0;
	
	// hdivn_val (FCLK:HCLK)ratio hdivn
	// 11 1:1 (0)
	// 12 1:2 (1)
	// 13 1:3 (3) 
	// 14 1:4 (2)
	// pdivn_val (HCLK:PCLK)ratio pdivn
	// 11 1:1 (0)
	// 12 1:2 (1)
	switch(hdivn_val) {
		case 11: hdivn=0; break;
		case 12: hdivn=1; break;
		case 13:
		case 16: hdivn=3; break;
		case 14: 
		case 18: hdivn=2; break;
	}
	
	switch(pdivn_val) {
		case 11: pdivn=0; break;
		case 12: pdivn=1; break;
	}
	
	rCLKDIVN = (hdivn<<1) | pdivn;

	switch(hdivn_val) {
		case 16: // when 1, HCLK=FCLK/8.
			rCAMDIVN = (rCAMDIVN & ~(3<<8)) | (1<<8); 
		break; 
		case 18: // when 1, HCLK=FCLK/6.
			rCAMDIVN = (rCAMDIVN & ~(3<<8)) | (1<<9); 
		break;
	}
	
	if(hdivn!=0)
		MMU_SetAsyncBusMode();
	else 
		MMU_SetFastBusMode();
}



//******************************[UPLL]********************** ************
void ChangeUPllValue(int mdiv,int pdiv,int sdiv)
{
	rUPLLCON = (mdiv<<12) | (pdiv<<4) | sdiv;
}



//******************************[MPLL]****************** **********
void ChangeMPllValue(int mdiv,int pdiv,int sdiv)
{
	rMPLLCON = (mdiv<<12) | (pdiv<<4) | sdiv;
}


//****************************Clock configuration function********************************
void SetClock(u8 mpll)
{
	if(mpll == MPLL271)
	{
		ChangeMPllValue(173,2,2);	
	}
	else if(mpll == MPLL304)
	{
		ChangeMPllValue(68,1,1);
	}
	else if(mpll == MPLL405)
	{
		ChangeMPllValue(127,2,1);
	}
	else if(mpll == MPLL532)
	{
		ChangeMPllValue(125,1,1);
	}
	ChangeClockDivider(14,12); //Set the division ratio to 1:4:8 fclk hclk pclk 
									//And set the CPU asynchronous bus mode
	CalcBusClk(); //Calculate bus frequency

	
}



Clock.h

#ifndef __CLOCK_H_
#define __CLOCK_H_
#include "def.h"
#include "2440addr.h"
#include "2440slib.h"

#define FIN (12000000) //External crystal
#define MPLL271 1 //Several typical clock macro definitions
#define MPLL304 2
#define MPLL405 3
#define MPLL532 4

void CalcBusClk(void); //Calculate bus frequency
void ChangeClockDivider(int hdivn_val,int pdivn_val); //Calculate the frequency division value
void ChangeUPllValue(int mdiv,int pdiv,int sdiv); //Configure USB bus
void ChangeMPllValue(int mdiv,int pdiv,int sdiv);
void SetClock(u8 mpll); //Configure system clock

extern U32 FCLK;
extern U32 HCLK;
extern U32 PCLK;
extern U32 UCLK;



#endif



Now that we have the specific numbers of several system clocks, we can configure the peripheral clocks well.

 

Note that when setting the system clock, if the HCLK is too large, the SDRAM value will not keep up. To solve this problem, Samsung has proposed such a solution, please pay attention to it:


Keywords:S3C2440 Reference address:Detailed explanation of S3C2440 clock system

Previous article:Detailed explanation of S3C2440 hardware IIC
Next article:Detailed explanation of S3C2440 external interrupt system

Recommended ReadingLatest update time:2024-11-16 12:56

Basic use of s3c2440 serial port
How to write UART program? 1. Serial port initialization Step 1: Set the pin ① Set the pins for the serial port. GPH2, 3 for TX0, RX0 Clear the bit, then set ② Set TX0 and RX0 internal pull-up, that is, configure the GPHUP register step2: Set baud rate (UBRDIV0) — 115200 == PCLK = 50MHz = UBRDIV0 = 26 ① Set UCON0 - Se
[Microcontroller]
S3C2440 bare metal ------- exception and interruption __ concept introduction and processing flow
1 The concept of interrupts and exceptions Let's take an example to illustrate how the CPU handles exceptions. 2. Processing Flow
[Microcontroller]
S3C2440 bare metal ------- exception and interruption __ concept introduction and processing flow
s3c2440 bare metal-memory controller (2. Connection of different bit width peripherals and CPU address bus)
Connection of devices with different bit widths Let's first take a look at how the peripheral ROM is connected to the CPU address bus in the 2440 chip manual. Connection between 8bit rom and CPU address line Connection between 8bit*2 rom and CPU address line Connection between 8bit*4 rom and CPU address line Con
[Microcontroller]
s3c2440 bare metal-memory controller (2. Connection of different bit width peripherals and CPU address bus)
Getting Started | Analysis of the S3C2440 boot process
The S3C2440 startup process is a difficult point and not easy to understand. The understanding of the S3C2440 startup process affects the subsequent analysis of the bare metal code execution process, thus showing the importance of the S3C2440 startup process. S3C2440 startup mode and startup mode selection Search f
[Microcontroller]
Getting Started | Analysis of the S3C2440 boot process
s3c2440 porting Linux kernel, porting Linux-3.4.2 kernel to S3C2440
1. BootLoader boot kernel process 1. Bootloader Work 1.1. Read the kernel into memory 1.2. Save the kernel startup parameters to the specified location, and parse the parameters at this location when the kernel starts 1.3. Start the kernel and pass in the machine ID 2. Kernel startup process The primary purpose of t
[Microcontroller]
s3c2440 bare board_interrupt architecture
S3C2440 has a total of 60 interrupt sources, of which 15 are sub-interrupt sources, which correspond to each bit in the SUBSRCPND register, and the other 45 interrupt sources correspond to each bit in SRCPND. It should be noted that EINT4~7 correspond to the same bit SRCPND , and EINT8~23 also correspond to SRCPND
[Microcontroller]
s3c2440 bare board_interrupt architecture
s3c2440 memory management unit MMU study notes
I learned about the S3C2440 memory management unit MMU, mainly referring to the "Complete Manual for Embedded Linux Application Development" (download at http://www.linuxidc.com/Linux/2011-01/31114.htm ). There are two articles that also explain it in detail, namely http://www.linuxidc.com/Linux/2011-09/43526.htm  and
[Microcontroller]
s3c2440 memory management unit MMU study notes
Detailed explanation of Uboot transplantation on S3C2440 (Part 2)
1. Transplantation Environment Host: VMWare--Fedora 9 Development board: Mini2440--64MB Nand, Kernel: 2.6.30.4 Compiler: arm-linux-gcc-4.3.2.tgz u-boot:u-boot-2009.08.tar.bz2 2. Transplantation Steps 4) Prepare to enter the second stage of u-boot (add support for Nor Flash on our developm
[Microcontroller]
Detailed explanation of Uboot transplantation on S3C2440 (Part 2)
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号