I'm using an STM32F411RE Nucleo board to develop some code for a digital guitar effects pedal, and I need to be able to implement a tap tempo.
I'm fairly inexperienced with coding in general. Does anybody know the easiest way to simply press a GPIO button twice, measuring the interval between the two presses, and assign that value to a parameter? Or at the very least just take that interval and flash an LED at that delay time? Assuming this is going to be utilizing some sort of interrupt.
Thanks!
Edit: I am using STM32CubeIDE with the HAL (Hardware Abstraction Layer) Library. I am able to easily read inputs and send outputs to various GPIO pins via the use of this library. I am also utilizing an external 8MHz clock.
If you need help with reading the input, setting the output, and the timing then the question is too broad and you should post separate questions for each concept. However, assuming you have the following fundamental building blocks:
bool getTempoInput() ;- function that reads state of tempo setting input switch.void setTempoOutput( bool state)- function that sets the state of the tempo indicator.unsigned getMillisecTick()- function that returns a free-running millisecond count.Clearly the names and signature of the functions need not be as above, but that allows the following pseudo-code (since we do not know what actual framework or library you might be using - if any).
Treat the above as illustrative - I have no means of testing it, it may contain flaws. Important points are:
tempo_millisecshared. The code could be better structured with these blocks in separate functions - (an exercise for the reader).