Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years ago.
How to use the analog comparators of this processor on Mbed?
I see in that PeripheralPins.c has no reference to analog comparators. I am testing an application with a reflective sensor where I need to generate an interrupt routine when the sensor detects the passage by a different color strip on a mechanism. I am using the QRD1114 sensor and its output voltage depends on the reflectance of the object. Has someone a suggestion how to use the comparator peripheral on Mbed environment?
Question relating to:
3 Answers
7 years ago.
I think you could do something like this:
#include "mbed.h" // Initialize a pins to perform analog input and digital output functions AnalogIn ain(A0); void do_something(); int main(void) { while (1) { // test the voltage on the initialized analog pin // and if greater than 0.3 * VCC set the digital pin // to a logic 1 otherwise a logic 0 if(ain > 0.3f) { do_something(); } } }
Here is the reference for AnalogIn API - https://os.mbed.com/docs/v5.6/reference/analogin.html
Thank you Sarah, but, this is ADC and has no interrupt associated.
Some ARM microcontrollers, like de STM32 L432KC, has the comparator peripheral that has an associated interrupt line and takes much less processing time and consumes much less energy than an ADC operation. I saw in the MBED files of board I am using that already exists a HAL file for the comparator peripheral, but I did'nt see anywhere nothing about this peripheral on MBED platform.
Best regards.
posted by 06 Nov 20176 years, 10 months ago.
Hi!
I'm trying to use the HAL for the COMP of my STM32 NUCLEO-L432KC with med.
Which version of HAL does mbed use? I've found two descriptions: "Description of STM32L4/L4+ HAL and low-layer drivers" (UM1884)
The Revision 5 has a HAL COMP Generic Driver (page 152ff) The newer Revision 7 doesn't have a HAL COMP Generic Driver - only a LL-Version
So how to use the COMP HAL functions to activate the comparator within mbed?
I couldn't find any examples. Only those from STM32Cube_FW_L4
Any hints?
6 years, 10 months ago.
Hi
We recently put the STM32L4xx HAL V1.8.2 in mbed-os. The stm32l4xx_hal_comp.c/h and stm32l4xx_ll_comp.c/h files are both present and you can use them.
There is no COMP examples on mbed, you have to see those in the STM32CubeL4 package.
If you have questions/issues using the COMP API, please ask them on STM32 forum: https://community.st.com/community/stm32-community/stm32-forum
Thanks