Hello !
I've wanted to ask for advice and for question about code. I've bough lately some neopixels (8 leds in one strap), so I wanted to make a code, and decided to learn how it works from someones code. I wanted to ask for some help in understanding it.
My goal is to light up leds one after another when I click a button, so I click a button first leds lights up, and when I click again the button the second one lights up (first led is still on not off). The code I've been viewing was this one : https://www.thevfdcollective.com/blog/stm32-and-sk6812-rgbw-led
And here I had one problem the DMA callbacks ... first of all I know that callbacks should be short, but how measure if's its fast enough to read what is inside of the callback ?
Why I asked this question ? I've been having a dilemma lately, basically imagine this situation :
//A
// UART_Transmit B
//C
// UART Receive D
//E
If I called the function UART transmit and had transmitted all data then the device (slave) on the other side will now send data back to the (master) device, So in "A" nothing happens timing doesn't matter, in "B" as well because we send data in "C" it matters ! Because if it's to long the data will comeback before even the program will execute the "D" Receive function. But okey "c" is empty, then we have "D", it is also important because this function Receive is not empty it has plenty of lines of code which are translated into machine code ! Have in mind the device (slave) is sending back the data to the (master) device So data is coming while the Receive function is being executed (line of code after line of code), like imagine the data is coming and we are not ready to wait whether the data is fully received or not because the processor hasn't yet read the line of code (one of many in receive) that says to wait for a certain flag.
Well I've had many math thinking in low level like calculating the amount of instructions read per 10 bit of uart data in certain baud rate which sometimes lead to for 40 MHz 100 instructions to read before10 bit will be sent back to master from slave. So not much time to be honest. How do I know how many instructions it takes for single function to be executed fully !
Well that's my dilemma which I wasn't focusing on, maybe next time
This is just a thing I am very aware of although I shouldn't but I feel like either the function of receive or so are slow, because they have a lot of lines of code while something is being executed and they have to be fast enough ! And as a newbie in programming microprocessors I shouldn't think about it but I do somehow, same goes here !!
DMA callbacks ! How do I know that the thing in first callback is fast enough before the second callback is being triggered ? And what if I click the button which will also start the callback, then I have in total 3 callback and can be triggered 2 of them at the same time.
Second problem what I have in mind maybe not in the code of someone else but in concept of mine. The thing is that if I wait for to long 80us before clicking a button the reset cycle will happen and the first led diode instead of sending the data to the next diode it will take it as it's own. So yea I have to think of a way with that ... Because the from someone else is lighting all the leds.
I've wanted to ask for advice and for question about code. I've bough lately some neopixels (8 leds in one strap), so I wanted to make a code, and decided to learn how it works from someones code. I wanted to ask for some help in understanding it.
My goal is to light up leds one after another when I click a button, so I click a button first leds lights up, and when I click again the button the second one lights up (first led is still on not off). The code I've been viewing was this one : https://www.thevfdcollective.com/blog/stm32-and-sk6812-rgbw-led
And here I had one problem the DMA callbacks ... first of all I know that callbacks should be short, but how measure if's its fast enough to read what is inside of the callback ?
Why I asked this question ? I've been having a dilemma lately, basically imagine this situation :
//A
// UART_Transmit B
//C
// UART Receive D
//E
If I called the function UART transmit and had transmitted all data then the device (slave) on the other side will now send data back to the (master) device, So in "A" nothing happens timing doesn't matter, in "B" as well because we send data in "C" it matters ! Because if it's to long the data will comeback before even the program will execute the "D" Receive function. But okey "c" is empty, then we have "D", it is also important because this function Receive is not empty it has plenty of lines of code which are translated into machine code ! Have in mind the device (slave) is sending back the data to the (master) device So data is coming while the Receive function is being executed (line of code after line of code), like imagine the data is coming and we are not ready to wait whether the data is fully received or not because the processor hasn't yet read the line of code (one of many in receive) that says to wait for a certain flag.
Well I've had many math thinking in low level like calculating the amount of instructions read per 10 bit of uart data in certain baud rate which sometimes lead to for 40 MHz 100 instructions to read before10 bit will be sent back to master from slave. So not much time to be honest. How do I know how many instructions it takes for single function to be executed fully !
Well that's my dilemma which I wasn't focusing on, maybe next time
This is just a thing I am very aware of although I shouldn't but I feel like either the function of receive or so are slow, because they have a lot of lines of code while something is being executed and they have to be fast enough ! And as a newbie in programming microprocessors I shouldn't think about it but I do somehow, same goes here !!
DMA callbacks ! How do I know that the thing in first callback is fast enough before the second callback is being triggered ? And what if I click the button which will also start the callback, then I have in total 3 callback and can be triggered 2 of them at the same time.
Second problem what I have in mind maybe not in the code of someone else but in concept of mine. The thing is that if I wait for to long 80us before clicking a button the reset cycle will happen and the first led diode instead of sending the data to the next diode it will take it as it's own. So yea I have to think of a way with that ... Because the from someone else is lighting all the leds.