AnsweredAssumed Answered

Vref interfering with GPIO PTB2 on KL03

Question asked by CARLOS OTERO on Aug 12, 2015
Latest reply on Aug 13, 2015 by jeremyzhou

Hello,

 

I would like to ask for your kind help with some problem involving Vref and GPIO.

 

I use the Vref voltage internally with a low-power buffer. At the same time, I use GPIO, in particular PTB2. However I see some interference on PTB2 presumably caused by Vref. To test my point, I did a sample program listed below.

 

I ran this program on my Freedom KL03. I removed R17 that connects PTB2 to the UART of the programming interface.

 

    configure_gpio();

    init_vref();

    enable=0;

 

    while(1) {

      PTB -> PTOR|=0x1<<10; //LED

 

      if(enable) {

        PORT_HAL_SetMuxMode(PORTB_BASE_PTR, 2u,kPortMuxAsGpio);

        GPIO_HAL_SetPinDir(GPIOB_BASE_PTR, 2U, kGpioDigitalOutput);

        GPIOB->PCOR = 0x1 <<2u;

      } else {

        PORT_HAL_SetMuxMode(PORTB_BASE_PTR, 2u,kPortPinDisabled);

      }

      enable ^= 1u;

 

      for(j=0;j<1;j++) { //delay

       for (i=0;i<150000u;i++) { }

      }

    }

 

 

 

If I hook the oscilloscope to PTB2, I see an oscillation between 1.2V and 0.4V, which is not what I expect, I would have expected to see an oscillation between 1.2V and 0V. I also used breakpoints to test my point.

 

Have any of you experienced that problem? any suggestions?

 

Thank you!

Outcomes