ADC on startKIT [Now available via community tab]

XCore Project reviews, ideas, videos and proposals.
User avatar
infiniteimprobability
XCore Legend
Posts: 1124
Joined: Thu May 27, 2010 10:08 am

ADC on startKIT [Now available via community tab]

Postby infiniteimprobability » Wed Jun 04, 2014 10:13 am

Version: 1
Status: Public release
License: BSD
Download: /files/project_builds/startkit-adc.zip

Finally... here is some demo code to allow you to easily use the ADCs on your startKIT. I've tried to make the API as MCU-like as possible.
Included is a simple app that lights the LEDs corresponding to the 4 ADC inputs proportionally to the ADC value.
The driver contains the link setup magic, so the ADC functions when run/debugged and also when flashed.
Don't forget to enable xscope I/O (run configurations in GUI or --xscope at prompt) to see console output.
Enjoy talking to the analog world! I'll look at getting this inetgarted into the examples too..
From adc.h:

//adc.h for startKIT written by infiniteimprobability (xcore.com) June 2014

//

//Contains ADC task and ADC interface definition

//

//Aims to present the U8A/startKIT ADC in an MCU-like manner by abstracting away

//channels, link setup (for startKIT FLASH boot) and trigger requirements.


//

//Enables all 4 channels and provides simple API for trigger, read and conversion complete event

//Practical fastest sample rate (to aquire all 4 channels) with all cores running flat-out

//is about 50us (to trigger, aquire, notify and read). So about 20KHz. Assumes core sharing with GPIO (slower)

//Ie. This module is built for comfort rather than speed. Give it it's own core and only run 4 cores total,

//and this number jumps to about 6us, or about 165KHz. Much closer to max theoritcal b/w of 1MHz/4 = 250KHz

//

//Runs in two modes (self tiggering periodically or trigger on request). Trigger function still callable

//in periodic mode and conversion finished notfication available in period mode if needed. Task is combinable

//so you can run it with other low speed tasks in the same logical core! (eg. GPIO)

//

//License = do what you like with it! But please post your projects on xcore.com for others to enjoy!
Images:
MarcinMarecki
New User
Posts: 3
Joined: Thu Sep 05, 2013 2:20 pm

Postby MarcinMarecki » Tue Aug 18, 2015 1:34 pm

xmos.workspace/startkit-adc/bin>xrun --id 0 --xscope startkit-adc.xe
App started
Button released!
ADC chan 0 = 1712, ADC chan 1 = 416, ADC chan 2 = 256, ADC chan 3 = 288
ADC chan 0 = 1712, ADC chan 1 = 432, ADC chan 2 = 272, ADC chan 3 = 304
ADC chan 0 = 1696, ADC chan 1 = 448, ADC chan 2 = 272, ADC chan 3 = 320
ADC chan 0 = 1712, ADC chan 1 = 448, ADC chan 2 = 256, ADC chan 3 = 304
ADC chan 0 = 1728, ADC chan 1 = 464, ADC chan 2 = 320, ADC chan 3 = 320
ADC chan 0 = 1744, ADC chan 1 = 528, ADC chan 2 = 336, ADC chan 3 = 352
ADC chan 0 = 1696, ADC chan 1 = 464, ADC chan 2 = 304, ADC chan 3 = 320
ADC chan 0 = 1760, ADC chan 1 = 512, ADC chan 2 = 336, ADC chan 3 = 352
MarcinMarecki
New User
Posts: 3
Joined: Thu Sep 05, 2013 2:20 pm

Postby MarcinMarecki » Tue Aug 18, 2015 2:16 pm

For proper compilation you have to store STARTKIT.xn file in source directory, pay attention for the case sensitive in file name.
The content of the setup file STARTKIT.xn, you can find on the page bellow http://www.xcore.com/forum/viewtopic.ph ... 7&start=20
Message dated Posted: Sat Jan 11, 2014 7:31 pm
Bellow view of my directory:
 
workspace\startkit-adc\src
2015-08-18  14:46    <DIR>          .
2015-08-18  14:46    <DIR>          ..
2015-08-18  13:56    <DIR>          adc
2014-06-04  11:19             3 318 app-adc-test.xc
2015-08-18  13:56    <DIR>          startkit
2015-08-18  13:41             2 649 STARTKIT.xn
               2 File(s)          5 967 bytes
 

Who is online

Users browsing this forum: No registered users and 1 guest