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.

multiple adc programming

Status
Not open for further replies.

ptte

Newbie level 4
Joined
Apr 17, 2010
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,327
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...
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,
 

I guess it should be c2[1] while using puts and do not forget to put the '\0' at the end of each row in the 2d-array c2.
--
Amr
 

The problem is am not able to display array values properly in the Hyperterminal

forget about displaying the array. can you display anything on the hyperterminal at all? what will putsUSBUSART("abcdefg"); produce on hyperterminal?
 

Thanks for ur reply

putsUSBUSART("abcde") will not display anything in the hyperterminal

only putrsUSBUSART function will display the string....

Correct me if am wrong...

Thanks,
 

Hi ptte

you can have a look at these tutorials, they use the same PIC as you do and explain how to configure and use the ADC with multiple channels and how to communicate with the PC through RS232:
**broken link removed**
**broken link removed**

Hope this helps
 

putsUSBUSART("abcde") will not display anything in the hyperterminal

only putrsUSBUSART function will display the string....

then use putrsUSBUSART.

Correct me if am wrong...

it is your code and if you say putrsUSBUSART works then it works.

we have no other way to verify or refute or support it.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top