uart pic18
This should be close enough for normal communication I would think. But if you really need it closer, here are the best figures for 115200 baud for standard value crystals:
18.432 MHz gives an error of 0.000000% with reload value of 9
24.000 MHz gives an error of 0.16% with reload value of 12
33.330 MHz gives an error of 0.46% with reload value of 17
38.880 MHz gives an error of 0.45% with reload value of 20
If you really want 0% error close to 40MHz, the closest I can get is 38.707200 MHz which gives an error of 0.0000% with reload value of 20. This is not a standard value of course, just to keep life interesting. Maybe you could persuade the 38.880 crystal to pull that far?
Or, you could ask these nice pwople to custom make one for you:
https://www.icmfg.com/buildcrystal.html
Of course, if you really need this level of accuracy the instrument must be kept in a controlled temperature oven as the crystal's frequency will alter too much with temperature variations (and ageing, and external vibrations, and capacitor ageing, and out of pure contrariness)
Good luck,
FoxyRick.