Pulse counter (external signal) with a STM32F769I-DISCO board

Post here first, or if you can't find a relevant section!
Post Reply
donwynne
Posts: 1
Joined: Fri Mar 18, 2022 3:13 am

Pulse counter (external signal) with a STM32F769I-DISCO board

Post by donwynne »

Hello everyone! I have to connect an inductive sensor to my STM32F769I-DISCO in order to count rising edges of an external signal. So, especially if you have already done that, I would need some advice about the inputs of my microcontroller I may use to carry out the connection with the inductive sensor.
By the way, to count rising edges, I am wondering which functions I could use. Otherwise, do you know a specific method for doing that?
I truly thank you in advance for your help (I'm still a newcomer in that field to be honest).
Sincerely,
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: Pulse counter (external signal) with a STM32F769I-DISCO board

Post by GonzoG »

Just use interrupt.
eg:

Code: Select all

volatile uint32_t impulseCount=0;

void ISR(){
  impulseCount++;
}

void setup() {
  // put your setup code here, to run once:
  pinMode(<pin>,INPUT);
  attachInterrupt(<pin>,ISR,RISING);
}
Depending on your circuit and sensor, you might need to use pull down or pull up resistor on input pin.
nektariosb
Posts: 3
Joined: Thu Mar 24, 2022 7:15 pm
Location: Greece

Re: Pulse counter (external signal) with a STM32F769I-DISCO board

Post by nektariosb »

@GonzoG which pins can I use for external interrupt?
Thank you!
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: Pulse counter (external signal) with a STM32F769I-DISCO board

Post by GonzoG »

I think that STM32s can use any pin as an external interrupt.
Post Reply

Return to “General discussion”