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 support@ccsinfo.com

PIC16LF1705 and DAC output

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



Joined: 01 Apr 2007
Posts: 195

View user's profile Send private message

PIC16LF1705 and DAC output
PostPosted: Sun Jun 19, 2016 10:22 am     Reply with quote

I'm using PCWHD V5.044 on a Windows 10 machine.

I'm trying to get the DAC output for a PIC16LF1705 chip working in a test configuration.

I have the statement setup_dac(DAC_VDD | DAC_OUTPUT) in my startup code. I am attempting to write to the DAC output with a command dac_write(dacVal), where dacVal is an unsigned 8-bit value to be written to the DAC output.

I get a compiler error stating setup_dac and dac_write are undefined identifiers. I looked in the 16LF1705.h file and saw nothing about DAC setup.

According to the chip datasheet, there should be a DAC output available on pin A0.

Has anyone gotten this chip to work with the DAC output?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 19, 2016 11:12 am     Reply with quote

Your old version doesn't support it. You will have to write your own
routines. Something like this:
Code:
#include <16LF1705.h>
#fuses INTRC_IO, NOWDT
#use delay(clock=4M)

// Constants used in setup_dac() are:
#define DAC_OFF  0
#define DAC_VSS_VDD   0x80
#define DAC_VREF_VDD  0x81
#define DAC_VSS_VREF  0x84
#define DAC_VREF_VREF 0x85
#define DAC_VSS_FVR   0x88
#define DAC_VREF_FVR  0x89
// The following may be OR'ed in with the above using |
#define DAC_OUTPUT2   0x10 
#define DAC_OUTPUT    0x20

#byte DAC1CON0 = 0x118
#byte DAC1CON1 = 0x119

void setup_dac(int8 value)
{
DAC1CON0 = value;
}

void dac_write(int8 data)
{
DAC1CON1 = data;
}

//==========================
void main()     
{
setup_dac(DAC_VSS_VDD | DAC_OUTPUT);
dac_write(128);

while(TRUE);   
}
starfire151



Joined: 01 Apr 2007
Posts: 195

View user's profile Send private message

PostPosted: Sun Jun 19, 2016 11:43 am     Reply with quote

Thanks very much!
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