I’m currently wondering if the output_pins in an macro are / should be processed in a consecutive manner.
I got following constellation here:
RPI Pico (MCU) connected to an RPI3 which runs MainsailOS.
What me got to the problem:
I tried to run a HD44780 Display connected at the RPI Pico, but that has not worked properly and now I’m trying to initialize the Display manually by settings output_pins.
I’m sure that the display is connected correctly, because I programmed the pi pico in micropython and display worked here flawlessly.
MCU und Output PIN Configuration:
[mcu rp_pico]
serial: /dev/serial/by-id/usb-Klipper_rp2040_E6611C08CB077322-if00
baud: 250000
restart_method: rpi_usb
[output_pin pico_led]
pin: rp_pico:gpio25
[output_pin lcd_rs]
pin: rp_pico:gpio0
[output_pin lcd_e]
pin: rp_pico:gpio1
value: 1
[output_pin lcd_d4]
pin: rp_pico:gpio5
[output_pin lcd_d5]
pin: rp_pico:gpio4
[output_pin lcd_d6]
pin: rp_pico:gpio3
[output_pin lcd_d7]
pin: rp_pico:gpio2
Now to my actual problem:
When I run the lcd_test macro
[gcode_macro all_data_low]
gcode:
SET_PIN PIN=lcd_d7 VALUE=0
SET_PIN PIN=lcd_d6 VALUE=0
SET_PIN PIN=lcd_d5 VALUE=0
SET_PIN PIN=lcd_d4 VALUE=0
[gcode_macro pulse]
gcode:
SET_PIN PIN=lcd_e VALUE=0
SET_PIN PIN=lcd_e VALUE=1
[gcode_macro lcd_init]
gcode:
SET_PIN PIN=lcd_d4 VALUE=1
SET_PIN PIN=lcd_d5 VALUE=1
SET_PIN PIN=lcd_d6 VALUE=0
SET_PIN PIN=lcd_d7 VALUE=0
pulse
[gcode_macro lcd_test]
gcode:
#Default States for GPIOs
SET_PIN PIN=lcd_rs VALUE=0
SET_PIN PIN=lcd_e VALUE=1
all_data_low
#LCD Initializatation (https://web.alfredstate.edu/faculty/weimandn/lcd/lcd_initialization/lcd_initialization_index.html - "4-Bit Interface, Initialization by Instruction")
lcd_init
lcd_init
lcd_init
I can see the outputs behaving correctly with my logic analyzer.
(Picture must be unfortunately external because i’m not allowed to upload more then one picture in my post.)
RS=lcd_rs
EN=lcd_en
Bus:3 = lcd_d4
Bus:2 = lcd_d5
Bus:1 = lcd_d6
Bus:2 = lcd_d7
But when I just make small changes to the macro, it seams that the output_pins would no be handled consecutively.
When I run the extended version of lcd_test macro
[gcode_macro all_data_low]
gcode:
SET_PIN PIN=lcd_d7 VALUE=0
SET_PIN PIN=lcd_d6 VALUE=0
SET_PIN PIN=lcd_d5 VALUE=0
SET_PIN PIN=lcd_d4 VALUE=0
[gcode_macro pulse]
gcode:
SET_PIN PIN=lcd_e VALUE=0
SET_PIN PIN=lcd_e VALUE=1
[gcode_macro lcd_init]
gcode:
SET_PIN PIN=lcd_d4 VALUE=1
SET_PIN PIN=lcd_d5 VALUE=1
SET_PIN PIN=lcd_d6 VALUE=0
SET_PIN PIN=lcd_d7 VALUE=0
pulse
[gcode_macro lcd_test]
gcode:
#Default States for GPIOs
SET_PIN PIN=lcd_rs VALUE=0
SET_PIN PIN=lcd_e VALUE=1
all_data_low
#LCD Initializatation (https://web.alfredstate.edu/faculty/weimandn/lcd/lcd_initialization/lcd_initialization_index.html - "4-Bit Interface, Initialization by Instruction")
lcd_init
lcd_init
lcd_init
#Initial Function Set
all_data_low
SET_PIN PIN=lcd_d5 VALUE=1
pulse
The my logic anlyzer shows the following output:
RS=lcd_rs
EN=lcd_en
Bus:3 = lcd_d4
Bus:2 = lcd_d5
Bus:1 = lcd_d6
Bus:2 = lcd_d7
From macro defintion I would have expected that the Bus:2 Signal should have been put zero much later.
Maybe I also get the wrong idea of how do this. I’m pretty new to the klipper world.
Can somebody please explain:
- Is this behavior correct ?
- Are the output_pins processed in a consecutive way ?
Kind regards,
Sebastian