Parallel Output of a Byte
-
- Posts: 2
- Joined: Wed Apr 08, 2020 3:35 pm
Parallel Output of a Byte
I need to write a byte to a GPIO port in a single operation. I can use any set of pins and any port. I've searched the documentation and can see no way to do it other than eight seperate pin() operations or using assembler or C.
Re: Parallel Output of a Byte
You can use viper code to write directly to a port register, and you can use uctypes.bytearray_at(addr, size) to read & write to a phsical memory location. For viper code, you find a documentation here: http://docs.micropython.org/en/latest/r ... de-emitter
I used that a lot in a SSD1963 driver for direct 8 bit wide port access. The sample driver is here:https://github.com/robert-hh/SSD1963-TF ... /TFT_io.py
I used that a lot in a SSD1963 driver for direct 8 bit wide port access. The sample driver is here:https://github.com/robert-hh/SSD1963-TF ... /TFT_io.py
-
- Posts: 2
- Joined: Wed Apr 08, 2020 3:35 pm
Re: Parallel Output of a Byte
Viper was the hint I needed. Thank you. Don't know why that was so hard to find.
Re: Parallel Output of a Byte
You can do this without ViperJohn Hasler wrote: ↑Wed Apr 08, 2020 4:06 pmI need to write a byte to a GPIO port in a single operation.
On the STM32 port there's a 'stm' module which gives you constants for most registers. Combined with machine.mem32 you can pretty much do anything.
Code: Select all
import machine
import stm
machine.mem32[stm.GPIOA] = ...
Re: Parallel Output of a Byte
machine.memxx calls are slow. If you need fast actions, viper works better.