in principle the code looks ok, but you don’t need the bpmCC variable. It’s even not required to convert this value into a different number format, because hexadecimal and decimal are just different forms to display/input values, but both will be translated into binary numbers by the compiler/assembler.
One thing which should be considered is, that you have to take care for underruns. The clockbox provides BPM rates from 48 to 255. this means, as soon as the BPM are less than 80, you will get a negative result. For an “unsigned char” this means, that the result will be >=128 (since there is no sign), and such a value should not be sent as 3rd byte of a CC, since it violates the MIDI protocol (only values between 0 and 127 are allowed).
So, you could add an if condition which ensure that values <80 and >(80+128) are not sent
Yes, the MCLOCK_BPMSet() function is the right one, because it’s always called when the BPM rate is initialized or modified.
With “bpmCC = (unsigned char)value” you are trying to access a variable (name: “value”) which doesn’t exist. But without loosing too much words: it’s really not required.
Just write MIOS_MIDI_TxBufferPut(bpm - 80) instead of MIOS_MIDI_TxBufferPut((unsigned char)value);