Digital I/O on XUF216 part

XCore Project reviews, ideas, videos and proposals.
jzw
Member++
Posts: 24
Joined: Sat Nov 14, 2015 3:53 pm

Digital I/O on XUF216 part

Postby jzw » Tue Mar 16, 2021 4:25 pm

Are the digital I/O pins on the XUF216 driven high or is there a passive pullup? I want to join two parts together using standard I/O pins and need to know if this will cause any damage if one end is set high and the other low. Basically I want a wired or connection.

Also I believe that if I use PORT :> iData and PORT <: iData I change the pins from inputs to outputs. Does the peek(PORT) instruction change direction or just return the current state?

Thanks
User avatar
CousinItt
XCore Addict
Posts: 229
Joined: Wed May 31, 2017 6:55 pm

Postby CousinItt » Wed Mar 17, 2021 2:14 pm

The signal description chapter of the relevant data sheet shows whether each pin has a pull-up or pull-down resistor. Typically I/O pins are pulled down. To use wired-and you should provide a pull-up resistor and set each pin for low output or input.
Pins may have one or more of the following properties:
· PD/PU: The IO pin has a weak pull-down or pull-up resistor. The resistor is enabled during and after reset. Enabling a link or port that uses the pin disables the resistor. Thereafter, the resistor can be enabled or disabled under software control. The resistor is designed to ensure defined logic input state for unconnected pins. It should not be used to pull external circuitry. Note that the resistors are highly non-linear and only a maximum pull current is specifed in Section 13.3.
The peek instruction is used to check the actual pin state.
unsigned peek(void port p)

Instructs the port to sample the current value on its pins.

The port provides the sampled port-width bits of data to the processor immediately, regardless of its transfer width, clock, ready signals and buffering. The input has no effect on subsequent I/O performed on the port.

This function has the following parameters:

p The port to peek at.

This function returns: The value sampled on the pins.
jzw
Member++
Posts: 24
Joined: Sat Nov 14, 2015 3:53 pm

Postby jzw » Wed Mar 17, 2021 4:17 pm

This does not answer the question. Going back to olden days if the output is similar to an open collector device then if an external pullup is used and one part is set with the output high and the other part set low then the common line will be held low with no damage. If the part set high is driving the line from a low impedance source then damage could occur. I need to know if the line is driven high from a low impedance source if the pin is set high.

I have not found where the weak resistor is set to pull up or down, is this a different setting to just driving the output high or low?
User avatar
akp
XCore Expert
Posts: 512
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Wed Mar 17, 2021 5:34 pm

Executing set_port_drive_low() enables the open drain with weak pull up mode. You will want to use an XS2 device. It can work on single bit or multi bit ports. Then you just use the normal <: and :> commands to set the open drain output or read the input register, respectively.

Look here to see confirmation it works: viewtopic.php?t=6051

And refer to this from xs1.h:

Code: Select all

/**
 * Configures a port in drive low mode. When a 0 is output to a pin it is
 * driven low and when 1 is output no value is driven. For XS1 devices, if
 * the port is not a 1-bit port, the result of an output to the port is undefined.
 * On XS2 and XS1-G devices calling set_port_drive_low() has the side effect of
 * enabling the port's internal pull-up resistor. On XS1-L devices calling
 * set_port_drive_low() has the side effect of enabling the port's internal
 * pull-down resistor.
 * \param p The port to configure.
 * \sa set_port_drive
 * \sa set_port_drive_high
 * \sa set_port_pull_up
 * \sa set_port_pull_down
 */
void set_port_drive_low(void port p);
jzw
Member++
Posts: 24
Joined: Sat Nov 14, 2015 3:53 pm

Postby jzw » Wed Mar 17, 2021 7:35 pm

Thanks for the info. Just saying "open drain" reassures me.
User avatar
akp
XCore Expert
Posts: 512
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Thu Mar 18, 2021 1:18 pm

100%. This is the mode used for I2C SCL/SDA so it's going to work open drain.
jzw
Member++
Posts: 24
Joined: Sat Nov 14, 2015 3:53 pm

Postby jzw » Thu Apr 01, 2021 10:42 am

Thanks for the response. I've finally got round to some more experiments. If I use set_port_pull_up I can use a wired and connection between two boards, which is what I need to do. By experiment if I run without accessing the port it is in a non driven state unless I use set_port_pull_up, which is good.
If by accident I end up with two boards with one driving high and the other low will any damage occur? From the data sheet 4mA or 8mA source is quoted but are the outputs short circuit proof?
User avatar
akp
XCore Expert
Posts: 512
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Thu Apr 01, 2021 10:47 am

I would be surprised if damage could occur if you drove a pin set output high into a pin set output low, but I guess I don't know for certain. It's easy enough for you to test. Typically with MCUs in my experience it's not going to damage them but it's not recommended.
jzw
Member++
Posts: 24
Joined: Sat Nov 14, 2015 3:53 pm

Postby jzw » Thu Apr 08, 2021 11:14 am

Thanks akp. I have "tested" this now, and no damage appears to have happened. However I would like to know if adding more units to the system with higher drive capability would cause damage. The spec of the part refers to 4mA but I would like to know if an output is proof against any voltage in the possible range from a low impedance source, i.e how well is the circuitry protected. I suppose a schematic of the IO ports is not publicly available?
User avatar
akp
XCore Expert
Posts: 512
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Thu Apr 08, 2021 1:56 pm

Perhaps a good schematic of the IO port is available, but (if so) I don't know where it is.

Who is online

Users browsing this forum: No registered users and 1 guest