XMOS sent me a free StartKIT development board just in time for Christmas. Now that the festivities are over, I've had a chance to get started with it. It's a bit frustrating because XMOS's documentation has the necessary information scattered rather broadly, and documents that you'd expect to contain certain pieces of information do not.* It's all there, just poorly organized & often hidden in long documents where you wouldn't expect it.
That said, the hardware is exciting in its potential. Once I got through the basic tutorial stuff I went to write a simple multiprocessing program--handing over the blinking of two LEDs on the board to two independent processes.
Here again I ran into documentation deficiencies. XMOS presents code examples in their docs as snippets, not full programs. This leads to misunderstandings due to lack of context. I was able to get a program going, on the third attempt. The first syntax I tried created two dependent processes. The second's syntax was not accepted even though it was copied from a sample snippet--it had a variable that needed to be declared, but I didn't know what type to declare it as, and the declarations are left out of the snippets. The third try worked, but only after enough time spent reading and time spent doing some fortunate guesswork to have gotten a lot further with another, better documented hardware platform.
Lighting a Candle While Cursing the Darkness
I still think this is the right platform for the initial ideas I had for it, though. So as I press on, step by step, in implementing those ideas, I'm going to document what I learn & hope to save others time and trouble. I've made a couple of resolutions about the code, similar to those on the code for my Begin with Java blog:
1. All examples will be presented as complete, compilable programs.
2. All examples will use multiprocessing syntax and structure.
Look for this code to appear on my website, saundby.com soon.
Until then:Don't follow the example syntax XMOS uses of writing your code inside main(). All main() should contain is channel declarations and par{} blocks. Put all your code into functions to be called inside par{} blocks.
The code for the dual process LED blinker:
/* * LED Tests.xc * * Created on: Jan 5, 2014 * Author: saundby */ #include <xs1.h> out port p1 = XS1_PORT_1A; //PORT 1A for D1 LED out port p2 = XS1_PORT_1D; //PORT 1D for D2 LED void led1(){ while(1){ //run forever p1 <: 1; // LED D1 On delay_milliseconds(200); p1 <: 0; // LED D1 Off delay_milliseconds(200); } } void led2(){ while(1){ // run forever p2 <: 0; // LED D2 Off delay_milliseconds(50); p2 <: 1; // LED D2 On delay_milliseconds(350); } } int main(void) { // Note: put the 'forever' loop in each of the // individual tasks, not out here. par{ led1(); led2(); } return 0; }
* It took me forever to find the electrical characteristics of the I/Os in the data sheets, but they are there. There just isn't a data sheet for the specific IC used in the StartKIT, which is a unique item not for sale separately. Personally, I consider it a major oversight to not either provide a data sheet for this specific IC or to include that information in the Hardware Manual for the StartKIT. Based on the scuttlebutt in the forums, I'm using the datasheet for the XS1-A8A-64-FB96 (PDF) as the closest analogue.
Hi Mark
ReplyDeleteThanks for the comments. Segher's comment on this thread http://www.xcore.com/forum/viewtopic.php?f=44&t=2506 is correct in saying that the closest production chip to the one on the startKIT is XS1-U16-128-FB217.
Thanks for bringing this up!
ReplyDeleteYes and no. The USB side of the chip on the StartKit isn't available to the user, it's dedicated to debugging. So of what the programmer has available, the one above is closer. And electrically, so far as logic levels, max and min voltages and currents on signal lines, etc, they're the same. Either will do so long as you recall that the second half of the chip & the USB aren't available.
This sort of confusion is all the more reason an actual data sheet for the StartKit's custom chip should be released. :)