I am making a circuit with PIC16F690, but I get a wrong result on the output.
When I have 1.21 volts on the ADC, I get 2.94V on the DAC output. If I lower the ADC input, the DAC output gets higher, if I increase the ADC input, the DAC output gets lower, any ideas?
I am using the CCS PIC C compiler, v5.61.
When I have 1.21 volts on the ADC, I get 2.94V on the DAC output. If I lower the ADC input, the DAC output gets higher, if I increase the ADC input, the DAC output gets lower, any ideas?
I am using the CCS PIC C compiler, v5.61.
Code:
/* Main.c file generated by New Project wizard
*
* Created: Sun Jul 2 2017
* Processor: PIC16F690
* Compiler: CCS for PIC
*/
#include <16F690.h>
#include <math.h.>
#fuses NOMCLR, NOPROTECT, NOWDT, INTRC_IO
#use delay (clock=4M)
/* Prototypes */
void Initialization ();
int main (void)
{
/* Local variables */
unsigned int8 i = 0;
int8 ADC_sample = 0;
/* Initiazlization */
Initialization ();
while (1)
{
for (i=0; i<256; ++i)
{
delay_ms (100);
ADC_sample = read_adc (); /* Read ADC on pin RA0 */
output_c (~ADC_sample);
}
}
return 0;
}
/* Functions */
void Initialization ()
{
/* Setup ADC module and pins (channels) */
setup_adc (ADC_CLOCK_INTERNAL);
setup_adc_ports (sAN0);
set_adc_channel (0);
/* Setup comparator */
setup_comparator (NC_NC_NC_NC);
/* Setup CVref */
setup_vref (FALSE);
}
Attachments
-
75.9 KB Views: 18
