XC-1A supern00b examples?

New to XMOS and XCore? Get started here.
User avatar
Skeksis
Active Member
Posts: 61
Joined: Sat May 28, 2011 9:42 pm
Location: England

XC-1A supern00b examples?

Postby Skeksis » Fri Jun 03, 2011 7:02 am

Hey all,

Are there, or is anyone willing to slip my way, simple wiring examples for using various bits & pieces with the XC-1A board? My background is in software with very little previous experience in electronics bar a few University projects utilising an Arduino Mega.

I'm finding the learning curve fantastically steep & have yet to stumble upon a nice simple example which doesn't use the on-board LEDs. Learning XC I have no trouble with, equally no trouble with making LEDs twinkle merrily but I could really do with a little nudge forward when it comes to hooking something up to X*PortA & being able to get myself programming for that.

Any hints, tips or Voodoo enchantments would be greatly appreciated!


Thanks,

Jonathan
"Time is an illusion. Lunch-time doubly so." - Douglas Adams
User avatar
TSC
Experienced Member
Posts: 100
Joined: Sun Mar 06, 2011 11:39 pm

Postby TSC » Sun Jun 05, 2011 7:24 am

Why don't you tell us what kind of stuff you want to hook up to the ports, and maybe someone can help you with a more specific task.

More LEDs?
Switches/buttons?
Motor?
LCD?
GPS/cellphone/camera/espresso machine...?

Or you could go looking for projects which use other microcontrollers. Almost any AVR/Arduino/PIC project's hardware can easily be transferred over to XMOS. The software would be harder to port, but you should be able to manage that. You just have to make sure to never put too much voltage into a port pin. The quad core XMOS devices can use 3 to 5V signalling (5.5V max) but I think the one and two core devices can only take 3.3V (3.6V max).
User avatar
Skeksis
Active Member
Posts: 61
Joined: Sat May 28, 2011 9:42 pm
Location: England

Postby Skeksis » Sun Jun 05, 2011 3:12 pm

Hi TSC, thanks for replying.

I think in my case the software would be easier to deal with, my previous experience with tinkering with hardware is minimal so I'm less than confident with plugging things into my XMos willy-nilly as I'll probably blow it up. It's the jump from theoretical to practical knowledge which is hampering me.

Anything would do really, I'd be happy with making yet another LED blink manically, lol. Thinking about it I have a BlueSMiRF laying about which should be easy to hook up. The pin-outs on that are:
  • CTS-1
  • VCC
  • GND
  • TX-0
  • RX-1
  • RTS-0

All I need to know for this is where to hook up the TX & RX pins & then the references to those pins, would I be correct in assuming it would be something along the lines of the attached image?
derp.png

I'm a little unsure, assuming I use X1PortA, how to reference individual pins within that port.

The header file "xs1_g4000b-512.h" packaged with XDE gives me an awful lot of ports to play with, however I can't see how these match up with the hardware if I need them at all?


Drowning in information at the moment, any further help would be greatly appreciated.


Thanks,
You do not have the required permissions to view the files attached to this post.
"Time is an illusion. Lunch-time doubly so." - Douglas Adams
User avatar
Andy
Respected Member
Posts: 279
Joined: Fri Dec 11, 2009 1:34 pm

Postby Andy » Sun Jun 05, 2011 8:20 pm

Hi Skeksis,

Take a look at page 15 of the manual if you haven't already:

https://www.xmos.com/download/public/XC ... 281%29.pdf

You can match up the pins in the diagram you showed to the corresponding software port i.e. Pin X1D1 is port P1B0 on core 1. In software you'd assign it as XS1_PORT_1B:

Code: Select all

on stdcore[1] : out port blub = XS1_PORT_1B;
It's worth noting that you can only access ports from threads on the core that the pins are attached. So in this case, the thread that outputs to port blub must be running on core 1. The compiler won't let you compile code that tries to read/write to it from any other core.
User avatar
TSC
Experienced Member
Posts: 100
Joined: Sun Mar 06, 2011 11:39 pm

Postby TSC » Sun Jun 05, 2011 11:43 pm

Also make sure you get the baud-rate and RX/TX directions of your UART correct.
RX on XMOS connects to TX on BlueSMiRF.
TX on XMOS connects to RX on BlueSMiRF.

Writing your own UART code is a great learning experience, probably requiring a bit of debugging. Or if you just want to get it going as quickly as possible, XMOS have the code for one available.
User avatar
Skeksis
Active Member
Posts: 61
Joined: Sat May 28, 2011 9:42 pm
Location: England

Postby Skeksis » Mon Jun 06, 2011 3:37 am

Excellent, thank you both for replying!

Andy, I've read through the hardware manual & have been using it to reference against to try to get to grips with everything. I'm failing to comprehend the jump from the port map to making references to it in the code.

I understand that if I wish to use one of the expansion header pins, say X1D9 in the X1PortA header, I look through & find the reference to it. Page 8 of the Hardware Manual tells me I have three port options I think(?): P4A3, P8A7 & P16A7.

Does these mean 4bit, 8bit & 16bits respectively?

And how do we make the jump to the code reference "XS1_PORT_1B" in your example?
I see that page 16 lists the port locations, however the referencing is continuing to elude me.

Also, am I able to make references to multiple individual pins in the expansion headers, for instance "talking" to pins X1D0 through to X1D5 separately?


I can imagine that once I finally understand I'll be kicking myself for being so stupid, for now though the learning curve is proving to be horrific.

Thanks for your continued patience,

Jonathan
"Time is an illusion. Lunch-time doubly so." - Douglas Adams
User avatar
Skeksis
Active Member
Posts: 61
Joined: Sat May 28, 2011 9:42 pm
Location: England

Postby Skeksis » Mon Jun 06, 2011 4:05 am

TSC wrote:Also make sure you get the baud-rate and RX/TX directions of your UART correct.
RX on XMOS connects to TX on BlueSMiRF.
TX on XMOS connects to RX on BlueSMiRF.

Writing your own UART code is a great learning experience, probably requiring a bit of debugging. Or if you just want to get it going as quickly as possible, XMOS have the code for one available.
I was just having a think about this, I think I've seen the code you mention somewhere while I was searching about for other things & will have to have another look for it (thanks for the reminder). If I can get this BlueSMiRF linked up then I'll probably try to use the code lurking in the Xmos repo' for the moment & then go on to do something interesting like coding my own later on when the impotent frustration has subsided. For now though I really just want to have something to show for all the reading I've been doing over the last week or so, I would literally be happy making a servo wiggle about or even blink an additional LED using the extension header, anything to get over the port mapping hurdle & have the theory squared away in my head.
"Time is an illusion. Lunch-time doubly so." - Douglas Adams
User avatar
Skeksis
Active Member
Posts: 61
Joined: Sat May 28, 2011 9:42 pm
Location: England

Postby Skeksis » Mon Jun 06, 2011 4:27 am

I'm feeling like a complete pillock now, I think understanding has just hit me like a tonne of bricks thanks to this snippet.
Andy wrote: You can match up the pins in the diagram you showed to the corresponding software port i.e. Pin X1D1 is port P1B0 on core 1. In software you'd assign it as XS1_PORT_1B
Am I correct in assuming that you basically just drop the first and last characters from the ID given in the map? So P1B0 drops down to 1B & so becomes XS1_PORT_1B and then depending on the port you wish to access you assign that pin on the corresponding core?

If that's true, then if I want to use pins X1D0 through to X1D5 separately, (assuming I can) how would I reference them as they should all come under XS1_PORT_4B? I might just be being foolish, I'm thinking of the example assigning X1D0 as RX and X1D1 as TX, would I require the use of two ports/cores for this example?


Thanks,

Jonathan
"Time is an illusion. Lunch-time doubly so." - Douglas Adams
User avatar
TSC
Experienced Member
Posts: 100
Joined: Sun Mar 06, 2011 11:39 pm

Postby TSC » Mon Jun 06, 2011 5:12 am

Skeksis wrote: I understand that if I wish to use one of the expansion header pins, say X1D9 in the X1PortA header, I look through & find the reference to it. Page 8 of the Hardware Manual tells me I have three port options I think(?): P4A3, P8A7 & P16A7.

Does these mean 4bit, 8bit & 16bits respectively?
Yes, it means that that pin can be used as one bit of a 4, 8 or 16 bit port, depending on how a port is declared.
For UART, you'd best stick with 1-bit ports. XnD0, D1, D10, etc.

You can find the XMOS UART here. I recommend using the two-threaded implementation, since that is conceptually easier to understand.
Skeksis wrote: Am I correct in assuming that you basically just drop the first and last characters from the ID given in the map? So P1B0 drops down to 1B & so becomes XS1_PORT_1B and then depending on the port you wish to access you assign that pin on the corresponding core?
Sounds right.
Skeksis wrote: If that's true, then if I want to use pins X1D0 through to X1D5 separately, (assuming I can) how would I reference them as they should all come under XS1_PORT_4B?
D0 through D5 covers several port ranges, so you can't really treat all those pins as one big port (unless you use port synchronization, which you don't need for now) and you can't treat them as many 1-bit ports.

If you want to use a 4-bit port, P4A corresponds to D2, D3, D8 and D9.
P4B corresponds to D4, D5, D6 and D7.

For a lot of things, you will find that 1-bit ports are the easiest to work with, so it's a shame there aren't more of them.
Skeksis wrote: I might just be being foolish, I'm thinking of the example assigning X1D0 as RX and X1D1 as TX, would I require the use of two ports/cores for this example?
Yes, you would be using two 1-bit ports. But you can put them on the same core.

Code: Select all

on stdcore [1]: in port uart_rx = XS1_PORT_1A;
on stdcore [1]: out port uart_tx = XS1_PORT_1B;
User avatar
Skeksis
Active Member
Posts: 61
Joined: Sat May 28, 2011 9:42 pm
Location: England

Postby Skeksis » Mon Jun 06, 2011 11:45 am

Perfect, I think I just about have it! I'll have a fiddle about & try to get something working later this evening.

Thank you for your help
"Time is an illusion. Lunch-time doubly so." - Douglas Adams

Who is online

Users browsing this forum: No registered users and 5 guests