How to use DAC1 Ch2 without dual mode Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
alex31
Posts: 304
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 28 times
Been thanked: 37 times
Contact:

Re: How to use DAC1 Ch2 without dual mode

Postby alex31 » Sun Apr 24, 2016 4:27 pm

I have created a ticket with a proposed patch attached.

Alexandre

User avatar
Giovanni
Site Admin
Posts: 13125
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 769 times
Been thanked: 653 times
Contact:

Re: How to use DAC1 Ch2 without dual mode

Postby Giovanni » Sun Apr 24, 2016 7:15 pm

I will give it a try tomorrow.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 13125
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 769 times
Been thanked: 653 times
Contact:

Re: How to use DAC1 Ch2 without dual mode

Postby Giovanni » Mon Apr 25, 2016 2:47 pm

Hi,

Fixed in repository, could you confirm everything is OK?

Giovanni

User avatar
alex31
Posts: 304
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 28 times
Been thanked: 37 times
Contact:

Re: How to use DAC1 Ch2 without dual mode

Postby alex31 » Tue Apr 26, 2016 9:13 pm

looks fine. I was on the road this two days, I will be able to do a real test tomorrow.

thanks
Alexandre

User avatar
alex31
Posts: 304
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 28 times
Been thanked: 37 times
Contact:

Re: How to use DAC1 Ch2 without dual mode

Postby alex31 » Mon May 02, 2016 8:03 pm

Tests has been done on F4 and F7 and all is working nicely !

Alexandre

User avatar
Giovanni
Site Admin
Posts: 13125
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 769 times
Been thanked: 653 times
Contact:

Re: How to use DAC1 Ch2 without dual mode  Topic is solved

Postby Giovanni » Mon May 02, 2016 8:04 pm

Thanks :)

Giovanni

sntnjrg
Posts: 65
Joined: Mon Jul 22, 2019 2:19 pm
Has thanked: 18 times
Been thanked: 3 times

Re: How to use DAC1 Ch2 without dual mode

Postby sntnjrg » Fri Jan 10, 2020 12:40 pm

Hi,

I have a similar problem. I'm using a STM32L4R5ZI-NUCLEO144 board and the version 19.1.0 of ChibiOS.

My mcuconf.h have the following definitions:

Code: Select all

/*
 * DAC driver system settings.
 */
#define STM32_DAC_DUAL_MODE                 FALSE
#define STM32_DAC_USE_DAC1_CH1              TRUE
#define STM32_DAC_USE_DAC1_CH2              TRUE
#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY     10
#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY     10
#define STM32_DAC_DAC1_CH1_DMA_PRIORITY     2
#define STM32_DAC_DAC1_CH2_DMA_PRIORITY     2
#define STM32_DAC_DAC1_CH1_DMA_STREAM       STM32_DMA_STREAM_ID_ANY
#define STM32_DAC_DAC1_CH2_DMA_STREAM       STM32_DMA_STREAM_ID_ANY


The DAC configuration is:

Code: Select all

  static DACConfig dac_cfg = {
    // Initial output on DAC channels.
    .init         = 0U,
    // DAC data holding register mode.
    .datamode     = DAC_DHRM_8BIT_RIGHT,
    // DAC control register.
    .cr = 0
  };


When the following code is executed, an assertion fails:

Code: Select all

dacPutChannelX(&DACD2,1,dac_out2);


The dacPutChannelX() function contains:

Code: Select all

void dacPutChannelX(DACDriver *dacp, dacchannel_t channel, dacsample_t sample) {

  osalDbgCheck(channel < (dacchannel_t)DAC_MAX_CHANNELS);
  osalDbgAssert(dacp->state == DAC_READY, "invalid state");

  dac_lld_put_channel(dacp, channel, sample);
}


channel is 1 and DAC_MAX_CHANNELS is 1.

The DAC_MAX_CHANNELS macro is defined in hal_dac_lld.h as:

Code: Select all

/**
 * @brief   Max DAC channels.
 */
#if STM32_DAC_DUAL_MODE == FALSE
#define DAC_MAX_CHANNELS                    1
#else
#define DAC_MAX_CHANNELS                    2
#endif


Is it possible to use that channel with that instance of the driver? Should I use channel 0 in both instances?

Code: Select all

dacPutChannelX(&DACD1,0,dac_out1);
dacPutChannelX(&DACD2,0,dac_out2);


Thanks

User avatar
Giovanni
Site Admin
Posts: 13125
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 769 times
Been thanked: 653 times
Contact:

Re: How to use DAC1 Ch2 without dual mode

Postby Giovanni » Fri Jan 10, 2020 1:29 pm

Hi,
It is a bug, I think the problem is here:

Code: Select all

/**
 * @brief   Max DAC channels.
 */
#if STM32_DAC_DUAL_MODE == FALSE
#define DAC_MAX_CHANNELS                    1
#else
#define DAC_MAX_CHANNELS                    2
#endif


Those two definitions are inverted. Moving this topic in bug reports.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 13125
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 769 times
Been thanked: 653 times
Contact:

Re: How to use DAC1 Ch2 without dual mode

Postby Giovanni » Sat Jan 11, 2020 10:36 am

Hi,

Fixed as bug #1065.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: Bing [Bot] and 9 guests