cancel
Showing results for 
Search instead for 
Did you mean: 

Strange GPIOA output states

parisa
Senior
Posted on December 26, 2016 at 18:26

Hello,

Here is my code for set and reset PA.3 for stm32f10x

#include <stdio.h>

#include <string.h>

#include 'stm32f10x_gpio.h'

#include 'stm32f10x_rcc.h'

#include 'stm32f10x_tim.h'

void delay(void){

                int i,j;

        for(i=0;i<10000;i++)

        for(j=0;j<250;j++);

}

int main(void){

                GPIO_InitTypeDef GPStructure;

                RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);

                GPStructure.GPIO_Mode=GPIO_Mode_Out_PP;

                GPStructure.GPIO_Pin=GPIO_Pin_3;

                GPStructure.GPIO_Speed=GPIO_Speed_50MHz;

                GPIO_Init(GPIOA,&GPStructure);

while(1){

GPIO_SetBits(GPIOA,GPIO_Pin_3);

delay();delay();delay();delay();delay();delay();

GPIO_ResetBits(GPIOA,GPIO_Pin_3);

delay();delay();

}

}

Well, I expect to get output voltage greater than 2.82 for high output voltage level and 0 for low voltage level but I get 1.3 for high output voltage level in set states! However it works fine for other ports (PB , ...)

In addition, I  test it for PA.15 but I get only 3.2 volt for set and reset!!!

what is my mistake?

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on December 26, 2016 at 20:09

Any details about the board you are testing this on?

The most likely reason would be that the pin is connected to something else which is driving the pin low, and in the PA15 case could it be used by the debugger interface?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3
Posted on December 26, 2016 at 20:09

Any details about the board you are testing this on?

The most likely reason would be that the pin is connected to something else which is driving the pin low, and in the PA15 case could it be used by the debugger interface?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on December 26, 2016 at 21:14

Thanks dear Clive on , your are right.Another electrical component was driving the pin low.However the PA.15 is free and I don't use it. Should I deactivate a certain register?

Posted on December 27, 2016 at 01:40

For the debug pins, you'd need remap the SWD/JTAG functionality off them. The Standard Peripheral Library v3.5.0 has a JTAG/GPIO example

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..