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?
Glitch on port out?
-
- Member++
- Posts: 21
- Joined: Sun Mar 03, 2013 11:26 pm
-
- Member++
- Posts: 21
- Joined: Sun Mar 03, 2013 11:26 pm
I have looked at this a bit more, and the same "glitch" appears to happen when writing essentially the same program in xc.
-
- XCore Expert
- Posts: 844
- Joined: Sun Jul 11, 2010 1:31 am
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.
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.
-
- Member++
- Posts: 21
- Joined: Sun Mar 03, 2013 11:26 pm
I am using the simulator in the xTools. Sorry, I guess that I forgot to mention that.
-
- XCore Expert
- Posts: 966
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
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.
-
- XCore Expert
- Posts: 844
- Joined: Sun Jul 11, 2010 1:31 am
That certainly is good advice, esp. for when you reconfigure ports.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.
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?
-
- XCore Expert
- Posts: 966
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
Yeah the ports are enabled by the constructors - so when you declare a port they are switched on before main.
Like the following you mean?same "glitch" appears to happen when writing essentially the same program in xc.
Code: Select all
port p = XS1_PORT_1A;
void main()
{ }
-
- Member++
- Posts: 21
- Joined: Sun Mar 03, 2013 11:26 pm
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;
}