I struggle with stm32f030r8 arm programming on atollic true studio ide.
I have some problem with reading correct data from idr register.
I make pull down PUPR register of GPIOB(0,1,2,3).
Other pins of GPIOB is output that i make with MODER register.
when i read idr data under loop every time i read F value but there is not any input.
Please help me to solve this problem [
#include "main.h"
int main(void)
{
volatile static uint16_t PortDataInput=0x00;
RCC->CR|=(uint32_t)0xF1; //set hsi clock source and with max speed
GPIOB->PUPDR|=0xAA; //set firt 4 bit of gpiob as pull down
GPIOB_RCC->AHBENR|=(1<<18); //enable gpiob clock source
GPIOB->MODER|=0x55555500; //set firt 4 bit of gpiob as input
GPIOB->OTYPER|=0x00000000; //set output pins of gpiob as push pull
while (1)
{
PortDataInput=GPIOB->IDR;
PortDataInput&=0xF;
}
You try to set the gpio register before enabling peripheral clock. So you can't write to any of its registers.
I found the solution. Solution is that.I had to set all gpio registers after enabling peripheral clock.
#include "main.h"
int main(void)
{
volatile static uint16_t PortDataInput=0x00;
RCC->CR|=(uint32_t)0xF1; //set hsi clock source and with max speed
GPIOB_RCC->AHBENR|=(1<<18); //enable gpiob clock source
GPIOB->PUPDR|=0xAA; //set firt 4 bit of gpiob as pull down
GPIOB->MODER|=0x55555500; //set firt 4 bit of gpiob as input
GPIOB->OTYPER|=0x00000000; //set output pins of gpiob as push pull
while(1)
{
PortDataInput=GPIOB->IDR;
PortDataInput&=0xF;
}
User contributions licensed under CC BY-SA 3.0