Replies: 2 comments 6 replies
-
try: Also remove the commas at the line endings. |
Beta Was this translation helpful? Give feedback.
5 replies
-
As you have already found out, a value at an index is different from a slice of one byte when you are working with bytes or bytesarray. >>> buf=b'\x03\x0f\xff\xf0'
>>> for i in range(4):
... print(buf[i:i+1])
...
b'\x03'
b'\x0f'
b'\xff'
b'\xf0' You can replace If you need the reverse order, try this: >>> for i in range(4,0,-1):
... print(buf[i-1:i])
...
b'\xf0'
b'\xff'
b'\x0f'
b'\x03' |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I am trying to communicate with DAC8004 using SPI and thonny micropython.
from the manufacturer manual the periphery is pins 12-15.
However when i try to run the following code of the manual, I get an error shown below that says thatI have a problem in the SPI command.
Where did i go wrong implementing this command?
Thanks.
`import machine
from machine import SPI, Pin
from machine import Pin
from time import sleep
cs=machine.Pin(15,machine.Pin.OUT)
spi=machine.SPI(0,baudrate=1000000,polarity=0,phase=0,bits=8,firstbit=machine.SPI.MSB,
sck=machine.Pin(14),
mosi=machine.Pin(13),
miso=machine.Pin(12))`
ERROR:
Traceback (most recent call last):
File "", line 10, in
ValueError:
https://docs.micropython.org/en/latest/esp8266/quickref.html#hardware-spi-bus
https://www.espressif.com/sites/default/files/documentation/0a-esp8266ex_datasheet_en.pdf
Beta Was this translation helpful? Give feedback.
All reactions