XMOS pins usage

Technical discussions around xCORE processors (e.g. xcore-200 & xcore.ai).
lmariotti
Member++
Posts: 27
Joined: Mon Nov 21, 2022 5:38 pm

XMOS pins usage

Post by lmariotti »

Hi everyone,

I'm currently developing an application using XU208-128-QF48 but I'm not sure I fully understand how XMOS ports work.
  1. Refering to datasheet (image in attatchments) the pins X0D26 .. X0D29 are gray, how can I use that pins?
  2. With a 4bit port (e.g. 4D) can I use each single bit (4D_0, 4D_1, 4D_2, 4D_3) as 1bit port?
  3. In AN00162_i2s_loopback_demo ports 4A are used for I2C on tile[0]: port p_i2c = XS1_PORT_4A;, since I2C only uses 2 pins it meas that 4A_2 and 4A_3 are "wasted"?
Thanks for your support.
You do not have the required permissions to view the files attached to this post.
User avatar
CousinItt
Respected Member
Posts: 366
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

Hi there,

1. From the data sheet, section 4:
The device provides a combination of 1bit, 4bit, 8bit and 16bit ports, as well as wider ports that are fully or partially (gray) bonded out.
You can use pins X0D26..29 as sections of wider ports, but not all pins of those ports are available. For example, you can use X0D26 and X0D27 as bits 0 and 1 of the four bit port 4E.

2. The general rule is that, when pins are shared by different ports, the narrower port has priority. From the data sheet, section 6.3:
If a port is enabled, it overrules ports with higher widths that share the same pins. The pins on the wider port that are not shared remain available for use when the narrower port is enabled. Ports always operate at their specified width, even if they share pins with another port.
3. The audio platform uses the XE216-512-TQ128. Pins X0D08 and X0D09 are not connected, so in this sense they are wasted. However, you would be able to use these pins if the board allowed access to them.
MaximLiadov
XCore Addict
Posts: 130
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

As a developer for many years, I think I understand why you might get frustrated. Let me give you some good advice, if I may. In my experience, it is not a good idea to use XMOS ports as GPIOs in complicated projects. Unlike standard MCUs for some washing machines, XMOS ports are much more useful as high-speed data ports. That's why they were designed. We are talking about 100 MHz speed. So for purposes like buttons or sensors, it's better to use one I2C port even with 4-bit port and then add an extra chip for GPIO extension. Or as many chips as you want! This way you can add dozens of standard "slow" GPIOs and protect your MCU from high current/overheating and contact bounce problems that inexpensive I2C GPIO chips provide automatically. I am very pleased with this approach. Highly recommended.
MaximLiadov
XCore Addict
Posts: 130
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

I forgot to mention that it is also very easy and convenient from software perspective. All you need to do is add an I2C server task. Then you can access GPIOs from literally anywhere in your code (from any tile and core). To process input GPIOs such as button presses or encoder changes, you can use only one interrupt XMOS input port and a very simple handler. Without the annoying problem of contact bounce. If you try to process the signal from an encoder connected directly to XMOS, it's a real mess. 100 Mhz port speed is too much for this and you will be using a 50 ms debounce software procedure, potentially losing other events. Not great. Especially if you need to measure the speed of the event. In my opinion, XMOS in/out ports should ideally be used as pure data ports. Don't be afraid to use additional peripherals. IMHO.
lmariotti
Member++
Posts: 27
Joined: Mon Nov 21, 2022 5:38 pm

Post by lmariotti »

Thanks for your reply, the idea of adding a GPIO expansion is quite understandable, but as far as my application is concerned I have some unused ports the one who is developing the board refuses to add an i2c line and another chip just to read a switch and toggle a led (nobody cares about software perspective).
MaximLiadov
XCore Addict
Posts: 130
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

If they don't care, why should you? Do what you can. You cannot use "wasted" pins in 4 bit ports. Not your problem. Ask the hardware department for free ports. Period.
lmariotti
Member++
Posts: 27
Joined: Mon Nov 21, 2022 5:38 pm

Post by lmariotti »

Hi MaximLiadov, I am forcing to get the GPIO expansion module added. Meanwhile I'm implementing the i2c interface to my project following AN00156_-How-to-use-the-I2C-master-library_1_0_3rc1 but I'm unable to link the i2c libary.
I've attatched the xmake --makefile=Makefile CONFIG=Default output for 3 different builds:
1) Without i2c library (builds ok)
2) With i2c library included (#include "i2c.h")
3) Without i2c library included (//#include "i2c.h")

My workspace directory looks like:
Project_name/
lib_gpio/
lib_i2c/
lib_i2s/
lib_logging/
lib_xassert/

Any idea?
You do not have the required permissions to view the files attached to this post.
MaximLiadov
XCore Addict
Posts: 130
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

If you are using xTimeComposer, your workspace file structure doesn't matter much.
You need to install the i2c library manually to automatically add it to all project files.
I know 2 ways to do this. The easiest one is to import from the "Libraries" window.
You should check your library version dependencies and update old libraries if necessary.
You do not have the required permissions to view the files attached to this post.
lmariotti
Member++
Posts: 27
Joined: Mon Nov 21, 2022 5:38 pm

Post by lmariotti »

I was trying to download manually from xmos website becasue from xTIMEcomposer I'm getting the following error: An error occurred during connection to www.xmos.com. Cannot communicate securely with peer: no common encryption algorithm(s). (Error code: ssl_error_no_cypher_overlap)

It's not possibile to add libraries manually without xTIMEcomposer studio dowload?
You do not have the required permissions to view the files attached to this post.
MaximLiadov
XCore Addict
Posts: 130
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

The second way is to manually import into the workspace. Right-click on an empty field and click Import. Then select Import from archive or file system.

Third way is to go to your project settings and manually add all paths dozens of times in many fields. Just look at the paths of other libraries and do the same.

Think of the project as a database. You cannot simply add or remove files from your file system. xTIMEcomposer doesn't really care. So please do this correctly.