Deuterated molecules are good tracers of the evolutionary stage of star-forming cores. During the star formation process, deuterated molecules are expected to be enhanced in cold, dense pre-stellar cores and to deplete after protostellar birth. In this paper we study the deuteration fraction of formaldehyde in high-mass star-forming cores at different evolutionary stages to investigate whether the deuteration fraction of formaldehyde can be used as an evolutionary tracer. Using the APEX SEPIA Band 5 receiver, we extended our pilot study of the $J$=3$rightarrow$2 rotational lines of HDCO and D$_2$CO to eleven high-mass star-forming regions that host objects at different evolutionary stages. High-resolution follow-up observations of eight objects in ALMA Band 6 were performed to reveal the size of the H$_2$CO emission and to give an estimate of the deuteration fractions HDCO/H$_2$CO and D$_2$CO/HDCO at scales of $sim$6 (0.04-0.15 pc at the distance of our targets). Our observations show that singly- and doubly deuterated H$_2$CO are detected toward high-mass protostellar objects (HMPOs) and ultracompact HII regions (UCHII regions), the deuteration fraction of H$_2$CO is also found to decrease by an order of magnitude from the earlier HMPO phases to the latest evolutionary stage (UCHII), from $sim$0.13 to $sim$0.01. We have not detected HDCO and D$_2$CO emission from the youngest sources (high-mass starless cores, HMSCs). Our extended study supports the results of the previous pilot study: the deuteration fraction of formaldehyde decreases with evolutionary stage, but higher sensitivity observations are needed to provide more stringent constraints on the D/H ratio during the HMSC phase. The calculated upper limits for the HMSC sources are high, so the trend between HMSC and HMPO phases cannot be constrained.