/* Sets up voltage ladder */
void Chip_ACMP_SetupVoltLadder(LPC_CMP_T *pACMP, uint32_t ladsel, bool ladrefVDDCMP)
{
uint32_t reg = pACMP->LAD & ~(ACMP_LADSEL_MASK | ACMP_LADREF_MASK);
//mkb added this line as the LAD sel is from 5:1 in the register so we need to shift the
//ladsel value << 1
ladsel = ladsel << 1; //<-------------FIX THE BIT SHIFT.
/* Setup voltage ladder and ladder reference */
if (ladrefVDDCMP) {
reg |= ACMP_LADREF_MASK;
}
pACMP->LAD = reg | ladsel;
}
|