Bonjour à tous,
Je suis en Deuxième année BTS Système électronique, et cette année j'ai un projet a soutenir.
Ma partie consiste a extraire une trame GPS pour l'exploiter sur un écran LCD.
J'ai donc besoin de vote aide pour le programme écrit en C.
Voila ce que j'ai trouvé.
Mon problème se porte sur la ligne 7char txt[768];
signed int latitude, longitude;
char *string;
int i;
unsigned short ready;
extern const unsigned short world_bmp[1024];
char GLCD_DataPort at PORTD;
sbit GLCD_CS1 at RB0_bit; sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2 at RB1_bit; sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS at RB2_bit; sbit GLCD_RS_Direction at TRISB2_bit;
sbit GLCD_RW at RB3_bit; sbit GLCD_RW_Direction at TRISB3_bit;
sbit GLCD_EN at RB4_bit; sbit GLCD_EN_Direction at TRISB4_bit;
sbit GLCD_RST at RB5_bit; sbit GLCD_RST_Direction at TRISB5_bit;
void interrupt() {
if (PIR1.F0 == 1) { //if interrupt is generated by TMR1IF
//Stop Timer 1:
T1CON.F0 = 0; //Set TMR1ON to 0
ready = 1; //set data ready
i = 0; //reset array counter
PIR1.F0 = 0; //Set TMR1IF to 0
}
if (PIR1.F5 == 1) { //if interrupt is generated by RCIF
txt[i++] = UART1_Read();
if (txt[i-1] == 0)
i = 0;
if (i == 768) i = 0;
//Stop Timer 1:
T1CON.F0 = 0; //Set TMR1ON to 0
//Timer1 starts counting from 15536:
TMR1L = 0xB0;
TMR1H = 0x3C;
//Start Timer 1:
T1CON.F0 = 1; //Set TMR1ON to 1
PIR1.F5 = 0; //Set RCIF to 0
}
}
void Display_Cursor(signed int lat, signed int lon) {
unsigned char latitude_y, longitude_x;
//Latitude and Longitude scaling for 128x64 display:
//Latitude: Input range is -90 to 90 degrees
//Longitude: Input range is -180 to 180 degrees
latitude_y = ((61*(90 - lat))/180) + 1;
longitude_x = ((125*(lon + 180))/360) + 1;
//Cursor drawing:
Glcd_Dot(longitude_x,latitude_ y,2); //Centar dot
Glcd_Dot(longitude_x-1,latitude_y,2); //Left dot
Glcd_Dot(longitude_x+1,latitud e_y,2); //Right dot
Glcd_Dot(longitude_x,latitude_ y-1,2); //Uper dot
Glcd_Dot(longitude_x,latitude_ y+1,2); //Lower dot
Delay_ms(500);
Glcd_Image( world_bmp ); //Display World map on the GLCD
}
void main() {
ADCON1 = 0x0F; // Set AN pins to Digital I/O
GLCD_Init();
Glcd_Set_Font(font5x7, 5, 7, 32);
Glcd_Fill(0x00);
Delay_ms(100);
ready = 0;
//Set Timer1 Prescaler to 1:8
T1CON.F5 = 1; //Set TCKPS1 to 1
T1CON.F4 = 1; //Set TCKPS0 to 1
//Enable Timer1 interrupt:
PIE1.F0 = 1; //Set TMR1IE to 1
//Timer1 starts counting from 15536:
TMR1L = 0xB0;
TMR1H = 0x3C;
//Clear Timer1 interrupt flag:
PIR1.F0 = 0; //Set TMR1IF to 0
//Note: Timer1 is set to generate interrupt on 50ms interval
UART1_Init(9600);
//Enable Usart Receiver interrupt:
PIE1.F5 = 1; //Set RCIE to 1
//Enable Global interrupt and Peripheral interrupt:
INTCON.F7 = 1; //Set GIE to 1
INTCON.F6 = 1; //Set PEIE to 1
//Start Timer 1:
T1CON.F0 = 1; //Set TMR1ON to 1
Glcd_Image( world_bmp ); //Display World map on the GLCD
while(1)
{
RCSTA.F1 = 0; //Set OERR to 0
RCSTA.F2 = 0; //Set FERR to 0
if(ready == 1) { //if the data in txt array is ready do:
ready = 0;
string = strstr(txt,"$GPGLL");
if(string != 0) { //If txt array contains "$GPGLL" string we proceed...
if(string[7] != ',') { //if "$GPGLL" NMEA message have ',' sign in the 8-th
//position it means that tha GPS receiver does not have FIXed position!
latitude = (string[7]-48)*10 + (string[8]-48);
longitude = (string[20]-48)*100 + (string[21]-48)*10 + (string[22]-48);
if(string[18] == 'S') { //if the latitude is in the South direction it has minus sign
latitude = 0 - latitude;
}
if(string[32] == 'W') { //if the longitude is in the West direction it has minus sign
longitude = 0 - longitude;
}
Display_Cursor(latitude, longitude); //Display the cursor on the world map
}
}
}
}
}car quand j'essaye de le compiler il me dit qu'il y a une erreur.char GLCD_DataPort at PORTD;
Merci a tous ceux qui vont pouvoir m'aider.
Et si je rencontre d'autres problèmes je vous les dirais.
Merci
-----