ERROR ADDING COMPONENT

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

Hello everybody,

i am working on 3 Analog Sensors which i have connected to Atsamd21-Xplained-Pro Analog Input pins, I have added ADC driver for 1st analog Sensor configured and Renamed it to Sensor Name. I now trying to add one more ADC for my Second Sensor but i get this error 

 

ERROR ADDING COMPONENT

Unable to add ADC

No implementations available for ADC_0 in current context

See picture Below.

 

Thanks

 

 

 

Last Edited: Fri. Dec 8, 2017 - 06:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

ATsamD21J only has "one 12-bit, 350ksps Analog-to-Digital Converter (ADC) with up to 20 channels."  You don't need to add another ADC, you need to determine how Start/ASF sets up the ADC channels.

Greg Muth

Portland, OR, US

Atmel Studio 7 (Version: 7.0.1652) on Windows 10

Xplained/Pro/Mini Boards mostly

 

 

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

Thank you for reply,
Thank you very much for explaining, Can you please tell me how to add channels.?

I have tick two more Analog Inputs and label the pins to Temp and Batt, How can i pass that to 

adc_async_read_channel ();

&

adc_async_start_conversion();

I have got new lines in Driver_init.c

 

gpio_set_pin_direction(Temp, GPIO_DIRECTION_OFF);

 

gpio_set_pin_function(Temp, PINMUX_PA02B_ADC_AIN0);

 

// Disable digital pin circuitry

gpio_set_pin_direction(Batt, GPIO_DIRECTION_OFF);

 

gpio_set_pin_function(Batt, PINMUX_PA10B_ADC_AIN18);

 

 

Thank you 

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

Look for a separate function

int32_t adc_async_enable_channel(
 struct adc_async_descriptor *const descr,
 const uint8_t channel
)

Earlier today I located the ASF4 reference manual here: http://ww1.microchip.com/downloa... . It has documentation for all(?) the different "drivers" that Start/ASF supplies. For the specific function above, look in section 5.2 ADC Asynchronous Driver. Also there's an example in section 5.2.4 Example of Usage.

 

Tip: When you download that PDF, also create a shortcut to the Atmel Start users guide (through which I was able to find the PDF above) : http://start.atmel.com/static/he... . It has no reference documentation for generated code, but it documents the Start/ASF UI.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Fri. Dec 8, 2017 - 09:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you very much for reply,

I have gone through that document, But still can't figure out "How do i know on which channel my Sensor 1 and which channel Sensor 2 is on.?

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

Each channel of the ADC is routed to a chip pin. This is documented in the SAM D21 data sheet. Start with chapter 7. I/O Multiplexing and Considerations. Look at Table 7-1. PORT Function Multiplexing, in the ADC column to see which pin is connected to which ADC channel.

 

NOTA BENE: I am not a vivid user of Start/ASF. What I tell you is "extrapolated" from my investigations of coding for the SAM D family "on the bare metal", i.e. without Start/ASF. I have only played around with Start a few times. Others might have better or more complete advice.. 

 

E.g. to enable an alternative function (e.g. ADC) on a pin, specific setup has to be done. I don't know if Start/ASF does this "by default" but I doubt it - if it did, how many channels would it do this for? All? Hardly likely. Some? How many, and which? I suspect there is some place in the Start/ASF-generated code where you tell what channels you want to use. Perhaps some struct that needs filling in? Or some function to call for each channel you want "enabled"? I'd start by browsing through the complete chapter for the ADC driver in the PDF I linked to above.

 

Yes, it's complex...

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Fri. Dec 8, 2017 - 09:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello JohanEkdahl,
I totally understand that, I have got something on a forum https://www.avrfreaks.net/forum/sam-d-adc-free-running

 

Please have a look at that, I am facing the same problem..

 

Last Edited: Fri. Dec 8, 2017 - 10:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using ADC Sync mode, Using the below code i am getting output in the Data Visualizer (Terminal) But don't know where it's coming from. I have connected Ground and VCC( Whether to see the graph goes up or down)  to each and every I/O pin Xplained Pro, But no one reacts.

 

Here is my code

 



	while (1) {
		uint8_t buffer[2];
		adc_sync_enable_channel(&ADC_0, 1);
		while (1) {
			adc_sync_read_channel(&ADC_0, 1, buffer, 2);
			io_write(io, buffer, 2);
		}
		
	}

 

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

beingmachine wrote:
I have got something on a forum https://www.avrfreaks.net/forum/s...   Please have a look at that, I am facing the same problem..

I took a quick look. I'll opt out of digging further into that thread matter. As I said above, I am not really a vivid Start/ASF user. I hope you get the attention of someone who knows more about ASF than I do.

 

Re the data visualizer: No, I've never used it, but have stumbled upon documentation. Go to the product page for the D21 Xplained kit, and under Documentation look for a document called Atmel Data Gateway Interface User Guide. There might also be clues in the Users Guide for the kit, and in the Atmel Studio help. 

 

I'm sorry, but I don't think I can be of more help.


 

Sideshow re not being an ASF user: My6 argument is much about what seems to be demonstrated in this thread. The ASF documentation seems superficial at best. And in order to drill down into it and understand how ASF works you still need to know a lot about the bare hardware. If you know the chip on that level, then many things can, in my opinion at this time [1], be implemented at that level without ASF.

 

This is not saying that a framework like ASF is by default and in principle of little use. It just seems to me that there is a lot of documentation, examples and "how-to's" that needs to be produced in order to make ASF actually as easy to use as it tries to promise.

 

[1] Subject to change without notice ;-)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

As with a lot of these "support libraries" the big question is do you spend your time trying to learn the APIs of the library or do you spend the same time just learning the peripheral registers of the raw chip and program it yourself? I'd only go with the library route for really complex peripherals like USB and CAN but for simple peripherals like ADC and UART it may be better to just take complete control and understanding. 

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

JohanEkdahl wrote:
The ASF documentation seems superficial at best

The trouble I find with most such library documentation - and ASF is no exception - is that it give a close-in view of individual functions, but no overview of how to put it all together into a system.

 

It's like a car user manual which describes the buttons, pedals, and levers individually - but doesn't tell you how to drive.

 

clawson wrote:
I'd only go with the library route for really complex peripherals

But, as this thread demonstrates, even things like USARTs are not "simple" on the SAMD.

 

I don't really think ASF does a great job at "hiding" this from you - as Johan said in #6, you do still need quite a good understanding at the HW level of how the IO multiplexing works, how the clock distribution works - even how the peripheral itself works (eg the 1 ADC but many channels distinction here).

 

EDIT

 

See also: https://www.avrfreaks.net/comment...

 

And: https://www.avrfreaks.net/comment...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Sat. Dec 9, 2017 - 12:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
I'd only go with the library route for really complex peripherals like USB and CAN but for simple peripherals like ADC and UART it may be better to just take complete control and understanding. 

I agree, but with the "moderation" that the SAM peripherals seems somewhat more complex than the AVR peripherals. Or it's just that I'm new to them.

 

Sideshow: What definitively is more complicated is the SAM clock system. I've spent a good few hours trying to get to grips with it and I'm starting to get there.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Im also battling with the ATSAMD21 and ASF4 and multiple inputs on the ADC, my ultimate goal is to have the ADC working with the DMA.

 

For now Ive got the ADC running in sync mode and selecting channels as follows :

 

Initially I used adc_sync_set_inputs(&ADC_0, 0x01, 0x19, 0) before each adc_sync_read_channel(&ADC_0, 0, adc_read_buffer, 2)

and then did adc_sync_set_inputs(&ADC_0, 0x02, 0x19, 0) & adc_sync_read_channel(&ADC_0, 0, adc_read_buffer, 2),

and adc_sync_set_inputs(&ADC_0, 0x03, 0x19, 0) adc_sync_read_channel(&ADC_0, 0, adc_read_buffer, 2) for each subsequent input that I would

want to read. Note that here I only read 2 bytes each time in the adc_sync_read_channel. 

 

The code I initially used was : 

    batt_voltage_ACD_value = 0;

    adc_sync_set_inputs(&ADC_0, 0x07, 0x19, 0);//Read AIN7/A7/PA07 (0x07) referenced to Internal Ground (0x18)

    adc_sync_read_channel(&ADC_0, 0, (uint8_t*)&batt_voltage_ACD_value, 2);

 

    variable_resistor_voltage_ADC_value = 0;

    adc_sync_set_inputs(&ADC_0, 0x02, 0x19, 0);//from hpl_adc_config, read AIN2/A1/PB08 (0x02) referenced to Internal Ground (0x18)

    adc_sync_read_channel(&ADC_0, 0, (uint8_t*)&variable_resistor_voltage_ADC_value, 2);

 

 I have subsequently changed the operation, by using the advanced ADC setup to rather scan all inputs in a range of inputs from a specific start input

 

 To scan AIN01 to AIN03, I specify AIN01 for "Positive Mux Input Selection" as the start, and 2 for "Number of input channels included in scan"

 If I now do adc_sync_read_channel(&ADC_0, 0, adc_read_buffer, 6), then the values for AIN01-03 are calculated as follows:

      ain01_ADC_value = adc_read_buffer[0]+adc_read_buffer[1]*256;

      ain02_ADC_value = adc_read_buffer[2]+adc_read_buffer[3]*256;

      ain03_ADC_value = adc_read_buffer[4]+adc_read_buffer[5]*256;

  Note that here I read 6 bytes (3 x 2 byte values) each time in the adc_sync_read_channel.