A possible defect of Chip_ADC_SetClockRate()

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

A possible defect of Chip_ADC_SetClockRate()

2,087 次查看
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

标签 (2)
标记 (1)
0 项奖励
回复
3 回复数

1,981 次查看
jeremyhsiao
Contributor II

Hi Alice,

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

BR

Jeremy

0 项奖励
回复

1,981 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

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

BR

Alice

0 项奖励
回复

1,981 次查看
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 项奖励
回复