Welcome! Log In Create A New Profile

Advanced

Using SD card and lcd12864 on the same bus

Posted by daaar 
Using SD card and lcd12864 on the same bus
July 19, 2022 11:45AM
In marlin, can I configure the display and memory card to work on the same spi bus? SCK, MISO, MOSI common for sd and st7920, and two separate CS for them
Re: Using SD card and lcd12864 on the same bus
July 19, 2022 04:59PM
I take you're designing custom hardware and ran out of pins. I suggest going with the next bigger package on the MCU and running dedicated signals. Much easier to do and very little extra cost when you look at the project as a whole.

I believe that Marlin already supports an LCD with a built in SD card reader that share the SCK, MISO, MOSI and use seperate CS pins. I'll see if I can find it.




If you want to roll one from scratch you'll need to do something along these lines.

The way to share hardware lines is to assign two different functions to each line in the pins_YOUR_BOARD.h file and use the soft SPI option for the SD card. The st7920 library (u8gl) uses it's own soft SPI. The two soft SPIs ignore each other. The pins file would look something like this:
#define SOFTWARE_SPI
  #define SD_SS_PIN                        P0_06
  #define SD_SCK_PIN                       P0_07
  #define SD_MISO_PIN                      P0_08
  #define SD_MOSI_PIN                      P0_09
  #define ST7920_SS_PIN                    P0_10
  #define ST7920_SCK_PIN                   SD_SCK_PIN 
  #define ST7920_MISO_PIN                  SD_MISO_PIN
  #define ST7920_MOSI_PIN                  SD_MOSI_PIN

The hard part is pointing the u8gl library at your ST7920 pins. Hopefully I can find an example that you can copy.




I'm a bit fuzzy on this but as I remember it the LPC1768 based 3D printer controllers ran out of pins and ended up without a seperate CS pin for the ST7920. As a result the LCD on the REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER would sometimes get corrupted when accessing the display's SD card. Took a lot of work to figure out how to rewrite the LCD quickly enough that it wouldn't be objectionable. Don't use any LPC1768 code as an example.
Re: Using SD card and lcd12864 on the same bus
July 19, 2022 05:07PM
The MKS_MINI_12864 uses a shared SPI for it's LCD and SD card. Use it as an example.
Re: Using SD card and lcd12864 on the same bus
July 22, 2022 05:16AM
Thanks for the advice. I just received st7920 and will try to connect
And yes, I made a custom board
Re: Using SD card and lcd12864 on the same bus
September 26, 2022 07:00PM
I had the same problem some time ago.
After a lot of trying and error, I did get it to work.

Here, you can check what I did:

[reprap.org]

Edited 1 time(s). Last edit at 09/26/2022 07:01PM by AlanCarvalho.
Sorry, only registered users may post in this forum.

Click here to login