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
Compilation error: base operand of '->' is not a pointer
Compilation error: base operand of '->' is not a pointer
- Attachments
-
- Attachement of error
- Screenshot 2025-01-23 202050.jpg (53.29 KiB) Viewed 137 times
if you don't need too much speeds, well you could do codes like
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 postCode: 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);
}
--
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
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
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
if you don't need too much speeds, well you could do codes like
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.
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);
}
--
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
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.
I am new to STM32s and this forum I will take care not to post in wrong forum.