This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL-CC2640R2: Having trouble changing the sampling rate for the ADC.

Part Number: LAUNCHXL-CC2640R2

Tool/software: Code Composer Studio

Having trouble changing the sampling rate for the ADC. The fastest input signal ADC can sample right now is only 1 or 2 Hz, which is not useful at all. And once the input signal has a frequency higher than 5Hz, the data that ADC samples just do not seem correct. Also, in Sensor Controller Studio, how do I make the minimum task iteration smaller than 10ms?

The code I use is an example code that is called    rfWsnNode_CC2640R2_LAUNCHXL_tirtos_ccs. I attached part of the code that is from NodeTask.c at the bottom. I did not change anything and it is straight from the example code. This code also will read the output from Sensor Controller Studio, which I also attached below.

  • Hi Yiren,

    It seems you are using the quickest sampling time for the ADC, 2.7 us, which is what I assume you want to do. The application you look at is setup to run on RTC based scheduling. This means that the "fwScheduleTask(1)" define the number of "ticks" until it should run again.

    This tick interval is connected to the RTC tick but it is not a 1 to 1 ratio, instead you yourself configure the number of actual RTC ticks that one of the Sensor controller ticks should correspond to. If you look at the "SceAdc_init()" function in the example you refer to you can find that they use "samplingTime" to setup this tick variable -> scifStartRtcTicksNow(samplingTime);

    i would suggest that you try out the "Run-time Logging" feature in Sensor Controller Studio to test out your code. You could look at alternative implementations in Sensor Controller Studio as there is multiple ADC examples there.

  • Hi,

        I still have some questions. Before I ask, let me explain a little bit of what my goal is. So my goal is to connect an analog output sensor to Pin23, which is one of the ADC pin on Micro controller. I hope to be able to modify my code in sensor controller studio so that it will be able to sample faster frequency signal. And then I want to have the code at sensor controller studio be able to output to the code at CCS, which I attached above called Nodetask.c. As of now, I will try Run-time Logging, but the thing is what baudrate do I choose? What Pins do I choose for RX pin and TXpin, and how do I hook up with my analog output sensor? Thanks.

  • Hi Yiren,

    The maximum sample rate is 200k Samples/s but the actual speed depend on how you configure and use the HW. As for Run-Time logging, you can use the default baudrate, the RX/TX pins is those of the launchpad which should be DIO2/3 if i remember correctly for your platform. 

    Note that you need to add the "rtlLogStructs()" API in the code to dump the data over the serial lines (otherwise you will not get any data out). You should do this call before you schedule the next run.