Hi,
if it works at low speed, there's not much to check in the code.
There are several points to consider:
- what is the slave device? Is that capable to communicate at such speed?
- communication frequency can be limited by bus capacitance. Did you try to check the signals by oscilloscope? How was the distortion? What is the length of wires? It should be as short as possible or the frequency should be decreased appropriately
- from SW point of view, you can play with settings in Configuration Register 1 CFGR1 (Sample point) and
Clock Configuration Register CCR to see if it makes a difference.
Regards,
Lukas