Problems with Microcontroller Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you the Codes for Registered Members of this site only, at free service...Follow Me.

PIC 18F452 microcontroller ADC code

PIC 18F452 microcontroller ADC code: use mikroc to build hex file


#include
#include
#pragma code My_HiPrio_Int=0×0008
void chk_isr(void);
void AD_ISR(void);
void My_HiPrio_Int(void)
{
chk_isr();
}
#pragma code
#pragma interrupt chk_isr
void chk_isr(void)
{
if(PIR1bits.ADIF==1)
AD_ISR();
}
void main(void)
{
TRISB=0;
TRISD=0;
TRISAbits.TRISA0=0;
ADCON0=0×81;
ADCON1=0xCE;
PIR1bits.ADIF=0;
PIE1bits.ADIE=1;
INTCONbits.PEIE=1;
INTCONbits.GIE=1;
while(1)
{
Delay10TCYx(1);
ADCON0bits.GO=1;
}
}
void AD_ISR(void)
{
PORTB=ADRESL;
PORTD=ADRESH;
Delay10TCYx(250);
PIR1bits.ADIF=0;
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Recent Comments

Popular Projects

Give Support

Give Support
Encourage Me through Comments

Microcontroller Projects

Total Pageviews