请问在KL26Z中使用外围模块是否一定要将相应的引脚设置为外设功能?

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

请问在KL26Z中使用外围模块是否一定要将相应的引脚设置为外设功能?

1,275 Views
王腾博
Contributor I

在使用KL26Z的ADC模块时,将PTE20的功能设置为随便一个(0-7)功能,都可以实现ADC采样,都可以得到结果。

Labels (1)
Tags (2)
0 Kudos
Reply
11 Replies

1,070 Views
ivadorazinova
NXP Employee
NXP Employee

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

0 Kudos
Reply

1,070 Views
王腾博
Contributor I

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.

0 Kudos
Reply

1,070 Views
ivadorazinova
NXP Employee
NXP Employee

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.png

ADC measures values which can be close real value also without calibration.

So, yes you can measure ADC without configuration.

Best Regards,

Iva

0 Kudos
Reply

1,070 Views
王腾博
Contributor I

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

0 Kudos
Reply

1,070 Views
jeremyzhou
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,070 Views
王腾博
Contributor I

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

0 Kudos
Reply

1,070 Views
jeremyzhou
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,070 Views
王腾博
Contributor I

Hello Ping

i really appreciate it you can help me to run the demo.so,there is the demo in the bottom.

i am sorry to delay you time to do this for me.

anyway,thank you.

best wishes.

wang

0 Kudos
Reply

1,070 Views
jeremyzhou
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,070 Views
王腾博
Contributor I

Hello Ping

如果你是用YL-KL26Z的板子,可以帮忙测试一下那个SD卡的例程吗?

要是调试成功,请发给我一份,谢谢了!

best wishes.

wang

0 Kudos
Reply

1,070 Views
jeremyzhou
NXP Employee
NXP Employee

Hello

【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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply