Hello there! Last Friday I received my starterKIT and just now managed to 'make' it run on several platforms I am using. TBH my first impression is a bit scary, since I was only practicing really lame things on PIC714*** and mostly using assembly now I have the feeling that this is something completely new. I came xross C very little to none in my life (24 years and mainly working as support of mainframe) and now I'd love to use some guidance where to start from, I've started reading the XMOS multicore extentions to C but as useful I find it I feel I am starting from the middle of the whole thing...
Btw I managed to run the examples and they were fine, I looked up their code but found several really strange things now I am examining the datasheet of the starterkit so next time at least to know to which port should I address for the LEDs
Hello from a complete newbie
-
- Junior Member
- Posts: 5
- Joined: Sun Dec 22, 2013 12:59 pm
-
- Member++
- Posts: 27
- Joined: Sat Dec 14, 2013 1:03 pm
Hello, Ive used arduino for a bit but finding the Startkit abit scary even compared to python on the raspberry pi.
-
- Junior Member
- Posts: 5
- Joined: Sun Dec 22, 2013 12:59 pm
AJB2K3 wrote:Hello, Ive used arduino for a bit but finding the Startkit abit scary even compared to python on the raspberry pi.
Total agree with you! I am struggling to find the 'datasheet' since I am checking the examples, and can't figure it out how they are addressing the LEDs for isntance... they are putting a XS1_PORT_P32 and that's all .. how the hell did they decided if it's 0x00 or 0xff ... I found something close but doubt it it is even near to what am I looking for...
https://www.xmos.com/en/download/public ... 1.0%29.pdf
This should be the hardware bible but I found it difficult orientating... by the way any close suggestions for a beginning C or smthg ? Any advice ?
-
- XCore Expert
- Posts: 754
- Joined: Thu Dec 10, 2009 6:56 pm
Code: Select all
#include <xs1.h>
#include <platform.h>
on tile[0] : out port LED3x3 = XS1_PORT_32A;
on tile[0] : out port LED1 = XS1_PORT_1A;
on tile[0] : out port LED2 = XS1_PORT_1D;
void LED3x3_task() {
timer t;
unsigned ctime;
t :> ctime; // read time from timer
while(1) {
t when timerafter(ctime + 50000000) :> ctime; // wait until timer has reached value
LED3x3 <: 0x000E1F80; // turn all 9 LEDs on
t when timerafter(ctime + 50000000) :> ctime; // wait until timer has reached value
LED3x3 <: 0x00000000; // turn all 9 LEDs off
}
}
void LED2_task() {
timer t;
unsigned ctime;
t :> ctime; // read time from timer
while(1) {
t when timerafter(ctime + 25000000) :> ctime; // wait until timer has reached value
LED1 <: 1;
LED2 <: 1;
t when timerafter(ctime + 25000000) :> ctime; // wait until timer has reached value
LED1 <: 0;
LED2 <: 0;
}
}
int main()
{
// run the two tasks in parallel on tile 0
par {
on tile[0] : LED3x3_task();
on tile[0] : LED2_task();
}
return 0;
}
I can imagine that this is a rough introduction if you come from arduino.
Even though it is a starter kit, it really helps if you have experience with other microcontrollers and programming in C. Good luck!
-
- Junior Member
- Posts: 5
- Joined: Sun Dec 22, 2013 12:59 pm
Thank you very much Bianco! Well never touched arduino, only old PIC16F's + simple assembly, programming in C is close to none since we only practiced it in the university for printing out stuff.... lovely another rough problem for solving.Bianco wrote:Try this. the 3 x 3 LEDs are connected to various bits of the 32 bit port as stated in the hardware manual. Also see the XC programming guide: https://www.xmos.com/en/xc-programming-guide?secure=1Code: Select all
#include <xs1.h> #include <platform.h> on tile[0] : out port LED3x3 = XS1_PORT_32A; on tile[0] : out port LED1 = XS1_PORT_1A; on tile[0] : out port LED2 = XS1_PORT_1D; void LED3x3_task() { timer t; unsigned ctime; t :> ctime; // read time from timer while(1) { t when timerafter(ctime + 50000000) :> ctime; // wait until timer has reached value LED3x3 <: 0x000E1F80; // turn all 9 LEDs on t when timerafter(ctime + 50000000) :> ctime; // wait until timer has reached value LED3x3 <: 0x00000000; // turn all 9 LEDs off } } void LED2_task() { timer t; unsigned ctime; t :> ctime; // read time from timer while(1) { t when timerafter(ctime + 25000000) :> ctime; // wait until timer has reached value LED1 <: 1; LED2 <: 1; t when timerafter(ctime + 25000000) :> ctime; // wait until timer has reached value LED1 <: 0; LED2 <: 0; } } int main() { // run the two tasks in parallel on tile 0 par { on tile[0] : LED3x3_task(); on tile[0] : LED2_task(); } return 0; }
I can imagine that this is a rough introduction if you come from arduino.
Even though it is a starter kit, it really helps if you have experience with other microcontrollers and programming in C. Good luck!
Thanks a lot! I will do my best especially when I have the kit now.. I will keep posting questions here!
-
- XCore Legend
- Posts: 1913
- Joined: Thu Jun 10, 2010 11:43 am
Small correction. According to the XMOS startKit schematic, the 3 x 3 LEDs are Active LOW. However, LEDs D1 & D2 are Active HIGH.
Therefore, from the above posted code:
LED3x3 <: 0x000E1F80; // turn all 9 LEDs on
should read as:
LED3x3 <: 0x000E1F80; // turn all 9 LEDs OFF since the respective XMOS GPIO lines will be HIGH
and
LED3x3 <: 0x00000000; // turn all 9 LEDs off
should read as:
LED3x3 <: 0x00000000; // turn all 9 LEDs ON since the respective XMOS GPIO lines will be LOW
Therefore, from the above posted code:
LED3x3 <: 0x000E1F80; // turn all 9 LEDs on
should read as:
LED3x3 <: 0x000E1F80; // turn all 9 LEDs OFF since the respective XMOS GPIO lines will be HIGH
and
LED3x3 <: 0x00000000; // turn all 9 LEDs off
should read as:
LED3x3 <: 0x00000000; // turn all 9 LEDs ON since the respective XMOS GPIO lines will be LOW
You do not have the required permissions to view the files attached to this post.
-
- Member++
- Posts: 27
- Joined: Sat Dec 14, 2013 1:03 pm
mon2 wrote:Small correction. According to the XMOS startKit schematic, the 3 x 3 LEDs are Active LOW. However, LEDs D1 & D2 are Active HIGH.
Therefore, from the above posted code:
LED3x3 <: 0x000E1F80; // turn all 9 LEDs on
should read as:
LED3x3 <: 0x000E1F80; // turn all 9 LEDs OFF since the respective XMOS GPIO lines will be HIGH
and
LED3x3 <: 0x00000000; // turn all 9 LEDs off
should read as:
LED3x3 <: 0x00000000; // turn all 9 LEDs ON since the respective XMOS GPIO lines will be LOW
What confuses me is that there are 9 pin split in 3 banks of three so should (in my mind be)
0x000000, 0x000000, 0x000000 (three sets of 00)
however the board has 4 sets per address
Not to mention that they use 0x000E1F80 instead of 0xFFFFFFFF as I would expect.
This has me baffled but I suppose that when I find the time to sit and play then this will make sense.
-
- Junior Member
- Posts: 5
- Joined: Sun Dec 22, 2013 12:59 pm
Mind that also!
Guys I am having a problem trying to address the sliders. Any suggestions ? My idea is to light up the 3x3 LEDs then slide over the matrix and with pushing the button to turn the led on which I am off. Lighting up the LEDs - ok. But how should I use the sliders ?
Guys I am having a problem trying to address the sliders. Any suggestions ? My idea is to light up the 3x3 LEDs then slide over the matrix and with pushing the button to turn the led on which I am off. Lighting up the LEDs - ok. But how should I use the sliders ?
-
- XCore Expert
- Posts: 754
- Joined: Thu Dec 10, 2009 6:56 pm
See https://github.com/xcore/sw_startkit_ex ... p_absolute
for an example of cap sense for the startKIT. You will also need this module to build it: https://github.com/xcore/sc_capacitive_sensing
for an example of cap sense for the startKIT. You will also need this module to build it: https://github.com/xcore/sc_capacitive_sensing
-
- XCore Expert
- Posts: 754
- Joined: Thu Dec 10, 2009 6:56 pm
The 9 LEDs are connected to one 32-bit wide port.AJB2K3 wrote:mon2 wrote:Small correction. According to the XMOS startKit schematic, the 3 x 3 LEDs are Active LOW. However, LEDs D1 & D2 are Active HIGH.
Therefore, from the above posted code:
LED3x3 <: 0x000E1F80; // turn all 9 LEDs on
should read as:
LED3x3 <: 0x000E1F80; // turn all 9 LEDs OFF since the respective XMOS GPIO lines will be HIGH
and
LED3x3 <: 0x00000000; // turn all 9 LEDs off
should read as:
LED3x3 <: 0x00000000; // turn all 9 LEDs ON since the respective XMOS GPIO lines will be LOW
What confuses me is that there are 9 pin split in 3 banks of three so should (in my mind be)
0x000000, 0x000000, 0x000000 (three sets of 00)
however the board has 4 sets per address
Not to mention that they use 0x000E1F80 instead of 0xFFFFFFFF as I would expect.
This has me baffled but I suppose that when I find the time to sit and play then this will make sense.
So there are only 9 bits of the ports used. 0xFFFFFFFF would also work but it will toggle all pins on the 32-bit port while this may not be desired if there are other circuitry connected to the other bits of the 32-bit port. See section 7 of the startKIT hardware manual. For example LED A1 is connected to bit 19 of 32-bit port A.