I'm experimenting with audio pwm output using the source code provided by krom (PeterLemon) as the base for a port to C, it is working very well, however I can't understand the relationship between the pwm clock, range and data. For example I see that 12, 13 and 14 bit 44100/mono output are all using the same clock divisor $2000 and the same range value $2C48 which doesn't seems right to me. The 8 bit audio example uses a different range $1B4 so I was expecting that also 12, 13 and 14 bit uses different ranges. Reading the BCM2835 ARM Peripherals documentation isn't of much help because the values looks wrong to me (also the clock source looks wrong, the code says it uses PLLC but the instruction has CM_SRC_PLLCPER + CM_SRC_OSCILLATOR = $05 + $01 = $06 PLLD), but indeed it is working right so I must be missing something.
Can someone explain me that relationship ? What I would like to do is parametrize the code so the user can choose the audio parameters (sample rate, width, mono/stereo) and the code do the calculations needed to set the correct clock and range parameters.