s3c2440 experiment---timer

Publisher:HeavenlyCloudsLatest update time:2023-09-12 Source: elecfansKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

 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<     INTPND = INTPND;

      }

 

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. ☀   


Keywords:S3C2440 Reference address:s3c2440 experiment---timer

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

Construction of embedded Linux root file system based on S3C2440
Embedded Linux has long been a household name in the IT industry. There is a great advantage in using Linux for embedded product development, which is that the development resources are rich and the cost is low. The embedded Linux operating system is increasingly valued and its application is becoming more and more
[Microcontroller]
Construction of embedded Linux root file system based on S3C2440
PIC16F877A timer
----------------------------------------------------------timer 0----------------------------------------------------------   TMR0 is 8 bits wide, has an optional prescaler, and is intended for general purpose use and can be used for both timing and counting. TMR1 is 16 bits wide and comes with a programm
[Microcontroller]
PIC16F877A timer
s3c2440 bare metal touch screen
1.0, Touch screen and LCD The touch screen and LCD are two independent screens, but there is a correspondence between them. Simply put, a coordinate point on the touch screen corresponds to a pixel point on the LCD. When we press the touch screen, the system calculates the coordinates of the location, and then finds
[Microcontroller]
S3c2440 bus frequency and clock settings in LINUX
The normal operation of many hardware requires the support of bus clock, such as LCD, I2C and other devices. This article analyzes the bus clock of s3c2440 and the related operations of s3c2440 bus clock frequency in Linux. First, analyze the bus clock of hardware s3c2440. 1. FCLK HCLK PCLK of s3c2440: The clock s
[Microcontroller]
Memory Management Unit MMU
The Memory Management Unit (MMU) is responsible for mapping virtual addresses to physical addresses and provides hardware-based memory access permission checks. Modern multi-user, multi-process operating systems use MMU to allow each user process to have its own independent address space: the address mapping function
[Microcontroller]
Memory Management Unit MMU
S3C2440 transplantation uboot supports NANDFLASH operation
In the previous section, we transplanted uboot to support NORFLASH for S3C2440. In this section, we will continue transplanting to support NANDFLASH. Table of contents Compile error Copy s3c2410_nand.c and modify the macro definition to support SC32440 Modify NFCONF, NFCONT in s3c2440_nand.c to support S3C2440 Mod
[Microcontroller]
S3C2440 transplantation uboot supports NANDFLASH operation
The process of porting u-boot-2010.12.tar.bz2 version to s3c2440
1. tar decompression 2. Modify the cross-compilation in the makefile file in the root directory to arm-linux- 3. make distclean 4, make trab_bigflash_connect 5. Modify /uboot/include/config.h, add two macros such as CONFIG_SYS_SDRAM_BASE=0, if not add make will report an error, so add it accordin
[Microcontroller]
uboot-2011.12 ported to S3C2440 (Sequence 1) - ELF executable file and its composition
We can divide executable files into two situations: storage state and running state 1. Storage state: The executable file is burned to the storage medium (flash or disk). At this time, the executable file usually consists of two parts, the code segment and the data segment. The code segment is divided into the executa
[Microcontroller]
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号