how to use ADC dynamic in SAM B11

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

I'm new user with ATMEL chips, I have a sam B11 Xplained pro and I use HTP Temp example with google smart app, it work fine. I want to replace the reading of temperature sensor by analog input. When i run my modification it work 10 times and it bloc. I use ADC example for sam B11 Xplained but in this example the reading of analog input is done only once on startup.

This topic has a solution.
Last Edited: Wed. Jan 11, 2017 - 01:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

Is it possible to make a ADC measure every max 100ms with this SAMB 11 module and send it on bluetooth ?

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have resolved my problem, after converting I deactivate my ADC and I re-activate and re-init it when I want read analog value. I read at 50Hz.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

Can you show you how did you do that? I am trying to read a data from temperature sensor connected to the GPIO_MS1, 2, 3, or 4, different configuration in ATMEL START, and what I get is 1D and no mater if something is connected to that pin or not

what Iam doing is: enable the channel , read the channel and print on serial port. is that all?

int main(void)
{
    system_init();
    atmel_start_init();
    USART_0_test();

    adc_sync_enable_channel(&ADC_0,GPIO_MS3);
    adc_sync_read_channel(&ADC_0, GPIO_MS3, (uint8_t*)&adc_values, 2);
    io_write(io1, adc_values, 2);

}    

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I also stuck with the same issue. I am able to read adc once after initialization. But after that it's not able to read the adc value.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does your program hang on adc_get_status?

Mine does every time, I tried skipping this in tdm_mode_adc_read, but then it just keeps giving me the same value.

I've also tried disabling and enabling at the start and end of each sequence of reads, which stops it from hanging, but its exactly the same as removing get_status, it doesn't hang, but it's value doesn't change.

Edit:
 

bdb wrote:

I have resolved my problem, after converting I deactivate my ADC and I re-activate and re-init it when I want read analog value. I read at 50Hz.

Just read this, when I tried I didn't reinitialize, only re-enabled. So I'll try again.
Do you really think this is a good solution though? I'd leave it unsolved so maybe we can actually get to the bottom of this.

Last Edited: Tue. Apr 23, 2019 - 04:56 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Everyone, 

 

I created this account just to post this because I've been having the same issue and its driving me insane. I'm trying to create a wireless controller with analog sticks on it and I want the control to be very responsive.  Naturally, one of the first things I did before moving to bluetooth is to get the ADC working.  After trying and failing to get the time division multiplexing mode working, I thought i'd move to something simpler.  So, I selected a single channel and tried to get it to read as fast as the ADC module would allow, no delays in my main loop.  It works for about 1.5 seconds after initializing, maybe less, and then just blocks, hanging in "adc_get_status" function within the adc_read() function.  

 

The normal operation of the ADC status bit is to sit at 0 while the conversion is taking place, and to set to 1 when the conversion is complete.  The function, for some reason which I can't figure out, first waits for the ADC Done bit to go High, and then waits for it to go LOW again before actually reading the result registers and returning the value.  Why would that be? A good question to answer is - What is the default state of this bit when no conversion is active? Maybe they're trying to avoid lockup in that scenario. Is this function really suitable to read the ADC at high frequencies without having to stumble over the initialization process and burning massive amounts of clock cycles? 

 

Perhaps a better theory lies in the introduction paragraph to the ADC chapter of the spec document, chapter 22, which mentions that the BLE firmware on the device uses the ADC 'periodically' in order to take measurements that help it conserve power, and that if the user wants to use the ADC, they have to disable this feature before using it.   However, they provide NO details whatsoever on how the BLE firmware uses the ADC, or how to disable it.  There is a chapter on BLE (8), but it only contains high level descriptions of what its Bluetooth capabilities are.

 

Here is the paragraph from chapter 22 of the spec on the ADC that I'm referencing. 

 

" The Bluetooth Low Energy ROM firmware uses the ADC to measure temperature and battery voltage to do periodic clock calibration. When user application requires ADC, it is required to disable this periodic measurement before using ADC. When the application completes with the measurement, enable the periodic measurement. For more details on API, refer to the BluSDKSmart API reference guide"

 

Again, I'm still hunting for this information on how to follow their infuriatingly vague instructions here that seem rather critical.  (And no, its not in the document that they reference)

 

However since the initialization sequence seems to free up the module for another brief period of time, obviously there's a bit somewhere that can be toggled to fix the issue, I'm going to do some digging and figure out which. I'll update once i figure it out. 

-Josh

Last Edited: Tue. Nov 26, 2019 - 03:45 AM