Is there a simple was to combine 2 or more pins together as a virtual port and read as binary bits ?
I am using a PIC micro to do some things outside of micropython and one of the things it will do is to output a 2 bit value (0 to 3) which I would like to read in micropython.
Read 2 or more pins as binary bits
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: Read 2 or more pins as binary bits
I would assume that you would do something like this
Code: Select all
two_bits = pin1.value() <<1 | pin2.value()
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Read 2 or more pins as binary bits
That would be my approach.
If speed is vital it is possible to access multi-bit I/O but it isn't for the faint-hearted; it certainly needs a study of the chip datasheet. An example may be found here in the file TFT_io.py.
If speed is vital it is possible to access multi-bit I/O but it isn't for the faint-hearted; it certainly needs a study of the chip datasheet. An example may be found here in the file TFT_io.py.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.