The changes in the optical and electrical properties of thick a-Si:H and a-SiC:H films doped with diborane are investigated. In situ spectroscopic ellipsometry measurements reveal that, at a ratio of diborane to silane Cg=[B2H6]/[SiH4]<10−3, the optical properties of both materials are not strongly modified by boron doping. However, in the case of a-Si:H films, an improvement of the morphological and optical properties is observed at Cg=0.45×10−3. The existence of an optimum doping level at Cg<10−3 in the case of an a-Si:H p layer is confirmed by the dependence of the open-circuit voltage of a-Si:H based solar cells on the doping level of the p layer.