I think that the friends who have debugged the driver have been exposed to the clock more or less. Because the clock is indispensable to the device, just as the heart supplies blood to the human body. Some devices have their own clocks, some receive the system's external clock, and the clock source is the cornerstone of the device's operation.
Therefore, detecting whether the clock is working is one of the keys to debugging the device. In this article, I will give you an effective clock debugging method —— no need to use the tester, but use the software method.
I will talk about the clock problem I encountered, and then see how to debug the clock.
The problem occurred when developing mcc (multi-channel controller) driver —— When we tested the driver, we found that no matter how the mcc parameters and trigger devices were configured, the device was self-sustaining, as if it were dead. Therefore the estimated clock is received. After investigation, the clock source mt9045 used by mcc is not set. This clock source will input the mcc input transmission and reception clocks, as well as the synchronous clock.
Because we didn't have enough data to configure the clock at the time, and the clock was really complicated, we were busy for a while and didn't get through it. Therefore, we urgently need to check the correctness of the clock input. If you use a wave tester, you don't know how to pick up the hardware pins (the device is well packaged). Finally, we use a software program to detect the port clock frequency.
static
int frequency_count(volatile unsigned long addr, unsigned int mask )
{
int t, nt, et ;
int v, lv, cnt;
t = Gettick();
while ( 1 )
{< Br>
nt = Gettick();
if ( nt != t )
break;
}
et = nt + GetsysClkRate ();
cnt = 0;
lv = v = (*(int*)addr) & mask;
while ( 1 )
{
nt = Gettick();
if ( nt >= et )
break;
v = (*(int*) Addr) & mask;
if ( v != lv )
{
lv = v;
cnt++;
}
}
return cnt/2;
}
The calculated values of the above program are approximate - when the system When the cpu frequency is about fast, the accuracy is about - the mechanism is left for everyone to understand.
The usage of the function is very simple. When detecting a clock output, that is, whether a pin on a particular address line (a software angle is a bit) generates a frequency, only the address address and the output pin mask of frequency_count are required, such as address 0xfdf90d50. The 0th bit is passed to 0xfdf90d50, 0x00000001. The function outputs the time frequency value.
Be aware that there are two helper functions. One is Gettick, which is used to get the current tick value of the system; the other is GetsysClkRate to get the system tick frequency.
The above functions can be implemented as follows in a Linux system.
static int Gettick()
{
return (int)jiffies;
}
< Br>
static int GetsysClkRate ()
{
return (int)HZ;
}
The above functions for the vxWorks system can be implemented as follows
static int Gettick()
{
return tickGet();
}
static int GetsysClkRate ()
{
return sysClkRateGet();
}
(1) Ifconfig command The first type uses the ifconfig command to configure the ip
Windows CE is an embedded operating system developed by Microsoft that can be used in a variety of e
This tutorial gives examples of how to provide messages/dialogs in Bash Shell scripts using tools l
Too many open files Errors are common faults in Linux systems. Solutions can be easily found on the
Yum error Error: Cannot find a valid baseurl for repo: addons
There are several ways to log in to Linux on Windows platform:
Get the current system time with C under Linux
View/Modify Linux Time Zone and Time
Linux history (history) command usage detailed
Linux shell awk get external variables (variable value) Introduction
Debian shows garbled (diamond, square) solution
Linux centos lnamp environment installation notes
Linux shell flow control (condition if, loop [for, while], select [case] statement instance
Microsoft Office 2013 Office Suite March 31 or coming to
Windows7 can not open the desktop file directly how to do
Using windows7 resource manager to quickly find files
Win7 removes the program that comes with it but is not commonly used
Win7 system computer does not insert U disk but display usb icon how to do
Tips for sharing: Easily send and receive faxes in Win XP
Vim tools commonly used in Linux
Windows 7 Comic Album: Protecting Online Shopping Security (5)
How does Windows 8.1 connect to a second monitor or projector?
Registry Unlocking Use the tool to convert reg format and bat format