ADC on startKIT [Now available via community tab]
Posted: 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:
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: