Hi, I have written this code.Stm32F107
#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(); } }
I expect output voltage greater than 2.82 for output voltage level and 0 for low level but I get 1.3 for high output voltage level!!!!! However it works fine for other ports (PB , ...)
Strange output voltages normally happens for two reasons: 1) The output pin is in tristate mode (i.e. working as input without any internal weak pull-up/pull-down). Easy to spot since a very large resistor to VCC or GND will make the pin float all the way to VCC or GND. A similar thing happens if the pin is in open-collector mode, but in this case the pin can draw hard to ground but can't lift the signal without external pull-up help.
2) The output pin is fighting with another output pin. One pin trying to draw the signal high, while the other pin trying to draw the signal low.
Another thing - your code is easier to read if you indent with spaces and places the code between <pre> and </pre> tags.
Thanks for your contribution,I have tested different modes but they didn't fix this problem.In addition I have changed code for toggle PA.15 but it give me ony 3.2 volt! Have I forgotten anything?
"... but it give me only 3.2 volt!"
Well, if you were expecting greater than 2.82 and you got 3.2 - what is the problem?!
You never get full rail-to-rail voltage swings.
3.2V would be a good voltage if assuming you have around 3.3V VCC.