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