Page 1 of 1

Using DAC O/P PIN RA2 16F1709

Posted: Thu Aug 04, 2022 12:22 am
by Roy
I am using PIC16F1709 and I want to use pin RA2 as the DAC output.
Flowcode8 does not allow me to set the DAC o/p pin. Default port A0.
Looking at the form it appears it I set C code for DAC1CON0 = 10110000 (0XB0) this will enable pin RA2 and disable Pin AO.
My question is my code correct in the attached Flowcode window and do I need to repeat the C block command during the program or will the Component Macro DAC_Output1 send the o/p to pin RA2?
Please see attachments for details

Re: Using DAC O/P PIN RA2 16F1709

Posted: Thu Aug 04, 2022 9:20 am
by chipfryer27
Hi

Sorry to be brief, travelling.

You are sending 10110000

According to datasheet bits 4 and 5 determine the output pin with 1=Enable / 0=Disable. You have both bits enabled. To disable DACOUT1 bit 5 needs to be 0 and to enable DACOUT2 bit 4 needs to be 1, so 10010000

I don't know how the Flowcode component operates (maybe it overwrites?) so can't say for certain without trying if changing the Register in your C-code Block will work with the component. If not you can use another C-Block(s) to enable/disable/set by modifying DAC1CON0 (bit 7 = Enable/Disable) and DAC1CON1 (bits 7 - 0 = Output).

Regards

Re: Using DAC O/P PIN RA2 16F1709

Posted: Tue Aug 16, 2022 12:25 am
by Roy
Hi Chipfryer27
Sorry for the delay I was building the circuit board to try out the program. I am pleased to say I only needed to add one line of C code to turn on the port for RA2 .
I placed this line after the component MARCO to enable the DAC output .
DAC1CON0= 0xB0 .
Next I have the component marco "Setoutput "(DAC_OUT)
This sends the required data to the DAC .
As the 16F1709 only has one DAC internally the output appears on both ports.
As you said if I wanted to only use RA2 i would need to change the value of DAC1CON0 to hex 90 .
Thanks