Found something in Programming XC on XMOS Devices PDF

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

Found something in Programming XC on XMOS Devices PDF

Post by AtomSoft »

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
Contact:

Post by Folknology »

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
Contact:

Post by AtomSoft »

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
Contact:

Post by AtomSoft »

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
Contact:

Post by jason »

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
Contact:

Post by AtomSoft »

i sent out a ticket.
Post Reply