Acess ARM9 hardware timers ( C and Linux )

Hello everybody,

I'm new to embedded linux development. I want to write some routines that need 1uS timer resolution. I understand that the ARM9 processors have 16 bit hardware timers.

How do one use these timers in linux from 'C'. Anybody have any example code?

If I was writing is Assembly, as I do with PICS, it would probably be easy.. but this is the first time working with ARM9 and Linux....

Any help or pointers are greatly appreciated...

-Jim

Reply to
JimNorton
Loading thread data ...

On Fri, 10 Apr 2009 16:12:29 -0500, "JimNorton" wrote in comp.arch.embedded:

You have a misunderstanding. There are no 16-bit hardware timers in the ARM9 core.

If you are buying an off-the-shelf chip built on an ARM9 core, from Atmel, or Texas Instruments, or Freescale, or one of many, many others, then it has whatever peripherals the chip maker decided to put on the chip with the core.

I suspect that most off-the-shelf ARM9 microcontrollers would have one or more hardware timers, at least 16 bits and perhaps more likely 32 bits.

You haven't said exactly what you want to use the timers for. Many ARM9 micros have on-chip peripherals to generate PWM waveforms, generate interrupts, and probably do quite a few other things with their on-chip timers.

The first thing you need to do is mention the specific ARM9 based micro you are using. And it would be a good idea to mention exactly what you want to use the timers for.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Reply to
Jack Klein

Hi Jack,

My processor is a Samsung S3C2410A. Datasheet is here:

formatting link

I just want to use a timer to time the reading and writing of some GPIO pins to access some hardware that require uS timing...

I know there is the nanosleep() function in Linux, but I'm not sure how accurate it is compared to accessing a timer by loading it with a value and letting it under or overflow...

I am new to this embedded linux stuff... my experience is with accessing the hardware directly in Assembly without the OS layer...

Any help would be appreciated...

that

16

example

Reply to
JimNorton

The kernel includes a clock framework:

formatting link
include/linux/clk.h

The s3c24xx timers are accessible via this framework:

arch/arm/plat-s3c24xx/pwm.c arch/arm/plat-s3c24xx/pwm-clock.c

Much of the relevant code has Simtec's name on it:

formatting link

nanosleep() is for use by applications. If you're accessing hardware, you probably want to write a device driver.

You may have a fairly steep learning curve ahead. Programming ARM-Linux is likely to be 99% Linux, 1% ARM.

Reply to
Nobody

here:

formatting link

Getting uS timing for a Linux application on ARM9 will be tricky. Linux is not a real-time OS, so it will be difficult for you to ensure that your I/O-pin-manipulating process is scheduled during the correct uS. What if an interrupt handler takes over the CPU just when you wish to toggle the I/O line? Even ignoring Linux, the CPU can give you a few surprises - a cache miss at the wrong moment might be enough to mess your timing up.

Since you know PICs and assembly programming, the easiest solution might be to add a little 8-bitter that handles the timing-critical I/ O, connected to the ARM9 via a serial link (uart, I2C, SPI). Or can the ARM9's timers be used to generate the desired waveform, without SW intervention?

Reply to
Hans Odeberg

Thank you for the great answers here....

formatting link

GPIO

how

and

you

accessing

is

Reply to
JimNorton

Hey that isn't a bad idea... Add a small PIC to do the fast bit banging that is required.. controlled by the ARM via a serial port...

I'll have to think on that one... :-)

here:

formatting link

GPIO

Reply to
JimNorton

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.