(XC-1) simple multicore flashing led problem - help!

New to XMOS and XCore? Get started here.
User avatar
Chendy
Active Member
Posts: 46
Joined: Tue Nov 02, 2010 4:53 pm

(XC-1) simple multicore flashing led problem - help!

Postby Chendy » Thu Nov 11, 2010 12:06 am

This code below works when compiled, it makes 4 of the 'clock' leds light up.

I understand the following code will all run on one core. I want to run the "logicThread" on stdcore[1] and everything else on the stdcore[0]. However I can't work out how to do this.

Code: Select all

#include <xs1.h>
#include <print.h>
#include <platform.h>

// Ports
#define PORT_CLED_0  XS1_PORT_4C  // "Clock" LEDs
#define PORT_CLED_GR XS1_PORT_1E  // Green/Red select lines
#define FLASH_PERIOD 100000000

// Ports
out port p_cled_g = PORT_CLED_GR;
out port p_cled_0 = PORT_CLED_0;

void ledDriver(chanend c_led){
	p_cled_g <: 1;
	while (1) {
		unsigned char c_led_;
		c_led :> c_led_;
		p_cled_0 <: c_led_;
	}
}

void logicThread(chanend c) {
	timer tmr;
	unsigned t;
	unsigned char ledStatus = 0b1111;
	tmr :> t;
	while (1) {
		t += FLASH_PERIOD;
		tmr when timerafter(t) :> void;
		ledStatus = ~ledStatus;
		c <: ledStatus;
	}
}

int main() {
	chan c;
	par
	{
		ledDriver(c);
		logicThread(c);
	}
	return 0;
}
What am I doing wrong? Here is my attempt:

Code: Select all

#include <xs1.h>
#include <print.h>
#include <platform.h>

// Ports
#define PORT_CLED_0  XS1_PORT_4C  // "Clock" LEDs
#define PORT_CLED_GR XS1_PORT_1E  // Green/Red select lines
#define FLASH_PERIOD 100000000

// Ports
on stdcore [0] : out port p_cled_g = PORT_CLED_GR;
on stdcore [0] : out port p_cled_0 = PORT_CLED_0;

void ledDriver(chanend c_led){
	p_cled_g <: 1;
	while (1) {
		unsigned char c_led_;
		c_led :> c_led_;
		p_cled_0 <: c_led_;
	}
}

void logicThread(chanend c) {
	timer tmr;
	unsigned t;
	unsigned char ledStatus = 0b1111;
	tmr :> t;
	while (1) {
		t += FLASH_PERIOD;
		tmr when timerafter(t) :> void;
		ledStatus = ~ledStatus;
		c <: ledStatus;
	}
}

int main() {
	chan c;
	par
	{
		on stdcore [0] : ledDriver(c);
		on stdcore [1] : logicThread(c);
	}
	return 0;
}
Is it something to do with declaring ports that will be written to? (p_cled_g & p_cled_0)

Any help appreciated

Chendy
User avatar
Chendy
Active Member
Posts: 46
Joined: Tue Nov 02, 2010 4:53 pm

Postby Chendy » Sat Nov 13, 2010 8:56 pm

I should have added that I have tried the "Multicore Hello World in XC using channels" example for the XC-1, but nothing happens; there is no "hello world" printed to console, whereas with the simple non multicore version I get the expected "hello word" appear in my console. Hmmmm

Maybe it something to do with my board being a "XC-1 1VO" board as opposed to a "XC-1".

Any thoughts?
User avatar
Andy
Respected Member
Posts: 279
Joined: Fri Dec 11, 2009 1:34 pm

Postby Andy » Sat Nov 13, 2010 10:32 pm

Are you putting the XC-1 in the correct boot mode by holding the 'A' button down when plugging in the USB?

Who is online

Users browsing this forum: No registered users and 0 guests