Reconfiguring overlapping ports at runtime Topic is solved

If you have a simple question and just want an answer.
User avatar
ers35
Active Member
Posts: 62
Joined: Mon Jun 10, 2013 2:14 pm

Reconfiguring overlapping ports at runtime

Post by ers35 »

Say I specify ports XS1_PORT_16A and XS1_PORT_4A in an XN file. There is a 4 pin overlap between those ports. Can I freely change their direction and clock if I only turn one of the ports on at a time?
For example, I want to configure XS1_PORT_16A to be clocked off a 62.5 MHz internal reference clock with XS1_PORT_4A disabled. Later, I disable XS1_PORT_16A and configure XS1_PORT_4A to be clocked off an external clock of 25 MHz. The behavior I expect to see is the same as if I had only declared one of the ports in the XN file in the first place.

View Solution
User avatar
infiniteimprobability
Verified
XCore Legend
Posts: 1164
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Firstly, the XN file for ports is really just a glorified #define that gets included via platform.h. It's not really necessary and doesn't change the nature of your question.

Regarding overlap, there is a thing call port precedence - it's described (in this very handy doc) here https://www.xmos.com/download/public/In ... s(1.0).pdf that I reccomend reading.

The upshot of precedence is that having 16A on and 4A on at the same time means that 4A appears, but 16A has a 4b hole in it. Ie smaller ports take precedence on the pin mux. The pin mux changes when the port is switched on/off (which is done implicitly by the compiler, or can be done manually using the inlines in xs1.h)

Since 16A and 4A are seperare logical ports, they can be clocked from different sources just fine.

You can freely change direction and clock source of ports at runtime - it may be prudent to make sure you reset things afterwards (eg. half empty buffer). A good way to do this is to call set_port_on (see xs1.h) which will safely initialise it.

So to answer the question "Can I freely change their direction and clock if I only turn one of the ports on at a time?", the answer is yes.

Engineer at XMOS