Hi, has anyone else had problems with the :
Illuminate multiple LEDs in sequence on an XC-1A board example ?
It does nothing on my XC-1A board, though the parallel version works fine.
cheers,
Beau
Example program does nothing : Illuminate LEDs in sequence.
-
- Member++
- Posts: 17
- Joined: Thu Sep 27, 2012 11:41 pm
-
- XCore Expert
- Posts: 754
- Joined: Thu Dec 10, 2009 6:56 pm
Can you perhaps attach the code and/or the XE file?
-
- Member++
- Posts: 17
- Joined: Thu Sep 27, 2012 11:41 pm
OK, thanks :Bianco wrote:Can you perhaps attach the code and/or the XE file?
[ .xn file :
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
<Type>Board</Type>
<Name>XC-1A Development Board</Name>
<BoardId>0002051X</BoardId>
<Declarations>
<Declaration>core stdcore[4]</Declaration>
</Declarations>
<Packages>
<Package id="0" Type="XS1-G4B-FB512">
<Nodes>
<Node Id="0" InPackageId="0" Type="XS1-G4B" Oscillator="20MHz" SystemFrequency="400MHz">
<Boot>
<Source Location="SPI:bootFlash"/>
</Boot>
<Core Number="0" Reference="stdcore[0]">
<Port Location="XS1_PORT_1A" Name="PORT_SPI_MISO"/>
<Port Location="XS1_PORT_1B" Name="PORT_SPI_SS"/>
<Port Location="XS1_PORT_1C" Name="PORT_SPI_CLK"/>
<Port Location="XS1_PORT_1D" Name="PORT_SPI_MOSI"/>
<Port Location="XS1_PORT_1E" Name="PORT_CLOCKLED_SELG"/>
<Port Location="XS1_PORT_1F" Name="PORT_CLOCKLED_SELR"/>
<Port Location="XS1_PORT_4C" Name="PORT_BUTTONLED"/>
<Port Location="XS1_PORT_4D" Name="PORT_BUTTON"/>
<Port Location="XS1_PORT_1H" Name="PORT_UART_TX"/>
<Port Location="XS1_PORT_1I" Name="PORT_UART_RX"/>
<Port Location="XS1_PORT_1K" Name="PORT_SPEAKER"/>
<Port Location="XS1_PORT_8D" Name="PORT_CLOCKLED_0"/>
</Core>
<Core Number="1" Reference="stdcore[1]">
<Port Location="XS1_PORT_8D" Name="PORT_CLOCKLED_1"/>
</Core>
<Core Number="2" Reference="stdcore[2]">
<Port Location="XS1_PORT_8D" Name="PORT_CLOCKLED_2"/>
</Core>
<Core Number="3" Reference="stdcore[3]">
<Port Location="XS1_PORT_8D" Name="PORT_CLOCKLED_3"/>
</Core>
</Node>
</Nodes>
</Package>
</Packages>
<ExternalDevices>
<Device NodeId="0" Core="0" Class="SPIFlash" Name="bootFlash" Type="AT25DF041A">
<Attribute Name="PORT_SPI_MISO" Value="PORT_SPI_MISO"/>
<Attribute Name="PORT_SPI_SS" Value="PORT_SPI_SS"/>
<Attribute Name="PORT_SPI_CLK" Value="PORT_SPI_CLK"/>
<Attribute Name="PORT_SPI_MOSI" Value="PORT_SPI_MOSI"/>
</Device>
</ExternalDevices>
<JTAGChain>
<JTAGDevice NodeId="0"/>
</JTAGChain>
</Network>
You do not have the required permissions to view the files attached to this post.
-
- XCore Expert
- Posts: 754
- Joined: Thu Dec 10, 2009 6:56 pm
Hello Beau,
I have modified your code to make it working:
There were two problems with your code:
A chan variable in XC is used to connect two chanends together.
When supplying a chan variable to two functions in a par statement, the tools will know that the two threads want to talk to each other and will set up the channel for you.
You have supplied each chan variable to only one function, leaving the chanends unconnected (you only need 2 chan variables for this program by the way).
This should give you a warning in the build window of the XDE like this:
The second problem is that the LEDs of the clock are connected to an 8-bit port, but the LEDs don't start from bit 0, but instead from bit 4. I used 0x70 to illuminate the LEDs on bits 4, 5, 6.
Bianco
I have modified your code to make it working:
Code: Select all
// Copyright (c) 2011, XMOS Ltd., All rights reserved
// This software is freely distributable under a derivative of the
// University of Illinois/NCSA Open Source License posted in
// LICENSE.txt and at <http://github.xcore.com/>
/*
============================================================================
Name : $(sourceFile)
Description : Illuminate multiple LEDs in sequence on an XC-1A board
============================================================================
*/
#include <platform.h>
#include <stdio.h>
#define PERIOD 20000000
out port cled0 = PORT_CLOCKLED_0;
out port cled1 = PORT_CLOCKLED_1;
out port cled2 = PORT_CLOCKLED_2;
out port cled3 = PORT_CLOCKLED_3;
out port cledG = PORT_CLOCKLED_SELG;
out port cledR = PORT_CLOCKLED_SELR;
void tokenFlash (chanend left, chanend right, out port led, int delay, int isMaster) {
timer tmr;
unsigned t;
if (isMaster) /* master inserts token into ring */
right <: 1;
while (1) {
int token;
left :> token; /* input token from left neighbor */
led <: 0x70;
tmr :> t;
tmr when timerafter (t+ delay ) :> void;
led <: 0;
right <: token; /* output token to right neighbor */
}
}
int main (void) {
chan c0, c1;
par {
on stdcore [0]: { cledG <: 1;
tokenFlash (c0, c1, cled0, PERIOD, 1);
}
on stdcore [1]: tokenFlash (c1, c0, cled1, PERIOD, 0);
// other cores
}
return 0;
}
A chan variable in XC is used to connect two chanends together.
When supplying a chan variable to two functions in a par statement, the tools will know that the two threads want to talk to each other and will set up the channel for you.
You have supplied each chan variable to only one function, leaving the chanends unconnected (you only need 2 chan variables for this program by the way).
This should give you a warning in the build window of the XDE like this:
(I compiled it using the command line tools)C:\Users\Bianco\Desktop\xc1a_led>xcc -o test.xe test.xc -target=XC-1A
test.xc:45: warning: `c0' not used in two parallel statements
test.xc:47: warning: `c2' not used in two parallel statements
The second problem is that the LEDs of the clock are connected to an 8-bit port, but the LEDs don't start from bit 0, but instead from bit 4. I used 0x70 to illuminate the LEDs on bits 4, 5, 6.
Bianco
-
- Member++
- Posts: 17
- Joined: Thu Sep 27, 2012 11:41 pm
Thanks Bianco,Bianco wrote:Hello Beau,
I have modified your code to make it working:
Bianco
I don't have the module with me today, but will try what you say soon, thanks indeed,
Beau
[Edit]
Thanks again Bianco, yes I have just been able to try what you suggest, and that works fine.
I will now look at the code carefully, I need it as a prototype for a different sequential program that I want to try and write.
cheers,
Beau