Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc165035

Browse files
committed
Fix blink example by correctly toggling output
The blink example was incorrect (as pointed out in issuemicropython#78).The example was toggling the GPIOs "output enable" state,instead of keeping "output enable" on and then toggling theoutput value of the pin.It "accidentally" worked, because we initally set the outputvalue to 1 (high) and thus, whenever "output enable" was set,the LED lit up, and when "output enable" was turned off, thepin was left floating without any output voltage and the LEDtherefore turned off.The new approach correctly enables "output enable" at thestart, and then only toggles the output value of the pin onand off.This change was also tested with a logic analyser, showingthat before this change, the logic analyser could not correclydetect a LOW state after a HIGH state, because the pin wasfloating without a pull-down resistor in place, whenever itwas not in "output enable" mode.After this change, the logic analyser correctly detected allLOW and HIGH states, because the pin remained in "outputenable" mode (and the ESP32 has a pull-down configured bydefault) and only the output value was toggled.
1 parent8fa7070 commitc165035

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

‎examples/blink.py‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@
3030
#define RTC_IO_TOUCH_PAD2_REG (DR_REG_RTCIO_BASE + 0x9c)
3131
#define RTC_IO_TOUCH_PAD2_MUX_SEL_M (BIT(19))
3232
#define RTC_GPIO_OUT_REG (DR_REG_RTCIO_BASE + 0x0)
33-
#define RTC_GPIO_ENABLE_W1TS_REG (DR_REG_RTCIO_BASE + 0x10)
34-
#define RTC_GPIO_ENABLE_W1TC_REG (DR_REG_RTCIO_BASE + 0x14)
35-
#define RTC_GPIO_ENABLE_W1TS_S 14
36-
#define RTC_GPIO_ENABLE_W1TC_S 14
33+
#define RTC_GPIO_ENABLE_REG (DR_REG_RTCIO_BASE + 0xc)
34+
#define RTC_GPIO_ENABLE_S 14
3735
#define RTC_GPIO_OUT_DATA_S 14
3836
3937
# constants from:
@@ -62,8 +60,8 @@
6260
# connect GPIO to ULP (0: GPIO connected to digital GPIO module, 1: GPIO connected to analog RTC module)
6361
WRITE_RTC_REG(RTC_IO_TOUCH_PAD2_REG, RTC_IO_TOUCH_PAD2_MUX_SEL_M, 1, 1);
6462
65-
# GPIO shall be output, not input
66-
WRITE_RTC_REG(RTC_GPIO_OUT_REG, RTC_GPIO_OUT_DATA_S + gpio, 1, 1);
63+
# GPIO shall be output, not input (this also enables a pull-down by default)
64+
WRITE_RTC_REG(RTC_GPIO_ENABLE_REG, RTC_GPIO_ENABLE_S + gpio, 1, 1)
6765
6866
# store that we're done with initialisation
6967
move r0, magic
@@ -83,12 +81,12 @@
8381
8482
on:
8583
# turn on led (set GPIO)
86-
WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TS_REG, RTC_GPIO_ENABLE_W1TS_S + gpio, 1, 1)
84+
WRITE_RTC_REG(RTC_GPIO_OUT_REG, RTC_GPIO_OUT_DATA_S + gpio, 1, 1)
8785
jump exit
8886
8987
off:
9088
# turn off led (clear GPIO)
91-
WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TC_REG, RTC_GPIO_ENABLE_W1TC_S + gpio, 1,1)
89+
WRITE_RTC_REG(RTC_GPIO_OUT_REG, RTC_GPIO_OUT_DATA_S + gpio, 1,0)
9290
jump exit
9391
9492
exit:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp