LED drivers, How to connect them to Normal SPI - Page 1
Forum section: electronics / projects

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 06, 2019, 01:41:46 pm
content: Hi,There are lot's of cheep and good 16 channel LED drivers out there, Like MBI parts like MBI5043,MBI5045,MBI5030 etc... or from ST something like STP1612PW05 or similar ones. all of them seems to have a industry standard footprint and the protocol seems the same, I have bring them up by bit banging to them and they worked as expected, the weird thing is the LE signal which has this Number of CLKrising edge when LE is asserted do different things! I wonder how to connect them to a normal SPI and could get the 30MHz SPI clock, do we have a trick? in this way we can achieve the maximum speed, also I prefer to use STM32 for these ones, so do we have something there to help?

author: langwadt
author_rank: Super Contributor
timestamp: August 06, 2019, 01:47:46 pm
content: Quote from: ali_asadzadeh on August 06, 2019, 01:41:46 pmswitch between hw spi and bit banging depending on what you need to do ?

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 06, 2019, 02:07:28 pm
content: I want to do it with HW SPI, right now I'm doing bit-bang! Because I want to use DMA on SPI and free the CPU.

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 06, 2019, 02:38:20 pm
content: You could take a look at this: TLC5947http://www.ti.com/product/TLC5947

author: Benta
author_rank: Super Contributor
timestamp: August 06, 2019, 03:40:31 pm
content: SPI has different modes, where clock phase and clock polarity differ. Make certain you use the correct mode.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 07, 2019, 05:46:15 am
content: QuoteI know that, the problem is the LE signal! do we have any sample code with hardware SPI, any MCU or arduino?

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 07, 2019, 05:50:37 am
content: QuoteIt's not compatible with these chips!

author: ealex
author_rank: Frequent Contributor
timestamp: August 07, 2019, 12:22:24 pm
content: I took a quick look over the datasheet (https://olympianled.com/wp-content/uploads/2015/09/MBI5043.pdf)It looks like the LE will do different things, depending on how many clock cycles it's set to 1.I can think on several ways to do this:- synchronize 2 SPI channels, if possible on your CPU with the same clock and mode, one of them handles SDI and the other handles LE - you will need 2x16 bit words for each byte- use something like the external memory interface that's present on some STM32 chips, but you'll waste a lot of RAM if you don't connect several LED drivers in parallel- get a small FPGA / CPLD (Lattice maybe) and make it into a protocol converter - SPI pass-trough, some extra input pins that will specify the requested command, and a counter in the FPGA that will set the LE high at the appropriate moment. If you need just 1 command, you can even set an external counter chip that will set the LE line high at the proper moment and will be cleared by the SPI's #CS line.

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 07, 2019, 12:37:17 pm
content: Quote from: ali_asadzadeh on August 07, 2019, 05:50:37 amWhat isn't? It seems relatively straightforward to feed it data with a simple SPI bus. Were you looking for ICs with the exact same commands and pin-out (or are the analog specs or features not fitting the requirements)? Adapting the software to this chip looks simpler than trying to twist an SPI bus to drive the other ones. So do we have to understand that you're not going to change anything hardware-wise?Otherwise, one solution for the others (with this LE signal) would be for instance to use QSPI instead of SPI if your MCU supports it. QSPI is like SPI but can put out up to 4 bits (some MCUs even support 8 bits in extended SPI peripherals), you could use 2 bits of data to drive the data and LE signals.Then again, if absolutely no hardware change is allowed, you may not necessarily be able to do this if the QSPI (or similar) peripheral can't be used with the pins that were selected on the MCU (really depends on the MCU and how the IO mux works if there is any...)

author: TomS_
author_rank: Frequent Contributor
timestamp: August 07, 2019, 12:50:30 pm
content: Quote from: ali_asadzadeh on August 06, 2019, 02:07:28 pmWhat I would do is use DMA to transfer all of the data, which would be the most intensive part for bit banging, and with an interrupt on DMA transfer complete, bit bang a single clock pulse to latch the data in.You could even go as far as using a timer interrupt if you dont want to sit in a busy loop for your bit banged clock pulse.To me that seems like the least amount of effort for the CPU and the programmer.

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 07, 2019, 01:49:18 pm
content: Just as an added note if no hardware change is possible and if using SPI is not an option or wouldn't bring significant benefits due to this LE signal and how it must (if I got it well from the datasheets, but didn't look too deeply) apparently be toggled right in the middle of the serial communication: we haven't seen your code, but I think there are probably a number of ways to improve your bit-banging approach (including not making it blocking) so that its relative inefficiency wouldn't be a problem in your code.My assumption here is that 1/ LED driving itself is not that time-critical if it's just for viewing purposes - to be confirmed - and 2/ the way you currently bit-bang to the LED driver is likely blocking, and thus makes it impossible to execute anything else on the MCU until it's completely done. If 1/ is true, you could just implement the bit-banging in some timer interrupt for instance, "sending" just one bit at a time at whatever rate is convenient and still meets your requirements, but obviously as slow as possible. Time spent in this interrupt would be minimal. MCU could execute anything else while the communication is under progress, which, unless again updating the status of the LEDs should be very fast (useless if it's only a visual indicator), is probably your main concern here.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 07, 2019, 02:37:43 pm
content: Thanks for the feedback, The LED driver part is not allowed to change, but everything else is possible, also It should be on a low end MCU, because of the priceThis is the STM32 bit-bang code,QuoteIf it can be done efficiently with DMA and GPIO only, it would be nice! since GPIO and DMA is almost free on any cortex M part.

author: NorthGuy
author_rank: Super Contributor
timestamp: August 07, 2019, 03:46:07 pm
content: Quote from: ealex on August 07, 2019, 12:22:24 pmMake one SPI master, forward the clock from it to the other SPI.Make the second SPI slave, and use its MISO to output LE as needed.This will be perfectly synchronized and DMA-able.

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 07, 2019, 04:06:01 pm
content: Quote from: ali_asadzadeh on August 07, 2019, 02:37:43 pmConfirms that it's blocking.As I said above, making it non-blocking is largely possible even with no DMA, and not very difficult.Now you have several different options. Up to you to select the one that can be implemented on your MCU and that you feel comfortable with.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 08, 2019, 05:21:26 am
content: QuoteThanks, But how?QuoteThat sound a good option,but pricey in terms of SPI usage.