Although there are 2 DACOUT channels for PIC24FV16KM202, there is single type constants for dac prototypes such as setup_dac() in the 24FV16KM202.h. I was expecting to to see two types of constants (dac_right and dac_left or dac1out, dac2out, ... exc) similar with other multiple DAC included devices such as 33F64gP802.h.

For example: #define DAC_ON 0x8000 is given for PIC24F... but there is no channel indicator.
#define DAC_LEFT_ON 0x00808000 and similarly DAC_RIGHT_ON are given for PIC33F... There is channel indicator right and left.

Is anybody worked with this device PIC24F16KM202 and test DAC outputs? Can you help me to write test code for these device to set DACs to fixed voltage levels according to wished DAC values?

gaugeguy

Joined: 05 Apr 2011Posts: 90

Posted: Wed Jan 24, 2018 7:37 am

On your processor setup_dac and dac_write both take two parameters. The first is the module and the second is the mode.
Look at the CCS header file for the processor.

iiibbo

Joined: 24 Jan 2018Posts: 2

Posted: Wed Jan 24, 2018 8:07 am

Sure, they take two parameters.
What I mean is that the difference between channel indications.

setup_dac(DAC_REF_VDD|DAC_LEFT) -> channel selected for PIC33F... vs setup_dac(DAC_REF_VDD|DAC_OUTPUT)-> no differentiation for channel and which channel is selected unknown.

Can you give me an example of code considering the DAC prototypes given in "24FV16KM202.h" which differentiates the channel clearly?

Ttelmah

Joined: 11 Mar 2010Posts: 13260

Posted: Wed Jan 24, 2018 8:21 am

Each DAC on this chip only has a single output. Two modules, one output each.
Chips like the dsPIC33EPXXXGS70X/80X, have two outputs on each module. Hence the extra commands to access these....

gaugeguy

Joined: 05 Apr 2011Posts: 90

Posted: Wed Jan 24, 2018 8:24 am

While I have used the PIC24FV16KM202 I have not used the DAC.

The data sheet labels them as DAC1 and DAC2 or DACx when referring to both.
The never use the term left or right but do use '1' and '2'. 1 and 2 both fit into an unsigned int8 to identify the module.

Cut code using setup_dac(1,mode) and setup_dac(2,mode) with whatever mode parameters you want and look at the listing to verify the registers written. You can make your own define for 1 and 2 to identify the DAC modules if you like.

#define DAC_LEFT 1
setup_dac(DAC_LEFT,mode);

Ttelmah

Joined: 11 Mar 2010Posts: 13260

Posted: Wed Jan 24, 2018 9:26 am

The other chip he is referring to, has the option to route each DAC output to two different connections. So there is a constant in the setup to decide which connection to feed the signal out on. This chip doesn't offer an option for this, just two separate modules. So there is no DAC_LEFT or DAC_RIGHT....

CCS only generates their configurations to match what MicroChip decide to call them. On chips aimed at analog audio, it makes sense to call the two DAC outputs 'left' and 'right', and MicroChip do so, on the other PIC they don't.