Hello 王 腾博,
Yes, at the concrete moment you can use only one function but in program process you can functions change. For example, for a while measure ADC and after that you can use it as GPIO or I2C - it depends on concrete pins.
Best Regards,
Iva
Frist of all, thanks for your answer. But i konw it that you say, i just want konw why the ADC can measure the right value when i don't configuration the MUX with any value or configuration it with any value.
Hello 王腾博,
I apologize for my late response, I was out of my office.
It depends, what you need.
For example, if you go to K60 Sub-Family Reference Manual chapter 10,
Signal Multiplexing and Signal Descriptions and you see Pinout, there is information about default state, so you can use pin as ADC without configuration because default state is ADC.
ADC measures values which can be close real value also without calibration.
So, yes you can measure ADC without configuration.
Best Regards,
Iva
Hello Iva Dorazinova
Thank you for your reply even you are so busy in you office.
you say it about ADC defult,i konw if when i fristly propose the question.
But now, my problem is the ADC can normally running even if it configuration any pin functions,like SPI,UART,I2C.
i am so confused about the problem.
Best Regards,
wang
Hello 王 腾博,
I was wondering if you got the correct value from the ADC module, while configure the PTE20 work in other function likes UART or TPM.
Actual, it's necessary to configure the corresponding function for the pin before to implement.
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Ping
Thank you for your answers,i have configure the right value for Pin Mux Control when i use the ADC module.Howwer,the result for test is the ADC can measure the right value from PTE20 before i configure Mux Control for 0,1,3 or 4.
Best Regards,
wang
Hello 王 腾博
It sounds like very weird,
I'd highly recommend that you can share the demo, then I'll run the demo on FRDM-KL26Z board.
I'm looking forward to your sharing.
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello 王 腾博
我简单讲述一下我的测试过程:
你的分享工程有error,所以我自己做了一个测试工程。
测试结果如下:
确实这如你所说,当PTE20工作于GPIO 或者TPM功能时,确实也可采样当时当下引脚上的电压值。
谢谢你的分享。
/*
* File: adc_test.c
* Purpose: Main process
*
*/
#include "common.h"
#ifdef CMSIS
#include "start.h"
#endif
void adc_init (void)
{
SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK;
PORTE_PCR20 |= PORT_PCR_MUX(1);
GPIOE_PDDR |= (1<<20);
GPIOE_PSOR |=(1<<20);
SIM_SCGC6 |= SIM_SCGC6_ADC0_MASK;
ADC0_CFG1 = ADC_CFG1_ADLSMP_MASK | ADC_CFG1_MODE(2) | ADC_CFG1_ADICLK(1)| ADC_CFG1_ADIV(2);
ADC0_SC2 = 0;
ADC0_SC3 |= ADC_SC3_ADCO_MASK |ADC_SC3_AVGE_MASK |ADC_SC3_AVGS(1) ;
ADC0_SC1A &= ~(ADC_SC1_DIFF_MASK);
ADC0_SC1A &=~(ADC_SC1_AIEN_MASK);
}
int adc_read(char channel)
{
int ADCResutl=0;
ADC0_SC1A = ADC_SC1_ADCH(channel);
while (!(ADC0_SC1A & ADC_SC1_COCO_MASK));
ADCResutl =(int )ADC0_RA;
ADC0_SC1A &= ~ADC_SC1_COCO_MASK;
return ADCResutl;
}
/********************************************************************/
int main (void)
{
int RA;
#ifdef CMSIS // If we are conforming to CMSIS, we need to call start here
start();
#endif
printf("\n\rRunning the adc_test project.\n\r");
adc_init();
while(1)
{
// out_char(ch);
RA=adc_read(0);
printf("Vout=%d\n",RA);
}
}
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello 王 腾博
YL-KL26Z自带例程中的SD例程是有错误的,建议通过此链接下载修正后的工程的。
【YL-KL26Z试用】+SPI SD驱动搞好了。。发帖庆贺一下、。。 - 飞思卡尔FAE线上技术支持 - 飞思卡尔技术社区 - 手机版 - Powered by Discuz!
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------