ptte
Newbie level 4
Hi...
I Am trying a Program to read first four channels of PIC18F4550.I am reading the four channels one by one and than storing adc values in an array to display the values in Hyperterminal...
The problem is am not able to display array values properly in the Hyperterminal
Here am attaching my code...
I Am trying a Program to read first four channels of PIC18F4550.I am reading the four channels one by one and than storing adc values in an array to display the values in Hyperterminal...
The problem is am not able to display array values properly in the Hyperterminal
Here am attaching my code...
Code:
void Get_Start_End(unsigned char a,unsigned char b)
{
int l,m,temp5;
char a_buffer[5],x;
char c2[5][4] = {
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{'\0'}
};
for(x = a,l=0; x<=a+b-1; x++,l++) //channel selection loop
{
x = x & 0x07;
ADCON0bits.CHS0 = (x & 0b00000001); //selecting the channel
ADCON0bits.CHS1 = ((x & 0b00000010)>>1);
ADCON0bits.CHS2 = ((x & 0b00000100)>>2);
ADCON0bits.GO = 1; // start of conversion
while(ADCON0bits.NOT_DONE); //wait for conversion
temp5 = ReadADC();
itoa(temp5,a_buffer);
for(m=0; m<4; m++){
c2[l][m] = a_buffer[m]; //storing the ADC values
}
}
putsUSBUSART(c2); //To display
}
awaiting ur replies...
Thanks,