Introducing the arm9 clock and timer

**Preface** This article mainly discusses the clock and timer system of the ARM9 processor, specifically focusing on the S3C2440 microcontroller. Based on Chapter 7 of the S3C2440 manual, this content covers various key topics such as power management, clock generation, USB clock, camera interface, and more. I will go into detail about these aspects in the following sections. **Introduction** The system clock is the core component that drives the entire circuit. Understanding the structure of the system clock is essential for working with peripherals like timers, UARTs, and other modules. The S3C2440 processor has four main clock signals: FIN, FCLK, HCLK, and PCLK. - **FIN**: External crystal input frequency, typically a low-frequency signal to avoid interference. - **FCLK**: Clock used by the CPU core. - **HCLK**: Clock for devices connected via the AHB bus, such as memory controllers, LCD controllers, and DMA units. - **PCLK**: Clock for peripherals connected via the APB bus, such as timers, UARTs, and ADCs. **Clock Structure** The S3C2440 system clock is divided into two parts: an external input and an internal phase-locked loop (PLL) that multiplies the external frequency to generate the required internal clocks. The external clock is usually lower to reduce noise and interference, as shown in the diagrams below. [Image 1: Clock Input and PLL Structure] [Image 2: Clock Division and Distribution] [Image 3: CLKDIVN Register Description] [Image 4: MPLLCON Configuration Example] The **CLKDIVN** register controls the ratio between FCLK, HCLK, and PCLK. For example, setting CLKDIVN to 0x03 divides FCLK by 1, HCLK by 2, and PCLK by 4. If HDIVN is non-zero, the CPU must switch from "fast bus mode" to "asynchronous bus mode." **Code Example** Here’s a sample code snippet for initializing the clock: ```c LOCKTIME = 0x00ffffff; // Use default value CLKDIVN = 0x03; // FCLK : HCLK : PCLK = 1 : 2 : 4 MPLLCON = ((0x5c << 12) | (0x04 << 4) | 0x01); // Set up PLL // Switch to asynchronous bus mode if needed __asm__ { mrc p15, 0, r1, c1, c0, 0 orr r1, r1, #0xc0000000 mcr p15, 0, r1, c1, c0, 0 } ``` **Timer Overview** The timer is a peripheral connected to the APB bus and runs at the PCLK frequency. The S3C2440 has five 16-bit timers, with timers 0–3 supporting PWM functionality. Timer 4 is an internal timer without external outputs. Each timer uses internal dividers to adjust the input clock frequency before starting the counting process. **Timer Working Principle (Example: Timer 0)** To use Timer 0, follow these steps: 1. Load initial values into TCNTB0 and TCMPB0. 2. Set TCON to manually update the timer registers. 3. Start the timer by setting the appropriate bits in TCON. 4. When the counter reaches zero, it reloads from TCMPB0, and the output pin toggles accordingly. **PWM Functionality** By adjusting the comparison value (TCMPB0), you can control the duty cycle of the output waveform. For example, if TCNTB0 is set to 62500 and TCMPB0 is set to 31250, the output will toggle every 0.5 seconds, creating a 50% duty cycle square wave. Changing TCMPB0 alters the duty cycle, enabling PWM operation. **Sample Code for PWM** ```c void timer0_init(void) { TCFG0 = 99; // Prescaler = 99 TCFG1 = 0x02; // Divide by 8 TCNTB0 = 62500; // Trigger interrupt once per second TCMPB0 = 31250; // 50% duty cycle TCON |= (1 << 1); // Manual update TCON = 0x09; // Auto load, start timer } ``` **Conclusion** Understanding the clock and timer systems of the S3C2440 is crucial for embedded development. Proper configuration ensures accurate timing and efficient power management. By mastering these concepts, developers can build robust and reliable embedded applications.

Terminal Blocks Accessories

The JUK universal Screw Terminal Block series has the typical features which are decisive for practical applications:

l The universal foot allows the terminal blocks to be easily snapped onto the NS35 or NS32 DIN Rail with G shape.

l Closed screw guide holes ensure screwdriver operation perfect.

l For terminal block with different wire cross-sectional areas, complete accessories are available, such as end plates, partition plates, etc.

l Potential distribution achieved by fixed bridges in the terminal center or insertion bridges in the clamping space.

l Same shape and pitch Grounding Terminal Blocks as the JUK universal series.

l Adopt ZB marker strip system,achieve unified identification.

Terminal Blocks Connector ,Electric Terminal Blocks Connector,Plastic Terminal Block,F Type Terminal Block Connector

Wonke Electric CO.,Ltd. , https://www.wkdq-electric.com

This entry was posted in on