Research on Auxiliary Clock of AT91RM9200 Platform

Publisher:532829319hmkLatest update time:2012-09-22 Source: 单片机与嵌入式系统应用 Keywords:AT91RM9200 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

In VxWorks, the implementation of the timer mechanism is based on the clock. Different timing mechanisms can be selected according to different requirements, such as taskDelay(), WatchDog, and auxiliary clock . The first two timings are based on the system clock.

taskDelay() is the simplest delay method. Its unit is tick, so its delay accuracy is not high, but it is sufficient for systems with delays of more than 10 ms. Using taskDelay(), the called task can be transferred from the ready state to the sleep state, but it cannot be used in interrupt service routines. In addition, by calling taskDelay(0), the CPU can be handed over to other tasks of the same priority in the system.

The watchdog timer is maintained as part of the system clock interrupt service routine. Therefore, the functions associated with the watchdog timer run at the system clock interrupt level, and the delay unit is tick. If the application requires multiple watchdog functions, wdCreate() can be used to generate independent watchdog IDs for each requirement, because for a given watchdog ID, only the most recent wdStart() is valid. With the watchdog timer, the calling task will not be blocked because the wdStart() call returns immediately. But it is generally only suitable for systems with a delay of more than 10ms.

If a higher precision timing (such as 1 ms) is required in practice, then the use of auxiliary clock is a very desirable method. Generally, auxiliary clock is not configured in the BSP of VxWorks system. This article introduces the configuration and use of auxiliary clock in detail so that it can be used flexibly in practice.

1 AT91RM9200 Industrial Platform Clock and Timer

The research in this paper is based on the AT91RM9200 industrial platform, so it is necessary to first introduce the clock and timer under this platform.

AT91RM9200 provides two 3-channel 16-bit timer/counters (TC). Although the three channels are independent, they operate in the same way. Each channel is user-configurable, including three external clock inputs (XC0, XCl or XC2), five internal clock inputs (TIMER_CLOCK1, TIMER_CLOCK2, TIMER CLOCK3, TIMER_CL0CK4, TIMER_CLOCK5), and two multi-function input/output signals that can be configured by the user. In addition, each channel can work in two different modes, namely capture mode and waveform mode. Among them, the capture mode provides signal measurement, and the waveform mode is used to generate waveforms, which can be programmed by the WAVE bit of the TC channel mode register. The block diagram of the timer/counter is shown in Figure 1.

Timer

Among them, if the channel signal is selected, XCO, XCl, and XC2 represent three external clock inputs; TIOA and TIOB represent two multi-function input/output signals acting on each channel; INT represents interrupt signal output; and SYNC represents synchronous input signal. If the block signal is selected, TCLKO, TCLKl, and TCLK2 represent three external clock inputs; TIOAO~TIOA2 represent the TIOA signals of channels 0 to 2, and TIOB0~TIOB2 represent the TI0B signals of channels 0 to 2.

Among them, the five internal clock inputs are related to the main clock (MCK), the slow clock (SLCK) and the clock after the main clock is divided, as listed in Table 1.

5 internal clock inputs and master clock

2 Configuration of auxiliary clocks in VxWorks

If you want to use the auxiliary clock in the VxWorks operating system, you must go through certain configurations before you can use it. First, you need to define it in the VxWorks component or config.h:

#define INCLUDE_AUX_CLK

If it is not defined, the auxiliary clock cannot be used. In addition, the auxiliary clock needs to be initialized in the sysHwlnit2 function of sysLib.C, that is, the interrupt connection configuration:

(void)intConnect(AUX_TIMER_INT_VEC, sysAuxClkInt, O)

The difference between the auxiliary clock and the system clock is that the auxiliary clock must be provided by the user in the ISR, but calling tickAnnounce() in the ISR is not allowed, otherwise it will disrupt the system clock mechanism.

The configuration of the auxiliary clock can be modified according to the function template in installDir/target/drv/timer/templateTimer. C. The driver used in this article is At91Rm9200timer. c, and the header file is At91Rm9200timer. h. The modifications made in this file need to be made according to the specific chip it depends on, that is, it is necessary to refer to the AT91RM9200 chip data sheet.

The functions related to the auxiliary clock are: sysAuxClkInt(), sysAux-ClkConnect(), sysAuxClkDisable(), sysAuxClkEnable(), sysAuxClkRateGet() and sysAuxClkRateSet(). Among them, sysAuxClkRateGet() can be regarded as a group with sysAuxClkRateSet(). sysAuxClkRateGet() reads the clock frequency set by the sysAuxClkRateSet() function, and the clock frequency setting in the sysAuxClkRateSet() function is limited by AUX_CLK_RATE_MIN and AUX_CLK_RATE_MAX. This maximum and minimum value needs to be defined, and the definition location may be different. Some are placed in eonfig.h, and some are placed in bsp.h. The maximum and minimum values ​​in this article are defined in Inte-grator.h. The next two functions that need to be discussed are sysAux-ClkInt() and sysAuxClkEnable().

The sysAuxClkInt() function calls the user-defined interrupt processing function, and the interrupt processing function called by the user is connected by the sysAuxClkConnect() function. Before calling the interrupt processing function, you must first clear the interrupt operation, such as:

AMBA_TIMER_READ(AMBA_TIMER_T2SR(AMBA_TIMER_BASE), temp);

Otherwise, the CPU will be stuck in interruption and cannot do anything else.

[page]

A lot of other work is done in the sysAuxClkEnble() function. According to the specific situation of AT91RM9200, select one of the five internal clocks, here select TIMER_CLOCK2; according to the channel concept mentioned above, select the second channel. It must be distinguished from the system clock. You cannot select an internal clock and the same channel at the same time.

First, you need to determine whether the auxiliary clock is configured in the power management . You can check the relevant files. If it is not configured, you need to configure it as follows:

AT9l_SYS→PMC_PCER=l<

Secondly, the AIC must be programmed first, and then the TC is configured.

Then, it is necessary to control the specific registers. First, the internal clock needs to be selected, as shown in Figure 2.

Select internal clock

Control the channel mode register:

AMBA_TIMER_WRITE(AMBA_TIMER_T2MR(AMBA_TIMER_BASE), TIMER_CLOCK2| TC_CPCTRG);

The second internal clock is selected through the TCCLKS bit, and the RC comparison trigger is enabled according to the timer value written into the RC register. At the same time, the TC channel control register needs to be controlled to write the counter clock enable command and software trigger command, such as:

AMBA_TIMER_WRITE(AMBA_TIMER_T2CR(AMBA_TIMER_BASE), TC_CLKEN);

AMBA_TIMER_WRITE(AMBA_TIMER_T2CR(AMBA_TIMER_BASE), TC_SWTRG);

In addition, since the RC register is used to trigger the enable, it is also necessary to control the TC interrupt enable register and write the RC comparison interrupt enable signal, such as:

AMBA_TIMER_WRITE(AMBA_TIMER_T2IER(AMBA_TIMER_BASE), TC_CPCS);

Finally, the interrupt enable operation needs to be performed, such as:

AMBA_TIMER_INT_ENABLE(AUX_TIMER_INT_LVL);

After everything is configured, recompile bootroFll and VxWorks image, start VxWorks image; then write a test program to test and verify whether the auxiliary clock is configured successfully. In addition, the auxiliary clock interrupt can be checked through a logic analyzer. After the auxiliary clock is driven, the sysAuxClkRateSet() function can be used in the application to dynamically set the number of interrupts per second of the system auxiliary clock; the sysAuxClkConnect() function specifies the ISR for the system auxiliary clock interrupt, and the sysAuxClkEnable() function enables the clock interrupt to call the specified ISR.

Conclusion

The main purpose of VxWorks providing the system auxiliary clock mechanism is to allow users to choose an additional timing resource besides the system clock and provide management means. In addition, some auxiliary debugging tools of VxWorks may also require the use of the system auxiliary clock.

The use of auxiliary clock is achieved by increasing the beat rate, and increasing the beat rate means that clock interrupts are generated more frequently, so the interrupt handler will be executed more frequently. This will bring the following benefits to the entire system:

①Higher clock interrupt resolution can improve the resolution of time-driven events;

② Improved the accuracy of time-driven events.

Keywords:AT91RM9200 Reference address:Research on Auxiliary Clock of AT91RM9200 Platform

Previous article:Multi-channel USB2.0 data acquisition system based on AT91SAM7X
Next article:Characteristic Analysis and Application of Synchronous Serial Port SSC of AT91RM9200 Processor

Recommended ReadingLatest update time:2024-11-16 21:38

USB host Linux driver based on AT91RM9200
Universal Serial Bus (USB) is a new computer peripheral serial communication interface standard. It overcomes the defects of traditional computer serial/parallel ports and has the advantages of hot plug, plug and play, reliable data transmission, convenient expansion and low cost. It has become one of the necessary
[Microcontroller]
USB host Linux driver based on AT91RM9200
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号