Compilation error: base operand of '->' is not a pointer

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
Blank
Posts: 3
Joined: Thu Jan 23, 2025 8:52 am

Compilation error: base operand of '->' is not a pointer

Post by Blank »

Hi guys, I am using an STM 32 F401CEU6 Black Pill Board, in this I am trying to build a program that triggers an interrupt when it detects a state change on pin PB10 of the STM.

BELOW IS MY CODE

===============================================================================================================================

uint32_t now, receiver_input1, receiver_input1_previous;

void setup() {
Serial.begin(57600);
attachInterrupt(PB10, ch1, CHANGE);
// put your setup code here, to run once:

}

void loop() {
delayMicroseconds(3500);
Serial.println(receiver_input1); // put your main code here, to run repeatedly:

}

void ch1(){
now = micros();
if(0B1 & GPIOB_BASE->IDR >> 10 )receiver_input1_previous = now;
else receiver_input1 = now - receiver_input1_previous;
}

===============================================================================================================================
I am getting a compilation error on if(0B1 & GPIOB_BASE->IDR >> 10 ), where it is saying base operand of '->' is not a pointer.

I hope someone can help.

Thanks
Attachments
Attachement of error
Attachement of error
Screenshot 2025-01-23 202050.jpg (53.29 KiB) Viewed 137 times
by ag123 » Thu Jan 23, 2025 3:48 pm
if you don't need too much speeds, well you could do codes like

Code: Select all


uint8_t state = 0;

void setup() {
	pinMode(PA1, INPUT);
	Serial.begin();
}

void loop() {

	if (digitalRead(PA1) != state) 
		Serial.println("state changed");
	state = digitalRead(PA1);
	delay(100);
}
and you can replace that PA1 with any pin you prefer to use.

--
OT: please post in the correct section in the forum, this section is for stm8, it could have been ignored.
Go to full post
GonzoG
Posts: 481
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: Compilation error: base operand of '->' is not a pointer

Post by GonzoG »

1. this is a subforum for STM8

2. GPIOB_BASE is not a pointer. It's a address value, that's why you get this error.
GPIOx are pointers to each GPIO registers.
eg: GPIOA->IDR
ag123
Posts: 1881
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: Compilation error: base operand of '->' is not a pointer

Post by ag123 »

if you don't need too much speeds, well you could do codes like

Code: Select all


uint8_t state = 0;

void setup() {
	pinMode(PA1, INPUT);
	Serial.begin();
}

void loop() {

	if (digitalRead(PA1) != state) 
		Serial.println("state changed");
	state = digitalRead(PA1);
	delay(100);
}
and you can replace that PA1 with any pin you prefer to use.

--
OT: please post in the correct section in the forum, this section is for stm8, it could have been ignored.
Blank
Posts: 3
Joined: Thu Jan 23, 2025 8:52 am

Re: Compilation error: base operand of '->' is not a pointer

Post by Blank »

Yes it works, thank you so much.

I am new to STM32s and this forum I will take care not to post in wrong forum.
Post Reply

Return to “General discussion”