## gumstix-users

 [Gumstix-users] Poll robostix ADC at regular interval From: Takashi - 2009-04-04 18:27:51 ```Hi, I have a connex, wifistix, and a robostix, and I want to poll recursively a ADC channel on the robostix (which is connected to an external sensor) at a fixed frequency (say 600Hz). Could someone explain how I could achieve this? How do I ensure the ADC channel is sampled at exactly the specified frequency from the gumstix? Thanks. Takashi -- View this message in context: http://www.nabble.com/Poll-robostix-ADC-at-regular-interval-tp22886435p22886435.html Sent from the Gumstix mailing list archive at Nabble.com. ```
 Re: [Gumstix-users] Poll robostix ADC at regular interval From: Dave Hylands - 2009-04-05 02:41:22 ```Hi Takashi, > I have a connex, wifistix, and a robostix, and I want to poll recursively a > ADC channel on the robostix (which is connected to an external sensor) at a > fixed frequency (say 600Hz). > > Could someone explain how I could achieve this? How do I ensure the ADC > channel is sampled at exactly the specified frequency from the gumstix? I'd setup a timer which generates an interrupt at the desired frequency. I'd make the ISR handler initiate the ADC sample. Since the gumstix clock runs at 16 MHz, you need to generate an ISR once every 26667 ticks, which is almost 600 Hz (599.993 Hz), or once every 26666 ticks, which is 600.015 Hz. If you use one of the 16 bit timers, with a prescalar of 1, then you can use WGM mode 4 (see page 133 of the ATMega128 datasheet) and set one of the OCR registers to 26666 or 26667 to get the interrupt generated at the desired rate. -- Dave Hylands Shuswap, BC, Canada http://www.DaveHylands.com/ ```