You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Daniel Pereira Carvalho <da...@gmail.com> on 2021/06/15 14:50:57 UTC

STM32G4 analog camparators

Hi,

I'm trying to use the analog comparators of the nucleo-g431kb board.  As a
reference I'm using the implementation and pin definition of the
nucleo-f334r8 board. Looking at RM0364 Reference manual section *15.3.2
COMP pins and internal signals* there is the following

*"The I/Os used as comparators inputs must be configured in analog mode in
the GPIOs registers."*

But looking at file arch/arm/src/stm32/hardware/stm32f33xxx_pinmap.h the
comparator inputs are defined as Alternate Functions

/* Comparator Inputs non inverting */

#define GPIO_COMP2_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN7)
#define GPIO_COMP4_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN0)
#define GPIO_COMP6_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN11)

/* Comparator Inputs inverting */

#define GPIO_COMP2_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN2)
#define GPIO_COMP2_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
#define GPIO_COMP4_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN2)
#define GPIO_COMP4_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
#define GPIO_COMP6_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
#define GPIO_COMP6_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN15)

From the STM32F334x8 datasheet, Table 14  Alternate functions, there are no
corresponding definitions to configure comparator inputs on AF8.

These definitions correct? Or I am understanding something wrong.

Thanks

Daniel Pereira de Carvalho

Re: STM32G4 analog camparators

Posted by Daniel Pereira Carvalho <da...@gmail.com>.
I have a STM32F334 Discovery kit [1] but I never use this board nor the
Analog Comparator peripheral. If you could help me with the tests I can
work on this.

Thanks

Daniel Pereira de Carvalho

[1] https://www.st.com/en/evaluation-tools/32f3348discovery.html

Em qua., 16 de jun. de 2021 às 03:19, raiden00pl <ra...@gmail.com>
escreveu:

> > These definitions correct? Or I am understanding something wrong.
> It seems that these definitions are wrong. Probably a copy-paste error from
> COMPx_OUTx definitions.
>
> But what is strange, COMP worked even with bad input pins configuration for
> stm32f334-disco/powerled example.
> Unfortunately, my stm32f334-disco board died so I can't do any tests for
> this moment.
>
> śr., 16 cze 2021 o 00:51 Nathan Hartman <ha...@gmail.com>
> napisał(a):
>
> > Are these conditions also applicable to the STM32G4 family? This family
> has
> > different/newer IP blocks than some other STM32 families, but I'm away
> from
> > my computer and can't check the details now. Maybe raiden00pl knows more.
> > IIRC he fixed some of my mistakes in the pinmap :-)
> >
> > IIRC STmicro has somewhere an application note describing the analog
> > features like OPAMP, COMP, etc, and other features and how they differ
> from
> > other STM32 families. That document could come in handy.
> >
> > Nathan
> >
> >
> > On Tue, Jun 15, 2021 at 10:51 AM Daniel Pereira Carvalho <
> > danieloak@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > I'm trying to use the analog comparators of the nucleo-g431kb board.
> As
> > a
> > > reference I'm using the implementation and pin definition of the
> > > nucleo-f334r8 board. Looking at RM0364 Reference manual section *15.3.2
> > > COMP pins and internal signals* there is the following
> > >
> > > *"The I/Os used as comparators inputs must be configured in analog mode
> > in
> > > the GPIOs registers."*
> > >
> > > But looking at file arch/arm/src/stm32/hardware/stm32f33xxx_pinmap.h
> the
> > > comparator inputs are defined as Alternate Functions
> > >
> > > /* Comparator Inputs non inverting */
> > >
> > > #define GPIO_COMP2_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN7)
> > > #define GPIO_COMP4_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN0)
> > > #define GPIO_COMP6_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN11)
> > >
> > > /* Comparator Inputs inverting */
> > >
> > > #define GPIO_COMP2_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN2)
> > > #define GPIO_COMP2_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
> > > #define GPIO_COMP4_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN2)
> > > #define GPIO_COMP4_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
> > > #define GPIO_COMP6_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
> > > #define GPIO_COMP6_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN15)
> > >
> > > From the STM32F334x8 datasheet, Table 14  Alternate functions, there
> are
> > no
> > > corresponding definitions to configure comparator inputs on AF8.
> > >
> > > These definitions correct? Or I am understanding something wrong.
> > >
> > > Thanks
> > >
> > > Daniel Pereira de Carvalho
> > >
> >
>

Re: STM32G4 analog camparators

Posted by raiden00pl <ra...@gmail.com>.
> These definitions correct? Or I am understanding something wrong.
It seems that these definitions are wrong. Probably a copy-paste error from
COMPx_OUTx definitions.

But what is strange, COMP worked even with bad input pins configuration for
stm32f334-disco/powerled example.
Unfortunately, my stm32f334-disco board died so I can't do any tests for
this moment.

śr., 16 cze 2021 o 00:51 Nathan Hartman <ha...@gmail.com>
napisał(a):

> Are these conditions also applicable to the STM32G4 family? This family has
> different/newer IP blocks than some other STM32 families, but I'm away from
> my computer and can't check the details now. Maybe raiden00pl knows more.
> IIRC he fixed some of my mistakes in the pinmap :-)
>
> IIRC STmicro has somewhere an application note describing the analog
> features like OPAMP, COMP, etc, and other features and how they differ from
> other STM32 families. That document could come in handy.
>
> Nathan
>
>
> On Tue, Jun 15, 2021 at 10:51 AM Daniel Pereira Carvalho <
> danieloak@gmail.com> wrote:
>
> > Hi,
> >
> > I'm trying to use the analog comparators of the nucleo-g431kb board.  As
> a
> > reference I'm using the implementation and pin definition of the
> > nucleo-f334r8 board. Looking at RM0364 Reference manual section *15.3.2
> > COMP pins and internal signals* there is the following
> >
> > *"The I/Os used as comparators inputs must be configured in analog mode
> in
> > the GPIOs registers."*
> >
> > But looking at file arch/arm/src/stm32/hardware/stm32f33xxx_pinmap.h the
> > comparator inputs are defined as Alternate Functions
> >
> > /* Comparator Inputs non inverting */
> >
> > #define GPIO_COMP2_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN7)
> > #define GPIO_COMP4_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN0)
> > #define GPIO_COMP6_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN11)
> >
> > /* Comparator Inputs inverting */
> >
> > #define GPIO_COMP2_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN2)
> > #define GPIO_COMP2_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
> > #define GPIO_COMP4_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN2)
> > #define GPIO_COMP4_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
> > #define GPIO_COMP6_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
> > #define GPIO_COMP6_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN15)
> >
> > From the STM32F334x8 datasheet, Table 14  Alternate functions, there are
> no
> > corresponding definitions to configure comparator inputs on AF8.
> >
> > These definitions correct? Or I am understanding something wrong.
> >
> > Thanks
> >
> > Daniel Pereira de Carvalho
> >
>

Re: STM32G4 analog camparators

Posted by Nathan Hartman <ha...@gmail.com>.
Are these conditions also applicable to the STM32G4 family? This family has
different/newer IP blocks than some other STM32 families, but I'm away from
my computer and can't check the details now. Maybe raiden00pl knows more.
IIRC he fixed some of my mistakes in the pinmap :-)

IIRC STmicro has somewhere an application note describing the analog
features like OPAMP, COMP, etc, and other features and how they differ from
other STM32 families. That document could come in handy.

Nathan


On Tue, Jun 15, 2021 at 10:51 AM Daniel Pereira Carvalho <
danieloak@gmail.com> wrote:

> Hi,
>
> I'm trying to use the analog comparators of the nucleo-g431kb board.  As a
> reference I'm using the implementation and pin definition of the
> nucleo-f334r8 board. Looking at RM0364 Reference manual section *15.3.2
> COMP pins and internal signals* there is the following
>
> *"The I/Os used as comparators inputs must be configured in analog mode in
> the GPIOs registers."*
>
> But looking at file arch/arm/src/stm32/hardware/stm32f33xxx_pinmap.h the
> comparator inputs are defined as Alternate Functions
>
> /* Comparator Inputs non inverting */
>
> #define GPIO_COMP2_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN7)
> #define GPIO_COMP4_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN0)
> #define GPIO_COMP6_INP     (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN11)
>
> /* Comparator Inputs inverting */
>
> #define GPIO_COMP2_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN2)
> #define GPIO_COMP2_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
> #define GPIO_COMP4_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN2)
> #define GPIO_COMP4_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
> #define GPIO_COMP6_INM_1    (GPIO_ALT|GPIO_AF8|GPIO_PORTA|GPIO_PIN4)
> #define GPIO_COMP6_INM_2    (GPIO_ALT|GPIO_AF8|GPIO_PORTB|GPIO_PIN15)
>
> From the STM32F334x8 datasheet, Table 14  Alternate functions, there are no
> corresponding definitions to configure comparator inputs on AF8.
>
> These definitions correct? Or I am understanding something wrong.
>
> Thanks
>
> Daniel Pereira de Carvalho
>