Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Adc not Reading when timer 2 uses in pic 18f452

Status
Not open for further replies.

venkatesh_pinnacle

Newbie level 1
Joined
Sep 4, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
bangalore
Activity points
1,298
Hi to all,
Please any one can solve the problem.Here in my project coding uses timer2 it want to generate clock train pulse and also only one data pulse to control the line sensor which give the output voltage when dark particles moves over the ic, that i want to read by pic 18f452 and display by rs232.Here is my coding.And the clock frequency is 20Mhz.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

int timer2,data=1;

int8 adcstore;

#int_TIMER2
void TIMER2_isr(void)
{
timer2++;
output_toggle(PIN_B7); //Clk
output_bit(PIN_B0,data); //Data
data=0;
set_adc_channel(0);
delay_us(4);
adcstore=read_adc();
printf("%d\r\n",adcstore);
if(timer2==1023)
{

data=1;
timer2=0;

}
}



void main()
{

setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_1,4,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);

enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

// TODO: USER CODE!!
set_tris_b(0x00);
set_tris_c(0x00);
set_tris_a(0xff);


}

Here the clock pulse and data pulses also comes and the voltage of the line sensor also vary when dark passes over the sensor but the think is the adc does not read the analog value and printing the digital.It is possible to make this coading by pic.And also i have to generate the clock pulse frequency about more than 1Khz when i am using printf statement the frequency reduces up to 27 hz.Is is possible to do this kind of project in Pic controller or i have to switch to another controller
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top