A possible defect of Chip_ADC_SetClockRate()

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

A possible defect of Chip_ADC_SetClockRate()

729 Views
jeremyhsiao
Contributor II

Hi,

I'm writing to report possible defect of Chip_ADC_SetClockRate() in the LPCOpen 3.03. The content of this function is as below:

    Chip_ADC_SetDivider(pADC, ((Chip_Clock_GetSystemClockRate() + (rate>>2)) / rate) -1);

It could mistakenly set up the wrong divider to 0xff when the result of ((Chip_Clock_GetSystemClockRate() + (rate>>2)) / rate) is zero.

In case internal XTAL is used (clock-rate is 12MHz) instead of external clock-rate, the adc demo-code of Init_ADC() will call Chip_ADC_SetClockRate(LPC_ADC, ADC_MAX_CLOCK_RATE), in which ADC_MAX_CLOCK_RATE is 50MHz. This will make result of "((Chip_Clock_GetSystemClockRate() + (rate>>2)) / rate)" as 0. Thus after minus 1 the Divider will be set to 0xff.

It is recommended that some protection or warning is added within Chip_ADC_SetClockRate().

Jeremy

Labels (2)
Tags (1)
0 Kudos
3 Replies

623 Views
jeremyhsiao
Contributor II

Hi Alice,

I'm using LPC11U66JBD48 and working on my own board without using external XTAL.

BR

Jeremy

0 Kudos

623 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

OK, thanks for your recommendation, I have reported it to development team.

BR

Alice

0 Kudos

623 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Jeremy,

Thanks for your sharing, could you please tell me the device you are using, I will check it .

BR

Alice

0 Kudos