Hi, I am finding abnormal functioning of GPIO output while Toggling.I am getting Pulse of 0.2138s width everytime before my Desired Output(35microseconds) in STM32F401 Nucleo-64.
Please Support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-20 10:35 AM
#include<NEW.h>
void delay();
void main()
{
SystemInit();
RCC->AHB1ENR |=1; /* Enabling clock for GPIOA port*/
GPIOA->MODER |=1<<24;/*General Purpose output function in PA12 Port*/
GPIOA->OSPEEDR|=1<<24;/*Medium speed */
GPIOA->ODR |=(1<<12);/* Turning ON PA12pin */
delay();/* 35 microseconds ON*/
GPIOA->ODR &=~(1<<12);/* Turning OFF PA12 pin */
while(1);
}
void delay()
{
RCC->APB1ENR |=1<<0; /* TIM2 clock enabled*/
TIM2->CNT=0;
TIM2->ARR=500;
TIM2->PSC=1;
TIM2->CR1 |=1;
while((!TIM2->SR & 1<<0));
TIM2->SR=0;
}
- Labels:
-
GPIO-EXTI
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-20 3:43 PM
Pulled-up the otherwise floating pin? Maybe your LA pulls it up?
Do you use the embedded bootloader?
Try some other pin. Try a 1kOhm pulldown.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-21 7:59 AM
Problem Solved after Connecting 1 Kohm Pull Down Resistor .
But output Pin is selected as Push-Pull(reset state) in GPIO_OTYPER by default. Why Pin is Floating i don't Understand.
Thank you for ur Extended Support .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-21 8:59 AM
After reset, almost all pins including PA12 are set as Input in GPIO_MODER.
GPIO_OTYPER setting is pertinent only when the pin is turned to output, i.e. either set as Output in GPIO_MODER; or set as AF in GPIO_MODER and the controlling peripheral selected by GPIO_AFR set it as output (for example as when timer channel is set to Output Compare).
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-21 11:50 AM
while((!TIM2->SR & 1<<0));
And additionally this code is broken because of operator precedence and should be fixed by putting the correct braces. Currently it works only by coincidence and while only the UIF bit is used. And use the CMSIS defined names for bit-fields!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-23 10:07 AM
Thank you Piranha
