Hello
I have an ESP32(WROOM) running latest MicroPython (MicroPython v1.12-119-g61f64c78a on 2020-02-01; ESP32 module with ESP32)
connected to a 2.8" 240x320 TFT with ili9341 driver chip, via SPI.
Using a ili9341 MicroPython driver ( e.g ili9341 from Adafruit or similar) I can draw shapes, text etc.
As an exercise I would like to "Read display identification information (04h)" without using the ili9341 Micropython driver, but I have not been successful.
Here is my code....
from machine import Pin, SPI
from time import sleep
# import ubinascii
vspi = SPI(2, baudrate=100000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
vspi.init(baudrate=2000000)
cs = Pin(5, Pin.OUT)
cs.value(0)
dc = Pin(17, Pin.OUT)
dc.value(1)
buf = bytearray(4)
rst = Pin(16, Pin.OUT)
while True:
sleep(1)
rst.value(0)
sleep(.1)
rst.value(1)
# cs.value(0)
# dc.value(1)
#dc.value(0)
#vspi.write(b'04')
#sleep(1)
dc.value(1)
#vspi.readinto(buf, 0x04)
a = vspi.read(3, 0x04)
Here is the output I have been getting ..
b'\xff\xff\xff' or b'\x00\x00\x00' which I consider is wrong
I assume I should be getting a 93 41 code
I have connected a logic analyser and I can see data on the MOSI line and clock activity on the sck(clock) line BUT I do not see any activity on the MISO line. I have tried different MicroPython SPI commands/combinations without any success.
Could someone show me some simply MicroPython code that might work or indicate what I am doing wrong.
Any help would be much appreciated.
Regards Frank
MicroPython SPI code problems
Re: MicroPython SPI code problems
Some devices require you to use the CS line to start an operation.
i.e.
- reset device (rst low, sleep, rst high)
- select command/data (dc high/low)
- start op (cs low)
- send / recv
- finish (cs high)
Do you see the correct data with the logic analyser on the MOSI and SCK lines? Is it definitely the correct polarity and phase?
i.e.
- reset device (rst low, sleep, rst high)
- select command/data (dc high/low)
- start op (cs low)
- send / recv
- finish (cs high)
Do you see the correct data with the logic analyser on the MOSI and SCK lines? Is it definitely the correct polarity and phase?