adison.mhanna
Newbie level 4
- Joined
- Jun 2, 2013
- Messages
- 6
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,340
#include <16f877a.h>
#device adc=10
#fuses XT,NOLVP,NOWDT,NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
float temp;
void main()
{
SETUP_ADC(ADC_CLOCK_INTERNAL);
SETUP_ADC_PORTS(AN0);
SET_ADC_CHANNEL(0);
delay_ms(100);
while(1) // infinite loop
{
temp = read_adc();
delay_us(100);
printf("%2.1f C\n",temp);
}
}
#include <16f877a.h>
#device adc=10
#fuses XT,NOLVP,NOWDT,NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
float temp;
void main()
{
SETUP_ADC(ADC_CLOCK_DIV_64);
SETUP_ADC_PORTS(AN0);
SET_ADC_CHANNEL(0);
delay_ms(100);
while(1) // infinite loop
{
temp = read_adc();
delay_ms(1000);
printf("%5.2f C\n",temp);
}
}
SETUP_ADC(ADC_CLOCK_INTERNAL);
SETUP_ADC_PORTS(ALL_ANALOG);
SET_ADC_CHANNEL(0);
delay_ms(100);
output_a(0x00);
Try this and tell what u are getting..
#include <16f877a.h>
#device adc=10
#fuses XT,NOLVP,NOWDT,NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
unsigned int temp;
void main()
{
set_tris_a(0x01);
SETUP_ADC(ADC_CLOCK_INTERNAL);
SETUP_ADC_PORTS(ALL_ANALOG);
SET_ADC_CHANNEL(0);
delay_ms(100);
output_a(0x00);
while(1) // infinite loop
{
temp = read_adc();
delay_ms(1000);
printf("%u C\n",temp);
}
}
Looks like you are reading an unconnected pin... In this CCS compiler, do you have to say in somewhere if the pins are input or output? In the PIC MCU's, there's the TRIS registers. Each bit says to one pin if it is IN or OUT. Check if the compiler have this option, and if so, do this before all the configuration.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?