-
Hi, I've been struggling to combine an External Micro SD Card with the ILI9341 TFT display. I am working on a project for my college project, I needed 5 components along with the ESP32 dev kit on MicroPyhton. All my components work well, and in fact, my project is finished. But only recently I got my hands on the micro sd card. For a few days I tried to combine it with the display, but it didn't work. For testing I got some help from ChatGPT, which helped, but we are stuck in a loop, and I can't even get help from my teachers, because they have no clue either... My final exam is in less than a month away. I tried running the code that finally allowed me to read a text file. But the tft screen is loading a black image, and when I press the push button to communicate with the sd card, it reads the text, and along with it it seems to fill a very small portion of the screen with the color white. If I remove the initialization of the sd card, the image loads without any issues, but of course I can't access the sd card that way. Also, for some reason I need to reformat my sd card sometimes after running one of the codes. Below is one of the codes in Thonny I had saved, I'll appreciate some help. import machine Initialize TFT displayspi_display = SPI(2, baudrate=40000000, sck=Pin(18), mosi=Pin(23)) Initialize SD card (pins)spisd = SoftSPI(-1, miso=Pin(19), mosi=Pin(23), sck=Pin(18)) Button setupbutton = Pin(33, Pin.IN, Pin.PULL_UP) #Function to display the intro image def intro():display.draw_image('Intro.raw', 0,0,240,320)Function to read the text file from SD carddef read_sd_text_file():
Button interrupt handlerdef button_pressed(pin):
Set up button interruptbutton.irq(trigger=Pin.IRQ_FALLING, handler=button_pressed) if name == "main": |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
I noticed that it posted the code badly, so I'll post it as a text file. |
Beta Was this translation helpful? Give feedback.
-
Forgot to add, the libraries I use are: TFT Display: https://github.com/rdagger/micropython-ili9341 |
Beta Was this translation helpful? Give feedback.
-
You have two different SPI drivers defined using same SCK and MOSI- the SoftSPI and the hardware SPI. Even though they use different CS pins it seems like this could be a conflict. To test either use two completely different SPI definitions (different SCK, MOSI, MISO, ... baudrate) or use as single SPI and just set the different CS for use. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Yup, I know the difference now and I'm changing to timers. I didn't know that it delays everything, in fact, the teachers weren't those that told me about it, it was my Father.
Also, I figured my issue out, although still not perfect. But I used an interrupt that will initialize the microsd only when i need to.
So my problem is solved. Thanks for the replies.