thivanka321
Newbie level 5
i wrote a programme in ccs c, to display A/D conversion values in hyperterminal.
i used pic 18f452. what i'm really converting is anlogue values taken from accelerometer.
but there is a unexpected problem. that is even without setting accelerometer to the A PORT of the pic, hyperterminal displays A/D converted values.
i checked the controler board whether there is a signals to A port. but there is not.
i;m sure pic controller board is ok. it works with other programmes ,well.
what is the reason for that? any problem with programme or what?
reply me soon.
i used pic 18f452. what i'm really converting is anlogue values taken from accelerometer.
but there is a unexpected problem. that is even without setting accelerometer to the A PORT of the pic, hyperterminal displays A/D converted values.
i checked the controler board whether there is a signals to A port. but there is not.
i;m sure pic controller board is ok. it works with other programmes ,well.
what is the reason for that? any problem with programme or what?
reply me soon.
Code:
#include "G:\ccsfiles\project2.h"
void main()
{
float value;
setup_adc_ports(AN0_AN1_AN2_AN3_AN4);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_oscillator(False);
// TODO: USER CODE!!
setup_adc(ADC_CLOCK_DIV_8);
// setup_uart(19200);
set_tris_b(255);
output_D(0);
while(1)
{
set_adc_channel( 2 );
delay_us(20);
value = read_adc();
printf("x = %8.3f\n\r",value);
set_adc_channel( 1 );
delay_us(20);
value = read_adc();
printf("y = %8.3f\n\r",value);
set_adc_channel( 0 );
delay_us(20);
value = read_adc();
printf("z = %8.3f\n\r",value);
output_D(255);
}
}