lpcware

LPC800 LPCOpen - bug in acmp_8xx.c Ladder Voltage Setup

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by brownm on Sat Oct 26 22:28:34 MST 2013
Hi there

There is a bug in the LPCOpen driver for setting the Ladder Point.

The Ladder select is from bit 5:1 in the register but the original code is OR'ing the ladsel value at bit 0, It needs to move it one place to the left before the OR'ing occurs.


/* 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;
}





Regards

Marshall Brown

Outcomes