Suggest why calcium compound produce a coloured flame but magnesium do not?

12Mg is 1s2 2s2 2p6 2s2

20Ca is 1s2 2s2 2p6 3s2 3p6 3d0 4s2

The electrons in the 4s level for Ca are further removed from the nucleus than the outer electrons in the Mg atom and it takes less energy to move them to a higher level. As a result, the energy emitted when the electrons from the Ca excited atom return to the ground state is less and more likely to be in the visible part of the spectrum. Mg electrons undergo the same kind of electron transition(s) but the the energy is more and falls in the ultra violet part of the spectrum and not in the visible part of the spectrum.