<?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[M5StackS3-SE + LoRa868 V1.1 SPI Conflict?]]></title><description><![CDATA[<p dir="auto">Hi. I have both an M5StackS3-SE and a LoRa868 V1.1 in a stack. I wrote a driver for the sx127x that fits my needs. I have WiFi, AWS IoT connectivity, and the sx127x working perfectly. I recently decided to try to get the display working so I could put together a simple LVGL application to display some metrics.</p>
<p dir="auto">I decided to use the BSP component for the M5Stack CoreS3 located here: <a href="https://github.com/espressif/esp-bsp/tree/master/bsp/m5stack_core_s3" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/espressif/esp-bsp/tree/master/bsp/m5stack_core_s3</a>. It's pretty straight forward to consume the component and initialize the BSP. When I do this, I see that it initializes the SPI Master controller itself (HOST2), which is not a problem, in theory. The LoRa radio communicates over the same SPI lines (MISO, MOSI, and SCK). I made sure to select a Chip Select line that does not conflict with anything else (DIP switches on the LoRa radio stack).</p>
<p dir="auto">I am not able to get the LoRa radio to work when I initialize the display. I can get the display to work and render one of the LVGL demos without a problem, but I am not able to also communicate with the LoRa radio at the same time. I should be able to as the ESP SPI Master controller driver should handle multiple drivers utilizing the same SPI configuration with different chip select lines.</p>
<p dir="auto">Here's my DIP switch config for the LoRa radio:</p>
<ul>
<li>NSS = G6 (<code>BUS_G6</code> on the schematic, straight to header)</li>
<li>IRQ = G10 (<code>BUS_ADC1</code> on the schematic, straight to header)</li>
<li>RST = G7 (<code>BUS_G7</code> on the schematic, straight to header)</li>
</ul>
<p dir="auto">This is how I setup the SPI device using the SPI driver:</p>
<pre><code>// Configure SPI bus
spi_device_interface_config_t spi_dev_cfg = {
    .clock_speed_hz = 9000000,  // 9MHz
    .mode = 0,
    .spics_io_num = hw_config-&gt;cs_gpio,
    .queue_size = 7,
    .flags = 0,
    .pre_cb = NULL
};
ret = spi_bus_add_device(spi_host, &amp;spi_dev_cfg, &amp;device-&gt;spi);
if (ret != ESP_OK) {
    ESP_LOGE(TAG, "Failed to add SPI device");
    // .. some error handling here ...
    return NULL;
}
</code></pre>
<p dir="auto">I confirmed in the BSP implementation that the SPI master controller appears to be initialized correctly (<a href="https://github.com/espressif/esp-bsp/blob/master/bsp/m5stack_core_s3/m5stack_core_s3.c#L173" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/espressif/esp-bsp/blob/master/bsp/m5stack_core_s3/m5stack_core_s3.c#L173</a>).</p>
<p dir="auto">It appears the DC (Data/Command) line for the LCD controller is also connected to the same MISO pin as configured by the documentation and the BSP implementation (<a href="https://github.com/espressif/esp-bsp/blob/master/bsp/m5stack_core_s3/include/bsp/m5stack_core_s3.h#L63C9-L63C19" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/espressif/esp-bsp/blob/master/bsp/m5stack_core_s3/include/bsp/m5stack_core_s3.h#L63C9-L63C19</a>). I am not sure if this could cause problems.</p>
<p dir="auto">I am likely overlooking the issue here. I hope it's just a silly mistake on my side. I am hoping someone perhaps knows what is going on here and can point me in the right direction.</p>
<p dir="auto">Many thanks in advance!</p>
]]></description><link>https://community.m5stack.com/topic/6953/m5stacks3-se-lora868-v1-1-spi-conflict</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 06:43:24 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6953.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 02 Nov 2024 20:55:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to M5StackS3-SE + LoRa868 V1.1 SPI Conflict? on Thu, 07 Nov 2024 03:20:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a> Thank you for the pointer! Looks like perhaps it's fixed for the Arduino implementation? It does not seem fixed for the ESP-IDF version quite yet. Your workaround combined with the <code>pre_cb</code> and <code>post_cb</code> callbacks worked! Here's a snippet/summary of what I did:</p>
<pre><code>#ifdef CONFIG_M5CORES3_SPI_CONFLICT_FIX
#define M5CORES3_SPI_CONFIG_FIX_MISO_PIN 35

void sx127x_spi_pre_transfer_m5cores3_fix_callback(spi_transaction_t* t) {
    // before a SPI transaction is started, we need to change the driving direction
    // of the DC pin in the CoreS3 (the CoreS3 uses the MISO pin as the DC pin and 
    // configures it as an output ping which conflicts with other SPI devices on the bus)
    
    // set gpio direction for MISO pin to input
    gpio_set_direction(M5CORES3_SPI_CONFIG_FIX_MISO_PIN, GPIO_MODE_INPUT);
}

void sx127x_spi_post_transfer_m5cores3_fix_callback(spi_transaction_t* t) {
    // undo pin direction change after SPI transaction is done

    // set gpio direction for MISO pin back to output
    gpio_set_direction(M5CORES3_SPI_CONFIG_FIX_MISO_PIN, GPIO_MODE_OUTPUT);
}
#endif

sx127x_handle_t sx127x_init(const sx127x_modem_config_t* modem_config)
{
    // ...

    // Configure SPI device
    spi_device_interface_config_t spi_dev_cfg = {
        .clock_speed_hz = 9000000,  // 9MHz
        .mode = 0,
        .spics_io_num = modem_config-&gt;cs_gpio,
        .queue_size = 7,
        .flags = 0,
        #ifdef CONFIG_M5CORES3_SPI_CONFLICT_FIX
        .pre_cb = sx127x_spi_pre_transfer_m5cores3_fix_callback,
        .post_cb = sx127x_spi_post_transfer_m5cores3_fix_callback
        #endif
    };
    ret = spi_bus_add_device(spi_host, &amp;spi_dev_cfg, &amp;device-&gt;spi);
    if (ret != ESP_OK) {
        ESP_LOGE(TAG, "Failed to add SPI device");
        vSemaphoreDelete(device-&gt;spi_mutex);
        free(device);
        return NULL;
    }

    // ...
}
</code></pre>
<p dir="auto">I can now use both the display and the sx1276 at the same time on the M5Stack CoreS3.</p>
<p dir="auto">Thanks again for your assistance!</p>
]]></description><link>https://community.m5stack.com/post/26979</link><guid isPermaLink="true">https://community.m5stack.com/post/26979</guid><dc:creator><![CDATA[r0kh0rd]]></dc:creator><pubDate>Thu, 07 Nov 2024 03:20:48 GMT</pubDate></item><item><title><![CDATA[Reply to M5StackS3-SE + LoRa868 V1.1 SPI Conflict? on Mon, 04 Nov 2024 11:01:24 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/r0kh0rd" aria-label="Profile: r0kh0rd">@<bdi>r0kh0rd</bdi></a></p>
<p dir="auto">I think it has been fixed by M5Stack. Check out this <a href="https://github.com/m5stack/M5CoreS3/blob/main/examples/Basic/sdcard/sdcard.ino" target="_blank" rel="noopener noreferrer nofollow ugc">example</a> - works for me.</p>
<p dir="auto">BTW: my example does not work anymore as <code>M5.Lcd.getSPIinstance()</code> no longer exists in <code>M5CoreS3</code> library.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/26946</link><guid isPermaLink="true">https://community.m5stack.com/post/26946</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Mon, 04 Nov 2024 11:01:24 GMT</pubDate></item><item><title><![CDATA[Reply to M5StackS3-SE + LoRa868 V1.1 SPI Conflict? on Sun, 03 Nov 2024 15:53:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a> Thanks a ton for that pointer! That looks promising. A bit unfortunate it was designed this way if that workaround is the only way. The official M5Stack CoreS3 BSP also has a warning that says that the SD Card does not work and they are working on fixing it. I wonder if the issue is similar to this. I am going to try to implement this and report back.</p>
<p dir="auto">In ESP-IDF there is a <code>pre_cb</code> and <code>post_cb</code> (callback configurations) that can be configured with the SPI device when it's registered on the bus. This should allow me to accommodate the DC/MISO reconfiguration in a bit more automated of a way.</p>
<p dir="auto">Thanks again for your help!</p>
]]></description><link>https://community.m5stack.com/post/26942</link><guid isPermaLink="true">https://community.m5stack.com/post/26942</guid><dc:creator><![CDATA[r0kh0rd]]></dc:creator><pubDate>Sun, 03 Nov 2024 15:53:12 GMT</pubDate></item><item><title><![CDATA[Reply to M5StackS3-SE + LoRa868 V1.1 SPI Conflict? on Sun, 03 Nov 2024 14:51:14 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/r0kh0rd" aria-label="Profile: r0kh0rd">@<bdi>r0kh0rd</bdi></a></p>
<p dir="auto">I am not sure it is still valid, but last year I encountered a similar issue when trying to use the LCD and the SD card together with an M5CoreS3.</p>
<p dir="auto">Maybe the <a href="https://github.com/felmue/MyM5StackExamples/blob/main/M5CoreS3/SDCardAndLCD/SDCardAndLCD.ino" target="_blank" rel="noopener noreferrer nofollow ugc">solution</a> I found at the time might be helpful for your situation as well.</p>
<p dir="auto">Note: I cannot test this myself as I lack the necessary hardware, e.g. I do not have a LoRa868 v1.1.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/26941</link><guid isPermaLink="true">https://community.m5stack.com/post/26941</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Sun, 03 Nov 2024 14:51:14 GMT</pubDate></item></channel></rss>