<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[how to share lcd spi?]]></title><description><![CDATA[<p dir="auto">Hi guys! this is my first post on this forum, I have some experience with the esp8266 and c and c++ but the esp32 and micropython are new to me.  So please try to be nice with me and and I apologize in advance for my English skill ;)</p>
<p dir="auto">I am on a m5stack core basic so i don't have psram, and right now I'm using the firmware fork of the lobo. <a href="https://github.com/m5stack/M5Stack_MicroPython" target="_blank" rel="noopener noreferrer nofollow ugc">link</a><br />
For what I understand so far this is not the latest firmware, it is no longer updated, but it is official and does not have a lot of uiflow stuff. (which I don't use, and I don't understand why I should want to use it) For now i am using upycraft as IDE, which is simple but it does its job.</p>
<p dir="auto">Sorry for this long introduction... XD<br />
I would like to use a simple SPI digital potentiometer (MCP41010) and the LCD.<br />
With something like this, calling the "cs_write" method, I can easily change the resistance of the potentiometer:</p>
<blockquote>
<p dir="auto">from machine import SPI,Pin<br />
from time import sleep</p>
<p dir="auto">CS_PIN = const(2)</p>
<p dir="auto">spi = SPI(2, baudrate=2600000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB, sck=Pin(18), mosi=Pin(23), miso=Pin(19)) #spihost=SPI.VSPI</p>
<p dir="auto">p0 = Pin(CS_PIN, Pin.OUT)<br />
p0.value(1)<br />
sleep(0.5)</p>
</blockquote>
<blockquote>
<p dir="auto">def cs_write(value):<br />
buf=bytearray(2)<br />
buf[0]=17 #b'\x11'   0001 0001<br />
buf[1]=value<br />
p0.value(0)<br />
spi.write(buf)<br />
p0.value(1)</p>
</blockquote>
<p dir="auto">and with something like this I can print on screen:</p>
<blockquote>
<p dir="auto">from m5stack import lcd<br />
lcd.tft_writecmd(0x21) #I have not completely understood why but to have the right colors I have to put this<br />
lcd.clear(lcd.RED)<br />
lcd.setCursor(100, 50)<br />
lcd.font(lcd.FONT_DejaVu24)<br />
lcd.print("Hello")</p>
</blockquote>
<p dir="auto">but if I run the two codes together when the second try to initialize the spi throw something like this:</p>
<blockquote>
<p dir="auto">[0;31mE (225533) spi_master: spi_bus_initialize(95): dma channel already in use[0m<br />
[0;31mE (225534) [SPI_UTILS]: spi bus initialization failed with rc=0x103[0m<br />
Traceback (most recent call last):<br />
File "&lt;stdin&gt;", line 1, in &lt;module&gt;<br />
OSError: Error initializing display</p>
</blockquote>
<p dir="auto">I could actually de-initialize the first spi and initialize the second every time but it's not the cleanest way and it takes more than a second each time to initialize the display.<br />
how can i do it? is there a way to have the spi instance from the display module and work on that by manually adjusting the cs pins?</p>
<p dir="auto">Any advice is welcome, thank you for reading, patience and any response</p>
]]></description><link>https://community.m5stack.com/topic/2017/how-to-share-lcd-spi</link><generator>RSS for Node</generator><lastBuildDate>Sun, 10 May 2026 06:11:41 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/2017.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 Jun 2020 16:14:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to how to share lcd spi? on Tue, 09 Jun 2020 06:57:23 GMT]]></title><description><![CDATA[<p dir="auto">maybe you could commit a issues to lobo github.   and if you want to use multi SPI device control we suggest you use Arduino to program it</p>
]]></description><link>https://community.m5stack.com/post/8939</link><guid isPermaLink="true">https://community.m5stack.com/post/8939</guid><dc:creator><![CDATA[m5stack]]></dc:creator><pubDate>Tue, 09 Jun 2020 06:57:23 GMT</pubDate></item><item><title><![CDATA[Reply to how to share lcd spi? on Mon, 08 Jun 2020 18:21:36 GMT]]></title><description><![CDATA[<p dir="auto">I feel alone ... a little help? :(</p>
]]></description><link>https://community.m5stack.com/post/8935</link><guid isPermaLink="true">https://community.m5stack.com/post/8935</guid><dc:creator><![CDATA[lightdemon]]></dc:creator><pubDate>Mon, 08 Jun 2020 18:21:36 GMT</pubDate></item></channel></rss>