Met

tweaker

Apr 11, 2012
8
Joined
Apr 11, 2012
Messages
8
Okay so I have been working on a digital metronome project using the Pic16f877a. Its nearly complete.

I am looking for some help with the timing. I have had success using a lookup table for each BPM but I'm looking for something a little less bulky. The time between clicks is as follows:
60/BPM
And the cycles I need using a 4MHz crystal:
(60/BPM)/1us

I'm trying to get a variable delay depending on the BPM but I'm having some trouble finding the right method and I have tried many.

Any suggestions would be greatly appreciated!
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Write a 1ms delay (1000 instructions) then call it 60000 / BPM times for each beat.

For example, at 60 BPM you would call it 1000 times to get a 1 second delay.

Bob
 
Top