Found something in Programming XC on XMOS Devices PDF

New to XMOS and XCore? Get started here.
User avatar
AtomSoft
XCore Addict
Posts: 135
Joined: Mon Dec 14, 2009 3:02 pm

Found something in Programming XC on XMOS Devices PDF

Postby AtomSoft » Tue Dec 15, 2009 2:08 am

If you go to page 11/139

Image

Should it be:

Code: Select all

void swap (int &x, int &y) {
    int tmp = x;
    x = y;
    y = tmp;
}
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Postby Folknology » Tue Dec 15, 2009 2:22 am

Jason (Lopez) Good catch, maybe there should be an errata section on the forums for documentation/books etc..
Jason (XCore admin) could that be added?
User avatar
AtomSoft
XCore Addict
Posts: 135
Joined: Mon Dec 14, 2009 3:02 pm

Postby AtomSoft » Tue Dec 15, 2009 2:36 am

heh thanks im just reading through this and seen it nothing special really :D
User avatar
AtomSoft
XCore Addict
Posts: 135
Joined: Mon Dec 14, 2009 3:02 pm

Postby AtomSoft » Tue Dec 15, 2009 2:50 am

Since this is a getting start thread i should add to it heh...

Code: Select all

# include <xs1.h>

in port oneBit = XS1_PORT_1A ;
out port counter = XS1_PORT_4A ;

int main ( void ) {
    int x;
    int i = 0;
    oneBit :> x;
    while (1) {
        oneBit when pinsneq (x) :> x;
        counter <: ++i;
    }
}
Ok to clarify .. because the PDF wasnt clear to me... What this is doing is sampling the PIN 1A and storing the value into x....

Now lets say x = 0 @

Code: Select all

oneBit :> x; 
The below line basically gets the PIN 1A value and waits until its NOT EQUAL to x (initial value) and when its not it places the new value into x...

Code: Select all

oneBit when pinsneq (x) :> x;
This code increments i by 1 (i = i +1) then stores it in counter variable..

Code: Select all

counter <: ++i;
Would that be exactly how it works? wasnt that easier to understand if it was correct... heh
User avatar
jason
XCore Expert
Posts: 577
Joined: Tue Sep 08, 2009 5:15 pm

Postby jason » Tue Dec 15, 2009 10:17 am

Folknology wrote:Jason (Lopez) Good catch, maybe there should be an errata section on the forums for documentation/books etc..
Jason (XCore admin) could that be added?
I think the official errata can be found on the book page on XMOS.com.

For example for Programming on XMOS Devices. Scroll to the bottom.

I think it would be wise to raise a support ticket on the XMOS.com site so they can be aware of this and update it in one location, otherwise updates/edits will be hard to track for the people writing the books.
User avatar
AtomSoft
XCore Addict
Posts: 135
Joined: Mon Dec 14, 2009 3:02 pm

Postby AtomSoft » Tue Dec 15, 2009 3:21 pm

i sent out a ticket.

Who is online

Users browsing this forum: No registered users and 1 guest