Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

8 khz sampling


Hello to everyone.

I’m trying to sample an audio signal at a frequency of 8 kHz. Is there a way to control Wixel in order to do this? Actually I’m wondering about a function like getMicroseconds() in order to write an application similar to “test_adc” offered with the Wixel SDK.

Other ideas? It could be that I’m approaching the problem in the wrong way…




Hello, Tapisge.

The Wixel SDK does not provide any functions to help you schedule tasks that need to happen more than once per millisecond. However, you could look at time.c in the Wixel SDK to see how the timekeeping is implemented there. Timer 4 counts up and overflows from 187 to 0 approximately every millisecond. In your application, you could consider either reading the value of T4CNT or setting up a different timer and using that to schedule your ADC readings.



Hello David, Thank you for your reply.

I’m trying to adopt interrupt, but maybe I fail something.
I wrote a simple application that, theoretically, swaps the status of the pin P1_7 every 1 ms.
I simply replicated on timer T3 same data of timer T4 in order to obtain an interrupt at every millisecond. The interrupt service subroutine simply switches the status of the pin P1_7.
With an oscilloscope, I should see the square wave, but I observe two continuous orizontal lines, as if the pin were changing level too much fast. I post my code…


#include <wixel.h>
#include <usb.h>
#include <usb_com.h>
#include <stdio.h>

ISR(T3, 0){
    	P1_7 = !P1_7;

void main(){


    T3CC0 = 187;
    T3IE = 1; // Enable Timer 3 interrupt. (IEN1.T4IE=1)

    // DIV=111: 1:128 prescaler
    // START=1: Start the timer
    // OVFIM=1: Enable the overflow interrupt.
    // MODE=10: Modulo
    T3CTL = 0b11111010;

    EA = 1; // Globally enable interrupts (IEN0.EA=1).



I tried your code here and it works as expected. I suspect there is an issue with either the triggering or the horizontal scale on your oscilloscope.



Oh… Sorry! You are in right, there was a problem with the probe cable. Thank you for your suggestion!

[quote=“DavidEGrayson”]I tried your code here and it works as expected. I suspect there is an issue with either the triggering or the horizontal scale on your oscilloscope.



I re-up this post because I found an application note from Texas Instrument that aroused me a question about timing of adc conversion.

In adh.h I read that ADC_BIT_12 impose a decimation rate of 512, and the conversion took 132 microseconds. 132 microseconds period correspond to a sampling rate of 7.58 kHz.

In the Design Note DN402 http://www.ti.com/lit/an/swra138/swra138.pdf I read that it is possible to implement an audio loopback using a sampling frequency of 8kHz and using a resolution of 13 bit. How is it possible? I also note a different configuration of the ADC…



I think the comments about the ADC resolution in section 3 of Design Note DN402 are wrong. The documentation of the CC2511F32 ADC registers in the datasheet clearly shows that the maximum resolution of the ADC is 12 bits. Because the ADC reading they are performing is always positive, you lose one bit and will have a resolution of 11 bits. You could contact Texas Instruments to ask them about it.