Skip to content
LDmicroGitHub edited this page Jun 4, 2018 · 9 revisions

Read before:
Pull up resistor / Pull down resistor

Note: Not all microcontroller ports have internal pull-up resistors. See datasheets of the controller.
pull_up

Port is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each pin separately).
image
By default, LDmicro enables all internal pull-up resistors on all digital inputs X (if pull-up resistor present in pin circuit).

So when you need a button, you simply connect them to the microcontroller pins. Without any additional resistors, like here
image
1) The buttons at the picture above are "Normally Open".
When the button is unpressed, then pin input level is HI (near Vcc).
When the button is pressed down, then pin input level is LO (near GND).

Then you set checkbox 'Negated' to get normal logic (not inverted) in LD micro.
And when you simulate "press" Xone, then the output level Xone is HI.
image
Also, you should set checkbox 'Set Hi input level before simulation'. This sets input level according to real hardware schematic signal level.
image
If you not set Hi input level before simulation, then Xthree=0 is negated to 1 and start Tdebounce3.
image

2) If used switch SW1 is "Normally Closed".
When the button is unpressed, then pin input level is LO (near GND).
When the button is pressed down, then pin input level is HI (near Vcc thru the internal pull-up resistor).
image
Then in LDmicro, you do not need to negate input Xsensor to normal logic.
image

Use an external resistor RpuExt (See Figure 14.1), if there is no internal pull-up.

3) There is a safety problem when using a pull-up resistor.
When a contact is incorrectly configured as an output and set to 1(high level) and accidentally connected to the ground, the pin can grill.
image

4) See also AN1785 ESD and EOS Causes, Differences and Prevention

Clone this wiki locally