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
Using DAC O/P PIN RA2 16F1709
Moderator: Benj
-
- Flowcode V4 User
- Posts: 17
- Joined: Thu Jul 30, 2009 9:13 am
- Location: New Zealand
- Been thanked: 1 time
Using DAC O/P PIN RA2 16F1709
- Attachments
-
- MAP_16F1709_v1.fcfx
- (22.89 KiB) Downloaded 143 times
-
- PIC16F1709.docx
- (51.71 KiB) Downloaded 148 times
Regards
Roy
Roy
-
- Valued Contributor
- Posts: 773
- Joined: Fri Jun 06, 2014 3:53 pm
- Has thanked: 185 times
- Been thanked: 204 times
Re: Using DAC O/P PIN RA2 16F1709
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
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
-
- Flowcode V4 User
- Posts: 17
- Joined: Thu Jul 30, 2009 9:13 am
- Location: New Zealand
- Been thanked: 1 time
Re: Using DAC O/P PIN RA2 16F1709
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
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
Regards
Roy
Roy