The effects of hydrogen dilution, subtle boron compensation, and light-soaking on the gap states of hydrogenated amorphous silicon films (a-Si:H) near and above the threshold of microcrystallinity have been investigated in detail by the constant photocurrent method and the improved phase-shift analysis of modulated photocurrent technique. It is shown that high hydrogen dilution near the threshold of microcrystallinity leads to a more ordered network structure and to the redistribution of gap states; it gives rise to a small peak at about 0.55 eV and a shoulder at about 1.2 eV below the conduction band edge, which are associated with the formation of microcrystallites embedded in the amorphous silicon host matrix. A concurrent subtle boron compensation is demonstrated to prevent excessive formation of microcrystallinity, and to help promote the growth of the ordered regions and reduce the density of gap defect states, particularly those associated with microcrystallites. Hydrogen-diluted and appropriately boron-compensated a-Si:H films deposited near the threshold of microcrystallinity show the lowest density of the defects in both the annealed and light-soaked states, and hence, the highest performance and stability. © 2001 American Institute of Physics.