Code to Calculate the Calibrate the ADC Using An External Reference

Hello,
I need to increase the accuracy of the ADC for an E-Series board. I was thinking about using an LM4040 to drive an analog pin to use as a reference.

Is there an easy way to calibrate ADC using external reference? Or should I write some code to determine the offset before each read?
Something like:
Voltage_Reference(For LM4040 its 2.048v)/3.3(ADC Max Voltage)= 2,542 (the Pre-Calibrated ADC Value)

2,542 +(AnalogRead(A0) = ADC Offset
AnalogRead(A1) + ADC Offset = True Reading

Where A0 is the pin the LM4040 output is on and A1 is the pin I want to get a true reading. This basically just determines the error of the ADC and then sums it with the reading from the ADC.

A good place to start is ST AN2834. There are a number of sources of error in the STM32 ADC, and this note covers them in great detail.