Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4895

SDK • Getting unexpected pulse lengths from my program - hoping someone could cast a quick eye over my code

$
0
0
Hello,

I'm fairly new to programming microcontrollers - the pico is my first. I'm trying to bulid a simple music sequencer as my first application. At the moment, the program is extremely barebones as I'm trying to verify the functionality, and understand, each step before moving on to the next. I've got as far as the second step before running into confusion! I am receiving a steady 3.3V clock at a gpio input, and in response to each clock pulse I am turning on an LED for 50% of the time between the previous clock pulse, and this clock pulse. I have confirmed the input circuitry is working as intended and the clock pulse is being received. The problem is that the output pin for the LED is, occasionally, only high for a very short period, i.e. the LED blinks rather than remaining on for the desired time period. I've tried printf debugging and so on, but adding debugging actually solves this problem; as long as the sleep on line 97 is uncommented, the program works as intended and the LED pin is high for the desired time period after every pulse (or at least I'm yet to see a blink). I imagine this has something to do with the interrupt for the clock receive pin occurring at an inopportune moment, but I'm not experienced enough to know, or understand how to best mitigate this issue. I would be extremely grateful if someone could cast a quick eye over my code - it's a very short single file! code here: https://github.com/blex-max/fill-seq-p ... fill-seq.c

Thanks :)

Statistics: Posted by blexmax — Mon Mar 25, 2024 12:43 am



Viewing all articles
Browse latest Browse all 4895

Trending Articles