We propose to model the spectral response of p-n junction photodetectors ba
sed on gallium nitride and related AlGaN alloys. The model is based on the
resolution of the differential equations that govern the excess carrier var
iation in each layer of the photodiode taking into account all the physical
parameters, in particular the presence of deep trap levels in the forbidde
n gap. We notice that the theoretical results are in good agreement with th
e experiments. We have also analysed the effect of the recombination veloci
ty at the illuminated surface, as well as the impact of the thickness and t
he doping density of the p-type layer (illuminated zone) on the spectral re
sponse magnitude.