Toggling GPIO at 38Khz

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jon Smirl
Date: Tuesday, October 7, 2008 - 8:43 pm

I'm working on getring the LIRC IR subsystem integrated into the
kernel. One common IR hardware implementation is based on standard
serial ports. It uses the serial port's DCD and DTR as GPIO pins.
This common IR hardware does not have a transmit modulator and is
modulating the IR signal in software. Luckily is has hardware
demodulation.

There are four common IR frequencies - 36Khz, 38Khz, 40Khz, 56Khz. I
need to create these frequencies in software. Data is then transmitted
as 400-600us burst of these frequencies. Around 10-30 clock pulses.

So how do I reliably generate 38Khz without destroying latency in the
system? I also don't want to measure the speed of the code I'm
executing - same code has to run on 90Mhz ARM and 3Ghz Core2. If a do
a loop with nanosleep() I need to know how fast my code is to subtract
it's execution time form the sleep time. The existing LIRC code works
this way and measures it's timing loop.

hrtimers look promising, but hrtimers doesn't have a periodic API. Is
there a technique for creating periodic timing that doesn't accumulate
error caused by rescheduling the timers?  If I need to send 30 pulses
of 38Khz, it is more important that the total time be (1/38000)*30 =
0.7894ms than it is for each pulse to be generated at exactly 26.3us
intervals.

Are there other techniques for generating pulse trains in the 36-56Khz
range on a simple GPIO pin? Anyone have some sample code?

-- 
Jon Smirl
jonsmirl@gmail.com
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Toggling GPIO at 38Khz, Jon Smirl, (Tue Oct 7, 8:43 pm)
Re: Toggling GPIO at 38Khz, Eric Miao, (Tue Oct 7, 11:40 pm)
Re: Toggling GPIO at 38Khz, Bill Gatliff, (Wed Oct 8, 5:01 am)
Re: Toggling GPIO at 38Khz, Jon Smirl, (Wed Oct 8, 6:06 am)
Re: Toggling GPIO at 38Khz, Chris Friesen, (Wed Oct 8, 10:00 am)
Re: Toggling GPIO at 38Khz, Remy Bohmer, (Wed Oct 8, 11:57 am)
Re: Toggling GPIO at 38Khz, Krzysztof Halasa, (Wed Oct 8, 2:58 pm)
Re: Toggling GPIO at 38Khz, Dave Hylands, (Wed Oct 8, 3:24 pm)
Re: Toggling GPIO at 38Khz, Bill Gatliff, (Wed Oct 8, 7:26 pm)
Re: Toggling GPIO at 38Khz, Andy Green, (Thu Oct 9, 1:38 am)
Re: Toggling GPIO at 38Khz, linux-os (Dick Johnson), (Thu Oct 9, 10:53 am)