Cantafford
Member
Hello,
I'm trying to read the ADC of PIC18f4550 and put that value on PORTB. I'm using ADC interrupt so I want to read the value when the ADC triggers an interrupt(conversion is complete).
I wrote the following code:
However I cannot see any change on the leds. They won't light up at all. Please help me correct this issue. I have no ideea what I'm doing wrong. Thanks.
I'm trying to read the ADC of PIC18f4550 and put that value on PORTB. I'm using ADC interrupt so I want to read the value when the ADC triggers an interrupt(conversion is complete).
I wrote the following code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include "header.h"
int counter=0;
void interrupt GetValue()
{
if(ADIF==1)
{
LATB = ADRESL; // read converted value to PORTC
ADON = 0;
}
ADIF = 0;
}
void main()
{
TRISB = 0;
TRISAbits.TRISA0 = 1;
OSCCON = 0x7F;
ADCON0 = 0x01; // channel 0 selected
ADCON1 = 0x0E; // references selected
ADCON2 = 0x89;
ADIF = 0;
ADIE = 1;
GIE = 1;
while(1)
{
GODONE = 1; // start conversion
}
}
However I cannot see any change on the leds. They won't light up at all. Please help me correct this issue. I have no ideea what I'm doing wrong. Thanks.