Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Can different analogWriteResolution values be set for DAC and PWM outputs ?

  1. #1
    Junior Member
    Join Date
    May 2019
    Posts
    2

    Can different analogWriteResolution values be set for DAC and PWM outputs ?

    I would like to use the Teensy LC's physical DAC at its full resolution (12-bit) whilst using the PWM outputs at a lower resolution (7-bit, to be able to run them faster).

    But calling analogWriteResolution(7) reduces the usable resolution of the physical DAC too.

    The physical DACs have a fixed real resolution, it seems to me that analogWrite() calls targeting the DACs should not be affected by the analogWriteResolution() function.

    Maybe we need a separate DACWrite() function or maybe the analogWriteResolution() needs a pin number argument like analogWriteFrequency()?

  2. #2
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,973
    try analogWriteDAC0(value) it is what is called by analogWrite() for DACs

    hardware/teensy/avr/cores/teensy3/analog.c
    Last edited by manitou; 05-27-2019 at 06:22 PM.

  3. #3
    Junior Member
    Join Date
    May 2019
    Posts
    2
    Quote Originally Posted by manitou View Post
    try analogWriteDAC0(value) it is what is called by analogWrite() for DACs

    hardware/teensy/avr/cores/teensy3/analog.c
    That works, thanks!
    That function call uses the full 12-bit resolution for the hardware DAC even when the PWM resolution is set to 7-bit with analogWriteResolution(7);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •