如题,题主使用的是yl-kl26,例程里的adc输入试过了,代码如下:
void adcInit (void)
{
SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK; /* ¿ªÆôPE GPIOʱÖÓ */
PORTE_PCR20 = PORT_PCR_MUX(0); /* ¿ªÆôPE20¹Ü½ÅÄ£Ä⹦ÄÜ */
SIM_SCGC6 |= SIM_SCGC6_ADC0_MASK; /* ¿ªÆôADCʱÖÓ */
/*
* ÅäÖÃADCÏà¹Ø¹¦ÄÜ
*/
ADC0_CFG1 = ADC_CFG1_ADLSMP_MASK | ADC_CFG1_MODE(3) | ADC_CFG1_ADICLK(0);
ADC0_SC2 |= ADC_SC2_REFSEL(1); /* Ñ¡ÔñµçÔ´²Î¿¼Ô´ */
}
/*********************************************************************************************************
** Function name: adcGetUint
** Descriptions: adc¶ÁÈ¡
** input parameters: none
** output parameters: adcÊýÖµ
** Returned value: none
** Created by: JiaoLong Liu
** Created date: 2012-12-12
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
*********************************************************************************************************/
INT16U adcGetUint (void)
{
// ADC0_SC1(0) = ADC_SC1_ADCH(0); /* Ñ¡ÔñADCÐŵÀ */
// while ((ADC0_SC1(0) & ADC_SC1_COCO_MASK) != ADC_SC1_COCO_MASK); /* µÈ´ýת»»Íê³É */
// return ADC0_R(0); /* Êä³ö½á¹û */
//
ADC0_SC1(0) = ADC_SC1_ADCH(0); /* Ñ¡ÔñADCÐŵÀ */
while ((ADC0_SC1(0) & ADC_SC1_COCO_MASK) != ADC_SC1_COCO_MASK); /* µÈ´ýת»»Íê³É */
return ADC0_R(0); /* Êä³ö½á¹û */
}
现在想把adc输入的引脚从E20改为E22,除了E20引脚初始化改成E22以外还应该怎么做? |