A clock is a synchronized beat that synchronizes a working system.
1. There are many ways to obtain a clock
1. External direct input clock signal
2. External crystal oscillator + internal clock generator (low-frequency microcontroller)
3. External crystal oscillator + internal clock generator + PLL + internal frequency divider
2. Internal structure of timer
1. Total clock system
Detailed description: When the 2440 is just turned on, since the PLL has not yet been turned on, FCLK is equal to the external input clock (12MHz). If you want to provide the clock frequency, you must turn on the PLL. PLL is divided into
MPLL and UPLL. Among them, UPLL controls USB, which has nothing to do with this experiment. MPLL is divided into three types of clocks: FCLK (CPU core clock), HCLK (AHB bus device clock), and PCLK (APK bus device clock).
2. Experiment content: Use timer 0 to make the LED light flash at a fixed time
As shown in the figure above: the route for timer 0 to obtain the clock frequency is: PCLK->prescaler->divider->MUX circuit->control logic unit->timer 0
3. Analysis before experiment
Through the above route, we can know that we need to carry out the following steps:
1. Obtain the PCLK clock (since PCLK is separated from MPLL, we need to set the value of MPLL first, and then set the PCLK through frequency division (register CLKDIV))
2. Set the prescaler (TCFG0)
3. Set the frequency divider (TCFG1)
4. Set MUX circuit (default)
5. Set the control unit (TCNTB0)
When using the timer for the first time, you need to set the "manual update" bit to 1 so that the value of the TCNTB0 register is loaded into TCNT0. The number can then be automatically loaded into the register via auto-reload.
4. Core code analysis
1. Initialize the clock
void init_timer(void)
{
//Step one: configure FCLK:HCLK:PCLK
CLKDIVN = 0x03;
/* If HDIVN is non-0, the CPU bus mode should change from "fast bus mode" to "asynchronous bus mode" */
__asm__(
"mrc p15, 0, r1, c1, c0, 0n" /* Read the control register* /
"orr r1, r1, #0xc0000000n" /* Set to "asynchronous bus mode" */
"mcr p15, 0, r1, c1, c0, 0n" /* Write to the control register */
);
//Step 2 : Configure MPLL
MPLLCON = FCLK; //200MHz
//Step 3: Set timer 0. At this time, PCLK is 50MHz
TCFG0 = 99; //Prescaler
TCFG1 = 0x03; //Frequency divider
TCNTB0 = 31250; // Timing time
TCON |= (1<<1);
TCON = 0x09;
//Enable timer 0
INTMSK &= (~(1<<10));
}
2. An interrupt occurs when the timer expires
void irq_timer(void)
{
if(INTOFFSET == 10)
{
GPFDAT &= (~(1<<4));
}
SRCPND = (1<
}
5. Summary
In the timer, the clock configuration of timer 0 is the focus. From PLL to timer 0, there is a lot that needs to be configured in the middle. Especially when setting the reload value for the first time, you need to update it manually. By writing a blog, I have deepened my understanding of the s3c2440 timer. I will insist on continuing to write. ☀
Previous article:Building an ARM development environment based on ADS+J-Link under Windows
Next article:s3c2440——Nandflash
Recommended ReadingLatest update time:2024-11-17 00:49
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Practical Development of Automotive FlexRay Bus System (Written by Wu Baoxin, Guo Yonghong, Cao Yi, Zhao Dongyang, etc.)
- FollowMe Issue 3 - Plant Care Monitor - MicroPython - XiaoESP32C3
- RT-Thread Kernel Implementation and Application Development Practical Guide: Based on STM32
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- N32G45x series MCU development and application records using JLINK RTT
- Award-winning live broadcast|Webinar-High-speed interface testing: PCIe5.0 test solution
- Which textbook should I use when learning C language?
- Energy storage emergency power supply-3D model appreciation
- [Xingkong Board Python Programming Learning Main Control Board] Teach you step by step how to make a real-time weather information board based on Xingkong Board
- Pioneer official engineer's dry goods: HPM6000 series BOOT MODE and external circuit design suggestions
- HPM6000 Series ADC Related Hardware Design Tutorial
- Show off the solar powered Bluetooth keyboard I redeemed on Double Eleven
- Please guide the electric vehicle permanent magnet synchronous motor igbt drive, can the schematic diagram be improved?
- Mulitismim simulates AC source with inductive load current with DC component