Page 1 of 1

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

Posted: Thu Jan 23, 2025 2:52 pm
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

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

Posted: Thu Jan 23, 2025 3:31 pm
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

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

Posted: Thu Jan 23, 2025 3:48 pm
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.

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

Posted: Fri Jan 24, 2025 4:50 am
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.