-
Unfortunately i don't have one...
I also found stm32's
jshDelayMicroseconds
function you were talking about earliervoid jshDelayMicroseconds(int microsec) { int iter = (int)(((long long)microsec * (long long)JSH_DELAY_MULTIPLIER) >> 10); // iter -= JSH_DELAY_OVERHEAD; if (iter<0) iter=0; while (iter--) __NOP(); }
I see the logic of this function like this:
iter = microsec * (how_fast_mc_is / how_fast_it_should_be)
But i don't understand how to make this function work with nanoseconds.
-
@allObjects, I finally managed to solder a second transistor as you offered. It looks terrible, but it works! Now the signal is not inverted. I also recompiled Espruino so that STM32 uses hardcoded timers and changed the timers from
\#define PATTERN_PULSE_T0H() for(uint32_t i = 0; i < 17; i++) {__NOP();} \#define PATTERN_PULSE_T0L() for(uint32_t i = 0; i < 33; i++) {__NOP();} \#define PATTERN_PULSE_T1H() for(uint32_t i = 0; i < 30; i++) {__NOP();} \#define PATTERN_PULSE_T1L() for(uint32_t i = 0; i < 20; i++) {__NOP();}
to
\#define PATTERN_PULSE_T0H() for(uint32_t i = 0; i < 7; i++) {__NOP();} \#define PATTERN_PULSE_T0L() for(uint32_t i = 0; i < 14; i++) {__NOP();} \#define PATTERN_PULSE_T1H() for(uint32_t i = 0; i < 13; i++) {__NOP();} \#define PATTERN_PULSE_T1L() for(uint32_t i = 0; i < 8; i++) {__NOP();}
But no matter what I send, the LED's are always white. My thought was if F405 is
168 MHz
and F103 is72 MHz
I should just scale the delay values proportionally. @Gordon, what am I missing here? -
May I ask what the thought is, not using SPI? Are we still attempting to solve why is the first Neo green here?
Yes, I am trying to solve this issue and another one at the same time: the second line of Neopixels is connected to a pin with no hardware SPI on it. Running a data line from the end of one line of LEDs to the beginning of another one feels terrible. This is why I am trying to workaround hardware SPI usage.
What we've got now: The LEDs are not damaged, even the first one (which is always green when controlled by Espruino). When I poke a wire from Arduino to Neopixel's data line everything works perfectly. But Arduino is 5v.
@Gordon, could you please tell me where can I find the code for the
F405
? I couldn't find it in Espruino sources. Is it outside of Neopixel lib or even deprecated? -
-
The LEDs are fine. I connected data line to Arduino and launched Adafruit's Neopixel demo sketch. Everything works beautifully.
I don't think SPI is the only way to run Neopixels with STM32. Basically, SPI is sending 4x more data at 4x more speed to mimic the LED's protocol. Does Espruino allow controlling a pin with a CPU directly with tiny timings, like: "set HIGH to the pin, wait for 450 nanoseconds, set LOW etc.." or it is a too low-level task?
-
Yay! We are getting somewhere, guys!)
But there is an issue with the first LED. Its green part always turns on no matter what color I set it to. When I reset the board all LEDs turn off, but when I turn them off manually by sending zeros, first always stays green. In the picture, I made a red to green gradient, you can see that first color is wrong.
@Gordon, the clock is fine, the problem was with the Neopixels soldered upside down. There was a misleading dot in the corner of every LED's footprint. I matched it with the notch of each LED but turned out that dot indicated power pin. When I replaced all the LEDs (they all burnt), the
af_opendrain
method worked. I just need to figure out the first LED's issue. -
-
How can I check the clock settings?
Looks like I damaged one pin on my STM32 which was responsible for the Neopixel control. Now I'm left with the B6 pin, which is still alive but does not have SPI. Can I implement Neopixels protocol without the lib, using only CPU and hardcoded timings? I know that vanilla STM32 can do it. Is it possible on Espruino?
I ordered new STM32's and I just want to localize the problem while they are being delivered.
-
@Gordon, could you please clarify one moment for me? Espruino Neopixel API reference says the following:
If I remove my transistor, connect STM32's pin directly to Neopixels's data and add a pull-up resistor to 5V there, then set this pin to
af_opendrain
mode and run
require("neopixel").write(B5, [255, 255, 255]);
It should work, right?I have tried this and it didn't work. I begin to suspect that I accidentally burned the LEDs...
-
@allObjects, yeah, the fix @MaBe posted is really interesting, but not suitable in my case.
I am using IN-18 tubes made in USSR. I was lucky enough to find them on some weird site (like craigslist but Russian). They are not that common, but still possible to find. They were sold for 25$ each, so I bought all the lamps that guy had! My treasure. This box was sealed in 1981.
-
@allObjects, exactly
-
@allObjects, there is a link to my project in #19. It has my PCB layout, just change the tab.
-
-
I tried to squeeze one more transistor into my PCB and failed. SMD components are too tiny for "in the air" fixes. I talked to a guy who helped me to make the PCB recently and he said that I can just remove the transistor and connect the pin directly to Neopixel's data keeping the connection with 5v. Then the pin can be used to pull the 5v line to ground. Is there any other option then send4bit? ` Can I control the pin's state directly with the correct timing with Espruino?
-
Do you agree with my #18 assessment
Absolutely. Thinking on how to add one more transistor on each line there. There is enough room, but I want to minimize the mess.
So does this board then only use hardware SPI? e.g. is it capable of software SPI?
I have no idea. The datasheet says that there is an SPI on the B5 pin. I am using Espruino's
SPI.setup
function. When I use it on the B5 port it is ok. When I use it on B6 port there is an error "ERROR: Pin B6 is not capable of SPI1 MOSI". I don't know what characteristics a port should have to be capable of a software SPI. As I mentioned earlier, there is this line in Espruino's 2.0 update notes:Software Serial Transmit and Receive on any pin
Isn't this an SPI? This looks very promising.
-
Yep, I've seen it. I am using my own board and I made a custom build of Espruino for it. Nothing special, it is based on
STM32Discovery
with the package changed toLQFP48
and some more little tweaks. I also usedpin_names_direct
as @Gordon offered. I have posted a link to my board PCB layout and diagram in my previous post. -
@Robin, thanks for the encouragement) I have tried sending data as you offered with no effect. I feel that there is nothing left to try with the software part. Another reason why I was evading hardware fixes is that all my components are SMD, and transistors have the TO-236AB package. I have a soldering station with a hot air gun, so soldering these components on a factory-quality PCB is fairly easy. But I can hardly imagine how to make this "in-the-air" fix with SMD components. Resistors are SMD too, they are 0805. So here comes the tricky part.
By the way, I have two separate lines of Neopixels. One of them is on B5 and another one on B6 port. There is no SPI on B6. I have seen, that latest Espruino version can setup SPI on every pin, but does it have enough speed to control the Neopixels?
Here is how my whole project looks like. Just in case.
-
I tried this:
SPI1.setup({baud:3200000, mosi:B5}); // like so SPI1.send4bit([1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1], 0b1110, 0b1100);
This should turn the first led white, but did nothing :(
Is this wrong?I also found this guide showing how to control WS2812 with PWM and DMA. This is a very efficient way, as they say. This guide is far beyond my understanding. Is something like this available with Espruino?
When I started this project, I thought that the LED part would be easy and fun. Already wasted four days on this problem, lol)
-
-
-
-
-
-
Almost year passed and I solved the issue today. Unfortunately I had to drop Espruino and stick to low level HAL STM32 library. The LED pin is controlled by timer's PWM and DMA. If you invert the timer polarity simply changing one register everything starts working. I want to say a HUGE thanks to everyone who helped me with this problem. You guys are awesome. OMG I can finally finish my clock now, I am so happy!
I will post the clock here as soon as I finish them.