How to use the ADC on StartKit?

All technical discussions and projects around startKIT
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm
Contact:

Post by Folknology »

dimitris wrote:Hi everybody,
it's nice to watch this thread!
I was having the same problems as MatCat and Folknology's solution worked for me. Just make sure you add the -fxscope flag in both the debug and release flags

I was expecting an API for the analogue part. Fortunately Folkonology's module brings the whole thing closer to that.
It would be nice if someone could give us more context on why is the whole thing needed! I was expecting that it would be as trivial as writing and reading some registers.

Code: Select all

data[0] = 0x10201;
     write_periph_32(adc_tile, 2, 0x20, 1, data);
This is what I was expecting it would make it run.

I would also appreciate some more insight on the reading of the samples.

Code: Select all

unsigned int samps = inuint(c);
         chkct(c, 1);
How come and this is different from reading a channel.

Folkonogy, I still get some preprocessor erros when I use your module. More specificaly it fails to find the xassert and the debug_print libraries. Removing those and replaycing the printing with standard prints made it work for the time being.

Kind regards,
Dimitris
In order to operate the ADC you have to set up which channels you wish to use, sample bit size and padding and how that data gets efficiently packaged before routing over an xmos links. You then also have to trigger the ADC using the loop-back 1 bit port from application tile to ADC tile. It is more complicated (on Startkit) because the ADC tile is linked to a different tile (the debug tile) rather than the application tile where your code runs. There is also some house keeping code that checks you are setting the ADC up in a valid way, hence the asserts and logging. The final piece unpacks of the samples after receiving them across the link ready for your use.

The inxxxx(c) and chkct(c,y) calls are not compatible with ':>' XC channel operators, data from the ADC (operating as a service) sent over the channel, requires a manual read and checking of tokens etc..

You can find the extra assert and logging modules in the SC_util on github/xcore

regards
Al


H3llow33N
New User
Posts: 2
Joined: Wed Feb 05, 2014 4:16 pm

Post by H3llow33N »

Hi all,

I was playing with the StartKit for a couple of days and I wanted to use the ADC. Unfortunately I could not configure it. I have noticed that the the program stops at the first call of write_periph_32(adc_tile, 2, 0x20, 1, data). Do you have any idea why this is happening?

Also, I would like to know the StartKit's peripherals and what numbers are assigned to them. The example is not very clear and it uses too many magic numbers, for example write_periph_32(adc_tile, 2, 0x20, 1, data). Were can I find the documentation of the ADC?

10x
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm
Contact:

Post by Folknology »

As mentioned in this thread make sure your compiler flags include --fxscope (look at you make/build settings check for xscope support) for now until Xmos release the new version of startkit code with ADC support.

regards
Al
H3llow33N
New User
Posts: 2
Joined: Wed Feb 05, 2014 4:16 pm

Post by H3llow33N »

It worked with the flag set.
The documentation needs to be more clear.
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm
Contact:

Post by Folknology »

H3llow33N wrote:It worked with the flag set.
The documentation needs to be more clear.
This isn't official it's simply a kludge to get the ADC working until an official Startkit with ADC library is released by the Xmos folk ;-)

regards
Al
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am
Contact:

Post by segher »

H3llow33N wrote:Also, I would like to know the StartKit's peripherals and what numbers are assigned to them. The example is not very clear and it uses too many magic numbers, for example write_periph_32(adc_tile, 2, 0x20, 1, data). Were can I find the documentation of the ADC?
It is all documented in the datasheets.

Pet peeve: these are not magic numbers, they are the addresses
of the peripherals. Adding extra indirections ("PERIPH_2",
or "PERIPH_ADC", or whatever) hurts more than it helps.
Just make sure the reader of the code knows what he is
looking at (give routines good names, and some comments
don't hurt).
User avatar
ea1ii
Member
Posts: 8
Joined: Mon Jan 13, 2014 3:16 am

Post by ea1ii »

Just made a very one test to last adapted module but it didn't work. It'd be nice if users were given a simple and easy module to test ADC on startKit. This is not really a complain but one of the most appealing features of this hardware is the possibility of making really great applications "without" asm. Just encouraging xMOS guys, that made a great work.

One last question. I'm a very beginner and for my doc readings I conclude that the channel method is a rather obsolote one for communicating tasks. So I made up into interfaces and found them powerful. Is there any reason for using channels ont the code given above?
User avatar
ea1ii
Member
Posts: 8
Joined: Mon Jan 13, 2014 3:16 am

Post by ea1ii »

I finally gave it a full try: indeed I copy-pasted sample code on this thread and checked for not missing the -fxscope flag. All I got was the message: "First stage multi-node boot failed, please check XN file and Xmos link connectivity". Any clues?
patolin
Junior Member
Posts: 5
Joined: Thu Dec 26, 2013 3:56 am

Post by patolin »

This seems to be a little more complicated than use the ADC on the stellaris launchpad, and way more complicated than the analogRead() from arduino XD

I will give it a try this week. Im interested in build a 1MSPS DSO, using the onboard ADC, so, lets see what can I do. I think that adding a USB-UART emulation will be a nice touch for this board too.
gkrusi
Junior Member
Posts: 7
Joined: Mon May 26, 2014 10:32 pm

Post by gkrusi »

So, few months later; are there any official libraries available for ADC on startKIT? I can't find any or make those to work.
Post Reply