Skip to main content
HWhit.1
Associate III
August 23, 2026
Question

Problem with configuring DAC1_OUT1 and DAC1_OUT2 to drive COMP1 and COMP2 INP- by internal connection

  • August 23, 2026
  • 2 replies
  • 72 views

Hi,

I have been using a NUCLEO-H7A3ZI-Q board in a research project for a magnetic spectrometer. The input the the Nucleo board is two short pulses which I have for a year or so, been using to generate trigger pulses using the INP inputs of  COMP1 and COMP2 with INN connected to DAC1_OUT1 and DAC2_OUT2, respectively by on-chip connection. The external outputs of COMP1 and COMP2 drive TIM1 and TIM3 that trigger ADC1 and ADC2. 

 

I used STMCubeMX 6.17.0 and STMCubeIDE 2.1.0 for authoring the code. 

 

I I needed to recompile a new version and I experienced that the output from COMP1 was not working with random fluctuations between 0 and 1. Previously, the COMP1 output was sharp pulse with a duration the input pulse was over the threshold set by DAC1_OUT1. The COMP2 output behaves as it should.
 

I tried to check the output of DAC1_OUT1 and DAC1_OUT2. Only the latter could be directed to an external pin and this worked as intended and produced the signals as expected. DAC_1_OUT1 was restricted to on-chip connections. It seems the problem is that the internal connection DAC1-OUT1  → COMP1_INN is no longer being made. . However, on-chip connections did not previously need the external pin to be unused. (Pin PA5 is used as TIM5 ETR input.)


My questions:

  1. I suspect this is a bug in STMCubeMX since it has just appeared? 
  2. Is there a way to manually work-around the internal connection configuration e.g. by direct writing to the registers as part of the set-up procedure.

    Many thanks for any help on this issue.

2 replies

TDK
August 24, 2026

Show your code or go off of one of the existing examples.

Yes, you can write to registers to interact with the DAC or any other peripheral.

"If you feel a post has answered your question, please click ""Accept as Solution""."
HWhit.1
HWhit.1Author
Associate III
August 24, 2026

Thanks for the quick answer.

Prompted by the suggestion we can just write to registers, I decided to look at what was written to them using the debugger.

DAC1_MCR

     Mode 1 = 0x3;  Mode 2 = 0x3

DAC1_CR
    EN1 = 0x1;   EN2 = 0x1

COMP1_CGR1
    INNSEL = 0x4 <=> DAC1_CH1

COMP1_CGR2
    INNSEL = 0x4 <==> DAC1_CH2

COMP1_OR
    AFOP = 0x0
    OR = 0x0
TIM5_AFR   (TIM5 shares a pin with DAC1)
    ETR_SEL = 0x0 <==> ETR external input

All to this seems to be what it should be. The next phase was to get the soldering iron out. I took away the TIM5  ETR input so external DAC connections could be made to both channels and measured with a multimeter. Initially, I got some strange voltage outputs on DAC1_OUT1 but not on DAC1_OUT2. Then these settled down and behaved as they should. However the problem still persists which points to COMP1 as the source of the problem. 

 

The code is very long and most of it is performs functions not connected with the DAC1 or COMP½, so I will not load it all up here. At least he init functions seem to be what they should be according to the measured register values. 

Many thanks,