-
Mon 2021.09.13
reply to post #6
analogWrite(PIN, value, { freq : my_freq_in_hz } ) Maybe in this case PWM will be the solution.
You are on the right track. I see from the code that a width of one complete pulse is around 20usec. (Is that accurate? response from post #10 needed here)
I'll agree that trying to simulate a pulse train with Javascript might be a bit of a challenge as Espruino is using an Interpreter and isn't compiled, but I was able to get pulse widths down towards 2usec but using a technique that isn't (best I am able to determine) available on non supported boards.
Read over my thread using the PPI Programmable Peripheral Interconnect that should give you some ideas on the methods used in creating pulses, timing and detection. It wont answer all your questions, but should get you on track.see also
http://www.espruino.com/InlineC
http://www.espruino.com/Assembler
Be prepared to put in some time reading, coding and experimenting, as some concepts take a bit of getting used to, especially if you are mostly involved in the Arduino environment.
Maybe in this case PWM will be the solution.
analogWrite(PIN, value, { freq : my_freq_in_hz } )