#include <p18F452.h>
#include <usart.h>
#include <adc.h>
#include <stdlib.h>
#include <delays.h>
#pragma config OSC=XT,PWRT=ON,WDT=OFF,LVP=OFF,DEBUG=OFF
#pragma config CP0=OFF,CP1=OFF,CP2=OFF,CP3=OFF,CPB=OFF,CPD=OFF
#pragma config WRT0=OFF,WRT1=OFF,WRT2=OFF,WRT3=OFF,WRTB=OFF,WRTC=OFF,WRTD=OFF
#pragma config EBTR0=OFF,EBTR1=OFF,EBTR2=OFF,EBTR3=OFF,EBTRB=OFF
unsigned long int gonder;
unsigned long int gelen;
unsigned long int bilgi;
void DelayFor18TCY( void )
{
Nop(); Nop(); Nop();
Nop(); Nop(); Nop();
Nop(); Nop(); Nop();
Nop(); Nop(); Nop();
}
void main()
{
//USARTı ayarla
OpenUSART( USART_TX_INT_OFF &
USART_RX_INT_OFF & // interrupt off
USART_ASYNCH_MODE & // asenkron mod
USART_EIGHT_BIT & // 8 bit veri
USART_CONT_RX & // sürekli mod
USART_BRGH_HIGH, // high speed mod
25 ); // baud rate için
OpenADC( ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_8ANA_0REF,
ADC_CH0 & ADC_INT_OFF );
TRISA=0x00;
TRISB=0x00;
TRISC=0x80;
while (1)
{
Delay10TCYx(5);
ConvertADC();
while( BusyADC() );
bilgi=ReadADC();
while( BusyUSART() );
putcUSART(gonder);
while( BusyUSART() );
gelen=getcUSART();
PORTB=gelen;
}
CloseADC();
CloseUSART();
}