salut,
avant tt chose je tiens a remercie tt les gens qui participe dans ce forum.
je suis entrain de realiser un projet d'une commande a distance par sms a base du téléphone siemens A65 et le PIC 16F877.
j ai fait un prgme qui fait le decodage des sms .lors du test réel il n'a pas fonctionné .
merci de votre aide!!!
le PROGRAMME est le suivant:





#include "D:\modgsm.h"
INT mesure(int i)
{ int tension;
set_adc_channel(i);delay_ms(10 );
tension=read_adc();
delay_ms(100);

RETURN(tension);
}

void tension_to_volt(long int tension,char volt[3])
{
int cent;int dix;int un;
tension=tension*2;
if (tension >99 ){cent=(tension/100);output_B(cent);}else cent=0;
dix=(tension - (cent*100));
dix=dix/10;
un=(tension - cent*100 - dix *10);

volt[2]=(byte)cent+'0';
volt[1]=(byte)dix+'0';
volt[0]=(byte)un+'0';

}
void transmet_tension( byte i,char volt[3])
{int tension;
tension=mesure(i);
tension_to_volt(tension,volt);
putc('A');
putc('N');
putc(i+'0');
putc('=');
putc(volt[2]);
putc('.');
putc(volt[1]);
putc(volt[0]);
putc('V');
putc(' ');
}

compare_cmd_AN(char cmd[20],char code[20])
{int i;byte resultat;
resultat=1;
for(i=0;i<11;i++){if (!(cmd[i]==code[i])){resultat=0;} }
return resultat;
}
compare_cmd_NU(char cmd[20],char code[20])
{int i;byte resultat;
resultat=1;
for(i=0;i<10;i++){if (!(cmd[i]==code[i])){resultat=0;} }
return resultat;
}


Transmet_entree_logique()
{boolean EL0;boolean EL1;boolean EL2;boolean EL3;boolean EL4;boolean EL5;boolean EL6;boolean EL7;
EL0=input(PIN_D0);putc('E');pu tc('L');putc('0');putc('=');pu tc(EL0+'0');putc(' ');
EL1=input(PIN_D1);putc('E');pu tc('L');putc('1');putc('=');pu tc(EL1+'0');putc(' ');
EL2=input(PIN_D2);putc('E');pu tc('L');putc('2');putc('=');pu tc(EL2+'0');putc(' ');
EL3=input(PIN_D3);putc('E');pu tc('L');putc('3');putc('=');pu tc(EL3+'0');putc(' ');
EL4=input(PIN_D4);putc('E');pu tc('L');putc('4');putc('=');pu tc(EL4+'0');putc(' ');
EL5=input(PIN_D5);putc('E');pu tc('L');putc('5');putc('=');pu tc(EL5+'0');putc(' ');
EL6=input(PIN_D6);putc('E');pu tc('L');putc('6');putc('=');pu tc(EL6+'0');putc(' ');
EL7=input(PIN_D7);putc('E');pu tc('L');putc('7');putc('=');pu tc(EL7+'0');putc(' ');
}
sorties(char cmd[20])
{byte resultat;
resultat=1;
if (!(cmd[0]=='S')){resultat=0;}
if (!(cmd[1]=='O')){resultat=0;}
if (!(cmd[2]=='R')){resultat=0;}
if (!(cmd[3]=='T')){resultat=0;}
if (!(cmd[4]=='I')){resultat=0;}
if (!(cmd[5]=='E')){resultat=0;}
if (!(cmd[6]=='S')){resultat=0;}
if (!(cmd[7]=='=')){resultat=0;}
RETURN resultat;
}

void affectation_sortie(char cmd[20])
{
if (cmd[8]=='1'){output_high(PIN_B0);}el se output_low(PIN_B0);
if (cmd[9]=='1'){output_high(PIN_B1);}el se output_low(PIN_B1);
if (cmd[10]=='1'){output_high(PIN_B2);}el se output_low(PIN_B2);
if (cmd[11]=='1'){output_high(PIN_B3);}el se output_low(PIN_B3);
if (cmd[12]=='1'){output_high(PIN_B4);}el se output_low(PIN_B4);
if (cmd[13]=='1'){output_high(PIN_B5);}el se output_low(PIN_B5);
if (cmd[14]=='1'){output_high(PIN_B6);}el se output_low(PIN_B6);
if (cmd[15]=='1'){output_high(PIN_B7);}el se output_low(PIN_B7);
}
void main()
{
char code[20];
byte resultat_AN;
byte resultat_NU;
byte resultat_S;
char cmd_AN[11]= "ANALOGIQUE";
char cmd_NU[10]= "NUMERIQUE";
int i;
char volt[3];
long int comp;
byte ak;
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RT CC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1) ;
resultat_AN=0;
resultat_NU=0;
resultat_S=0;
ak=1;
Set_tris_b(0x00);
Set_tris_A(0xFF);
Set_tris_d(0xFF);
OUTPUT_B(0);
do
{
if (ak==1){printf("AT+CMGF=1;AT+C MGL");putc(13);ak=0;};
comp=comp+1;
delay_ms(1000);
if (comp==10){ak=1;comp=0;}
IF (kbhit()) {gets(code);
resultat_AN=compare_cmd_AN(cmd _AN,code);
resultat_NU=compare_cmd_NU(cmd _NU,code);
resultat_S=sorties(code);
}
if (resultat_AN==1) {for(i=0;i<7;i++){transmet_ten sion(i,volt);resultat_AN=0;}}
if (resultat_NU==1) {Transmet_entree_logique();res ultat_NU=0;}
if (resultat_S==1) {affectation_sortie(code);resu ltat_S=0;}
}
while (true);
}
#include "D:\PFE2007S2\MATRICE\programm e\programme.h"
#include <2432.C>


void main()
{char code[9];
long int i;LONG INT n;LONG INT J;LONG INT timeout; long int k;
byte t[7] ={0b0000001,0b0000010,0b000010 0,0B0001000,0b0010000,0b010000 0,0b1000000};
byte x;byte c;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_timer_0(RTCC_INTERNAL|RT CC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1) ;
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
init_ext_eeprom();
set_tris_b(0);
Output_B(0);
j=1;timeout=0;
n=22;
PRINTF(" EST FES");
l1:
while(!kbhit()&&(++timeout<300 00)) delay_ms(1);
IF (kbhit()) {gets(code);
for(i=j;i<8;i++){write_ext_eep rom(i,code[i]);}
j=j+7;
goto L1;
}

do
{
c=0;
for(k=1;k<n*7;k+7){

for(i=k;i<k+8;i++){
x=read_ext_eeprom(i);
Output_B(0);
I2C_Start();
I2C_Write(0x40);
I2C_Write(x);
I2C_Stop();
output_b(t[c]);delay_ms(10);
}
c=c+1;

if (c==8) {c=0;}
}

}
while (true);
}