Joined: 07 Nov 2021
|How use RA to RA5 pins for ADC in PIC16F877A
|Posted: Mon Nov 08, 2021 6:39 am
|I would like to know how I can activate the pins of a 16f877 such as RA0 to RA5 to function as inputs that allow me to capture the value of 2 respective sensors to store them in separate variables that later will be evaluated or used in relevant conditionals.
I have tried with the following code, but I only get reading through RA0.
float TempAmbiente, SRefe;
//transform temperature and separate data receiving channels
set_tris_b(0b00000000); // I configure the pins for input or output, being 1 input and 0 output.
setup_adc_ports(RA0_ANALOG); // I allow the input of the data provided by the TempAmbiente sensor.
setup_adc_ports(RA1_ANALOG); // I try to read the reference signal
setup_COUNTERS(RTCC_internal.rtcc_div_1); // voltage division
// Turn on the LCD
lcd_init(); //Delete the display leaving it clean or initialized again.
TempAmbiente=(float) read_adc()/2; // here I read the PIN2.AN0 where is the ambient sensor
printf(lcd_putc,"%f" , TempAmbiente); // I show the ambient temperature
// I set the conditions for closing the loop
output_high(pin_b1); // Command a 1 to turn on the Red Led
output_high(pin_b2); // Command a 1 to turn on the FanMotor V1
output_low(pin_b4); // Command a 0 to turn off the Green Led
// I print a message to let people know what is happening.
printf(lcd_putc, "Disipando calor");
output_low(pin_b1); // Command a 0 to turn off the Red Led
output_low(pin_b2);// I turn off the V1 Fan
output_high(pin_b4);// I turn on the Green led
//I am sending again a message to let you know what is going on.
printf(lcd_putc, "Disipando Frio");
I'm really new to this and little by little is that with the manual and other information I try to get the project forward, since the assembly for the simulation is there but I lack that detail in the code, I would appreciate all the help possible.