CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

set DAC module of PIC24F16KM202 and no channel indicator

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
iiibbo



Joined: 24 Jan 2018
Posts: 5

View user's profile Send private message

set DAC module of PIC24F16KM202 and no channel indicator
PostPosted: Wed Jan 24, 2018 6:35 am     Reply with quote

Hello,

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 2011
Posts: 303

View user's profile Send private message

PostPosted: Wed Jan 24, 2018 7:37 am     Reply with quote

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 2018
Posts: 5

View user's profile Send private message

PostPosted: Wed Jan 24, 2018 8:07 am     Reply with quote

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.

or

dac_write(DAC_LEFT, data) vs
dac_write(DAC_OUTPUT, data) -> no channel indicator

for example, in PIC24F device file, it is written that

dac_write(unsigned int8 module, unsigned int8 value)

but there is no indication of channel in given constants.

given constants-> DAC_OFF,DAC_ON, DAC_HALT_IDLE, DAC_NOHALT_SLEEP, DAC_NO_SOFT-RESET, DAC_USE_TRIGGER, DAC_OUTPUT, DAC_REF_..., DAC_TRIGGER_....

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 2010
Posts: 19546

View user's profile Send private message

PostPosted: Wed Jan 24, 2018 8:21 am     Reply with quote

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 2011
Posts: 303

View user's profile Send private message

PostPosted: Wed Jan 24, 2018 8:24 am     Reply with quote

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 2010
Posts: 19546

View user's profile Send private message

PostPosted: Wed Jan 24, 2018 9:26 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group