Hi.I write a program in C for my microcontroller(PIC 18F452) but
faced to a problem that related only to C language and that is;
as you can see in my Main program and the two Functions I want to
pass an array of ; " int adcvalmax[8] " which got valued in the Function;
" int CHS_Read(int adcvalmax[8]) ", between " Main " program and
Function; void Display_AdcX(int adcvalmax[8] ) for processing.
But I do not know if my "Main & Functions" are right or not?
Here are the descriptions of my Functions and Main program;
1.int CHS_Read(int adcvalmax[8]); Reading input values by analog to digital module of the PIC18F452 and save the results in the array
" adcvalmax[m] ".
2.void Display_AdcX(int adcvalmax[8] ) ;get the array
" adcvalmax[m] "and by using it display its value on LCD.
3.In the Main program I call Function; " void Display_AdcX(int adcvalmax[8] ) " as; Display_AdcX( adcvalmax[] ); .
Would you please help me and tell me if my program and functions are right or not?And what is/are wrong in my program?
Thanks,
unsigned char ch0=0,ch1=0;
int t0=0,t1=0;
char *tc;
int adcvalmax[8]=0;
#define stepsize 98
int interb0=0;
void Display_AdcX(int adcvalmax[8] ) {
int i=0,m=0;
char ch[i]=0;
adcvalmax[8]=0;
for(i,m=0;i,m<8;i++,m++){ //IS THIS FOR STATEMENT RIGHT? ****************
ch[i] = adcvalmax[m] /1000;
Lcd_Chr(2, 1, 48 + ch[i]); //write ASCII at 2nd row,1st column
Lcd_Chr_Cp('.');
ch[i] = ( adcvalmax[m] /100) % 10;
Lcd_Chr_Cp(48 + ch[i]);
ch[i] = ( adcvalmax[m] /10) % 10;
Lcd_Chr_Cp(48 + ch[i]);
ch[i] = adcvalmax[m] % 10;
Lcd_Chr_Cp(48 + ch[i]);
Lcd_Chr_Cp('A');
}
}//~
int CHS_Read(int adcvalmax[8]){
long longadc=0;
adcvalmax[8]=0;
int ch[8];//declares a array of 8 integers
int m=0,i=0;
int Px=0,P1st=0,P2nd=0;
for(i=0;i<8;i++){
for(m=0;m<8;m++){
do{
ch[i]=ADC_Read(i);
Px=ch[i];
}while(Px!=0)
P1st=ADC_Read(m);
Delay_ms(10);//10 ms pause
P2nd=ADC_Read(m);
while(P1st<=P2nd){
P1st=P2nd;
P2nd=0;
P2nd=ADC_Read(m);
}
adcvalmax[m] = P1st;// if (vf>vn)
index = (stepsize);
ADRESH = (ADRESH)&&(0b00000011);
longadc = ADRESH + ADRESL;
adcvalmax[m] = longadc * index;//in mA or mv
}
}
return[adcvalmax[]];
}//~
void main() {
Display_AdcX( adcvalmax[] )
Delay_ms(2000);
}//~!
unsigned char ch0=0,ch1=0;
int t0=0,t1=0;
char *tc;
int adcvalmax[8]=0;
#define stepsize 98
int interb0=0;
void Display_AdcX(int adcvalmax[8] ) {
int i=0,m=0;
char ch[i]=0;
adcvalmax[8]=0;
for(i,m=0;i,m<8;i++,m++){ //IS THIS FOR STATEMENT RIGHT? ****************
ch[i] = adcvalmax[m] /1000;
Lcd_Chr(2, 1, 48 + ch[i]); //write ASCII at 2nd row,1st column
Lcd_Chr_Cp('.');
ch[i] = ( adcvalmax[m] /100) % 10;
Lcd_Chr_Cp(48 + ch[i]);
ch[i] = ( adcvalmax[m] /10) % 10;
Lcd_Chr_Cp(48 + ch[i]);
ch[i] = adcvalmax[m] % 10;
Lcd_Chr_Cp(48 + ch[i]);
Lcd_Chr_Cp('A');
}
}//~
int CHS_Read(int adcvalmax[8]){
long longadc=0;
adcvalmax[8]=0;
int ch[8];//declares a array of 8 integers
int m=0,i=0;
int Px=0,P1st=0,P2nd=0;
for(i=0;i<8;i++){
for(m=0;m<8;m++){
do{
ch[i]=ADC_Read(i);
Px=ch[i];
}while(Px!=0)
P1st=ADC_Read(m);
Delay_ms(10);//10 ms pause
P2nd=ADC_Read(m);
while(P1st<=P2nd){
P1st=P2nd;
P2nd=0;
P2nd=ADC_Read(m);
}
adcvalmax[m] = P1st;// if (vf>vn)
index = (stepsize);
ADRESH = (ADRESH)&&(0b00000011);
longadc = ADRESH + ADRESL;
adcvalmax[m] = longadc * index;//in mA or mv
}
}
return[adcvalmax[]];
}//~
void main() {
Display_AdcX( adcvalmax[] )
Delay_ms(2000);
}//~!