Bonjour,

Je programme sous MPLAB et le compilateur C ne veut rien savoir sur le code suivant (Ligne 34:Error: syntax error) :


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <i2c.h> 
#include <p18f452.h>
#include "driver_lcd.h"
#include <delays.h>
 
unsigned char busI2C(void)
{ unsigned char res, cmd_byte;
 
res=0x00;
 
OpenI2C(MASTER, SLEW_OFF);
SSPADD=7;
cmd_byte=0x01;
 
while(1){
StartI2C();
WriteI2C(0b10011011);
WriteI2C(cmd_byte);
RestartI2C();
WriteI2C(0b10011011);
res=readI2C();
NotAckI2C();
 
while( SSPCON2bits.ACKEN==1);
StopI2C();
if(cmd_byte==0x00)
{
return(res);
}
cmd_byte=res & 0x40?0:1;
}
}
 
char[] binToTableau( char bin){
 
bin=128*bin[7]+64*bin[6]+32*bin[5]+16*bin[4]+8*bin[3]+4*bin[2]+2*bin[1]+bin[0] - 127;
 
char Tableau[4];
 
if(bin<0){
Tableau[0]=0x2D;
bin=bin*(-1);
Tableau[1]=0x30^(bin/100);
Tableau[2]=0x30^(  (bin-(bin/100)*100)/10  );
Tableau[3]=0x30^(   bin - ((bin/100)*100 +(bin-((bin/100)*100)/10  )*10 ) ) ;
}
if(bin>0){
 
Tableau[0]=0x2B;
Tableau[1]=0x30^(bin/100);
Tableau[2]=0x30^(  (bin-(bin/100)*100)/10  );
Tableau[3]=0x30^(   bin - ((bin/100)*100 +(bin-((bin/100)*100)/10  )*10 ) ) ;
}
return Tableau[];
}
 
void main(void){
unsigned char Tableau[4];
 
while(1){
char temp;  // stockage de la temperature
 
temp = busI2C();
 
char Tab[] = binToTableau(temp);
 
}
}
Le but de la fonction binToTableau a un type retour "tableau de char".

Merci pour votre aide

GUillaume