Glitch on port out?

Technical questions regarding the XTC tools and programming with XMOS.
diltsman
Member++
Posts: 21
Joined: Sun Mar 03, 2013 11:26 pm

Glitch on port out?

Post by diltsman »

I am using an XK-1A.

I have a program that is configuring a port in C++ with inline assembly. When setc res[XS1_PORT_4F], CTRL_INUSE_ON is executed I see the wave for the port go to 0xf for 10 ns (1 clock). It is 0 before this and then returns to zero until I actually execute an out on the port.

Is this the port actually outputting 0xf (looks like a glitch to me) or is something else happening? How can I tell if a port is in input or output mode from the Waves tab? Also, if this is a glitch, is there some way for me to prevent it?


diltsman
Member++
Posts: 21
Joined: Sun Mar 03, 2013 11:26 pm

Post by diltsman »

I have looked at this a bit more, and the same "glitch" appears to happen when writing essentially the same program in xc.
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

Is it really driving it strongly high, or is something weakly pulling
it up (either the chip, or something else on your board, or even
your measuring equipment)? I'm thinking it could be the internal
pulldown switching off.
diltsman
Member++
Posts: 21
Joined: Sun Mar 03, 2013 11:26 pm

Post by diltsman »

I am using the simulator in the xTools. Sorry, I guess that I forgot to mention that.
User avatar
Ross
XCore Expert
Posts: 966
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

You don't mention the configuration of the port, but if at all possible it is recommended to configure ports using the "configure_" functions in xs1.h since they are written in a way that avoids glitches and safe against exceptions etc.
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

Ross wrote:You don't mention the configuration of the port, but if at all possible it is recommended to configure ports using the "configure_" functions in xs1.h since they are written in a way that avoids glitches and safe against exceptions etc.
That certainly is good advice, esp. for when you reconfigure ports.
The correct order to do things in can be tricky.

But the configure_* functions do not enable the ports (setc IN_USE);
that is done by the constructors, which run essentially the same
code as diltsman's as far as I can see?
User avatar
Ross
XCore Expert
Posts: 966
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Yeah the ports are enabled by the constructors - so when you declare a port they are switched on before main.
same "glitch" appears to happen when writing essentially the same program in xc.
Like the following you mean?

Code: Select all

port p = XS1_PORT_1A;
void main()
{ }
diltsman
Member++
Posts: 21
Joined: Sun Mar 03, 2013 11:26 pm

Post by diltsman »

This is the exact XC code.

Code: Select all

#include <platform.h>

out port bled = PORT_BUTTONLED;

int main (void) {
	for (int o = 0x03;; o = ~o)
	{
		bled <: o;
	}
    return 0;
}