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.

CC2540 ADC sampling while transmitting

Other Parts Discussed in Thread: CC2540, CC2541

Hi,

Im sampling a signal using the ADC at a rate of 300Hz (and is triggered by a timer). The samples are copied by DMA and I receive an interrupt every 10 samples. At that point, I transmit the data.

Is there a way to synchronize between the ADC and the transmission ? as the ADC is sampling at a fixed rate, im assuming that the OS may decide to transmit exactly in the middle of a sample.

Is there any way to prevent the cc2540 to transmit while an ADC sample is progress ? I am experiencing errors while sampling an there is a transmission in progress.

Or is there a way to flush the transmission buffer so that it will transmit immediatly, rather than wait for packets to be accumulated? 

Thanks,

Yadid

  • Hello Yadid,

    I have not used the ADC with the DMA, so I am only making an alternative suggestion.  If you are using the ADC with BLE, then you could use the same code as that is used to measure the battery voltage and then set the BATTERY_CHECK_PERIOD to 3.  In the (event & BATTERY_CHECK_EVT) you could read the ADC every time the event occurs and then have a counter so that on the 10th read, the data is sent.

    You can either average the ten reads and send it or send all ten reads.  Using Packet Sniffer, you can verify that the data is being read and sent during that time interval.

    Thanks,

  • Reading the ADC from an event does not provide accurate timing. I need to sample the signal at exact intervals with as little delay and jitter as possible.

    The OS times tasks only in an approximate manner and cannot be used for this purpose.

    Yadid

  • Maybe a TI employee can answer my question ?

    Yadid

     

  • Hi Yadid,

    Is the issue that you want to _not_ send until a specified amount of samples have been read? Or do you not want the RF to interfere?

    In any case, the RF events will occur periodically whether you want to or not, since that's the way BLE connections work.

    You can use the below function, defined in hci.h after a connection is etablished to set up a OSAL event to be triggered after an event has taken place (actually after post-processing of that event is complete)

    extern hciStatus_t HCI_EXT_ConnEventNoticeCmd( uint8 taskID, uint16 taskEvent );

    For more detailed timing, you can use the function defined in ll_sleep.h, and used in _hal_sleep.c:

    void  LL_TimeToNextRfEvent( uint32 *sleepTimer, uint32 *timeout );

    Where timeout is the number of sleep timer (32768Hz) ticks until the next RF event i scheduled.

    Best regards,
    Aslak 

  • Hi Aslak,

    I appreciate your help.

    I don't want the ADC to sample while there is RF transmission as it can interfere.

    My problem is that im sampling a biophysiological signal at an exact  sample rate so, once I start sampling I can't just pause before there is about to be a transmission.

    That's why I wanted to know if there is a way to delay the RF event so that they will occur between the samples.

    Im pretty sure there must be some standard method to sample ADC at a fixed rate and not have the RF interfere.

    Thanks,

    Yadid

  • You can use another controller to for running your program and use the BLE only for sending the data.

    If you look at the bio senor examples, they use an MSP430 as the main controller and the CC2541 as the BLE transmitter.

    Or, you can switch to the CC2541 and then turn the radio off and do your measurements then turn it back on to transmit.  This means that there will be an interval where you do not take measurements.

    Thanks,

  • Running another controller will increase the BOM, power consumption, and additional board space - so it is not an optimal solution.

    Not sampling for an interval is not an option, as I must sample continuously and at a constant rate.

    Yadid

  • Well, you may have to change your sampling interval to accommodate using a BLE SoC.

    You may have to do it in intervals, store the data in RAM during the measurement interval, then transmit.  Or use two devices in tandem, while one is sampling the other transmits.

    Following the suggestion by Alask and writing tighter code to accommodate BLE is, to my limited knowledge on the subject, your only way out of this.  

    Thanks,

  • Let assume Im sampling once every 4 milliseconds. And transmitting the data after 10 samples are collected. How can I cause the bluetooth communication to take place only between the samples?

    Yadid

  • Aslak provided the exact methods to use in order to accomplish your task.

    I cannot write the code for you...that would require the signing of documents and the exchange of currency.

    Now close out this threat with a verify and then come back if you are having difficulties with you new code.

    Thanks,

  • Hello,

    couple of ideas

    Check into disableHalt command. This will keep CPU active during rf.

    Slave latency may also help, as the slave will not wake up and transmit on connection interval if there is no data in the tx buffer. This with timetonextrf may be useful.

    Greg

  • Thanks for the information, It sounds like I have everything I need to try and solve this.

    Yadid

  • Hi Greg,

    Can you point me to documentation on the disableHalt command ?

    I could not locate it in any of the TI API documents.

    Thanks,

    Yadid

  • Found it  - Apparently it was not available in BLE1.2 but only in 1.3 

  • Hi Yadid, 

    Can you post your code here for reference? and trying to do the same thing? 

    And did u solve the problem you were having.

    Thank you.

    Joseph.

  • Hi Joseph,

    I have not implemented it yet, but I found that most my problems were solved by calling disableHalt in the initialization of the system.

    This prevents the CPU for halting when the radio is transmitting.

    Yadid

  • Hi Yadid,

    I was talking about the code you use in sampling and copying to DMA and interrupt.

    I am doing something similar and i have not been able to get it to work.

    Thanks

    Joseph.

  • Joseph,

    I used this code from the TI web site:

    http://processors.wiki.ti.com/index.php/CC25xx_CC11xx_SoC_Example_Codes

    Yadid