PB de compilation
Répondre à la discussion
Affichage des résultats 1 à 2 sur 2

PB de compilation



  1. #1
    invitef97198f3

    PB de compilation


    ------

    Bonjour à tous voila mon code
    Code:
    /*fonction detection_reception
    et fonction lecture_trame*/
    #include <p18f452.h>
    #include <delays.h>
    #include <usart.h>
    #include <string.h>
    
    //Déclaration des ports
    #define DATA_PORT      PORTD
    #define TRIS_DATA_PORT TRISD
    #define RS_PIN   PORTDbits.RD2   /* ligne RS */
    #define TRIS_RS  DDRDbits.RD2    /* config ligne RS */
    #define E_PIN    PORTDbits.RD3   /* ligne E  */
    #define TRIS_E   DDRDbits.RD3    /* config ligne E  */
    
    char recept[768];
    signed int latitude, longitude;
    char *string;
    int i;
    unsigned short ready;
    		
    //déclaration fonction Commande initialisation
    void init (unsigned char cmdinit);
    void initlcd (void);
    void resetlcd (void);
    //déclaration des fonctions Commande et d'Ecriture d'une donnée
    void WriteCmdXLCD(unsigned char cmd);
    void WriteDataXLCD(char data);
    
    void interrupt(void) {
      if (PIR1bits.TMR1IF == 1) {        //if interrupt is generated by TMR1IF
        //Stop Timer 1:
        T1CONbits.TMR1ON = 0;                    //Set TMR1ON to 0
        ready = 1;                       //set data ready
        i = 0;                           //reset array counter
        PIR1bits.TMR1IF = 0;                     //Set TMR1IF to 0
      }
      if (PIR1bits.RCIF == 1) {        //if interrupt is generated by RCIF
        recept[i++] = RCREG;
        if (recept[i-1] == 0)
          i = 0;
        if (i == 768) i = 0;
        //Stop Timer 1:
        T1CONbits.TMR1ON = 0;                    //Set TMR1ON to 0
        //Timer1 starts counting from 15536:
        TMR1L = 0xB0;
        TMR1H = 0x3C;
        //Start Timer 1:
        T1CONbits.TMR1ON = 1;                   //Set TMR1ON to 1
        PIR1bits.RCIF = 0;                     //Set RCIF to 0
      }
    }
    
    
    void main(void) {
    
        ADCON1 = 0x0F;                               // Set AN pins to Digital I/O
        ready = 0;
        
        //Set Timer1 Prescaler to 1:8
        T1CONbits.T1CKPS1 = 1;                    //Set T1CKPS1 to 1
        T1CONbits.T1CKPS0 = 1;                    //Set T1CKPS0 to 1
        //Enable Timer1 interrupt:
        PIE1bits.TMR1IE = 1;                     //Set TMR1IE to 1
        //Timer1 starts counting from 15536:
        TMR1L = 0xB0;
        TMR1H = 0x3C;
        //Clear Timer1 interrupt flag:
        PIR1bits.TMR1IF = 0;                     //Set TMR1IF to 0
        //Note: Timer1 is set to generate interrupt on 50ms interval
    
        SPBRG = 25; // configure la vitesse à 9600 BAUD N 8 1
        //Enable Usart Receiver interrupt:
        PIE1bits.RCIE = 1;                     //Set RCIE to 1
        //Enable Global interrupt and Peripheral interrupt:
        INTCONbits.GIE = 1;                   //Set GIE to 1
        INTCONbits.PEIE = 1;                   //Set PEIE to 1
        
        //Start Timer 1:
        T1CONbits.TMR1ON = 1;                    //Set TMR1ON to 1
        
        while(1)
        {
          RCSTAbits.OERR = 0;                  //Set OERR to 0
          RCSTAbits.FERR = 0;                  //Set FERR to 0
          
          if(ready == 1) { //if the data in recept array is ready do:
            ready = 0;
            string = strstr(recept,"$GPGGA");
            if(string != 0) {          //If txt array contains "$GPGGA" 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;
                }
              }
            }
          }
        }
    }
    
    void resetlcd (void){
    WriteCmdXLCD(0X01);//efface la mémoire de donnée et ramène le curseur à l'@0x00
    WriteCmdXLCD( 0X06);//le curseur se déplace vers la droite I/D=1 
    					 //l'affichage n'accompagne pas le curseur dans son déplacement S=0
    }
    
    void initlcd (void){
    init (0x30);// mode 8 bits sur interface 8 bits
    init (0x30);// mode 8 bits sur interface 8 bits
    init (0x30);// mode 8 bits sur interface 8 bits
    init (0x20);// mode 4 bits sur interface 8 bits
    
    WriteCmdXLCD(0X28);//mode 4 bits et 2 lignes
    WriteCmdXLCD(0X0E);//afficheur en fonction D=1 Le curseur C=1 et le clignotement B=1
    WriteCmdXLCD(0X01);//efface la mémoire de donnée et ramène le curseur à l'@0x00
    WriteCmdXLCD( 0X06);//le curseur se déplace vers la droite I/D=1 
    					 //l'affichage n'accompagne pas le curseur dans son déplacement S=0
    }
    
    //fonction Commande d'initialisation on envoie que les 4 bits de poids fort
    void init (unsigned char cmdinit)
    {
    		TRIS_RS=0;
    		TRIS_E=0;
    		RS_PIN = 0;
            TRIS_DATA_PORT &= 0x0f;
            DATA_PORT &= 0x0f;//envoi des bits de poids fort
            DATA_PORT |= cmdinit&0xf0;
            E_PIN = 1;                      
            Delay10TCYx(1);//5us
            E_PIN = 0;
    		Delay10KTCYx (10);// 50ms
    }
    
    //fonction Commande on envoie  les 4 bits de poids fort puis les 4 bits de poids faible
    void WriteCmdXLCD(unsigned char cmd)
    {       TRIS_RS=0;
    		TRIS_E=0;
    		RS_PIN = 0;
            TRIS_DATA_PORT &= 0x0f;
            DATA_PORT &= 0x0f;//envoi des bits de poids fort
            DATA_PORT |= cmd&0xf0;
            E_PIN = 1;                      
            Delay10TCYx(1);//5us
            E_PIN = 0;
            DATA_PORT &= 0x0f; //envoi des bits de poids faible
            DATA_PORT |= (cmd<<4)&0xf0;
            E_PIN = 1;                      
            Delay10TCYx(1);//5us
            E_PIN = 0;
    		Delay10KTCYx (10);//50ms remplace la lecture du BusyFlag
    } 
    
    //fonction Ecriture on envoie  les 4 bits de poids fort puis les 4 bits de poids faible
    void WriteDataXLCD(char data)
    {       TRIS_RS=0;
    		TRIS_E=0;
    		RS_PIN = 1;                     
            TRIS_DATA_PORT &= 0x0f;
            DATA_PORT &= 0x0f; //envoi des bits de poids fort
            DATA_PORT |= data&0xf0;
            E_PIN = 1;                      
            Delay10TCYx(1);//5us
            E_PIN = 0;
            DATA_PORT &= 0x0f; //envoi des bits de poids faible
            DATA_PORT |= ((data<<4)&0xf0);
            E_PIN = 1;                      
            Delay10TCYx(1);//5us
            E_PIN = 0;
    		Delay10KTCYx (10);//50ms remplace la lecture du BusyFlag
    }
    A la ligne "string = strstr(recept,"$GPGGA");" quand je compile j'ai cette erreur:
    "Warning [2066] type qualifier mismatch in assignment"
    je ne comprend pas pk.

    -----

  2. #2
    sdec25

    Re : PB de compilation

    Salut,
    prototype de la fonction strstr :
    Code:
    char *strstr (auto const char *s1, auto const char *s2);
    Tu lui passes un rom char* en 2ème argument, le compilateur n'aime pas.

    Pour + d'explication, ce topic, en particulier le post 18.

Discussions similaires

  1. Une compilation
    Par invite900e2c79 dans le forum Mathématiques du collège et du lycée
    Réponses: 2
    Dernier message: 01/05/2010, 18h15
  2. Problème de compilation
    Par invite58110dc5 dans le forum Logiciel - Software - Open Source
    Réponses: 0
    Dernier message: 15/09/2008, 03h07
  3. Installation / Compilation OS X
    Par Goldfish dans le forum Logiciel - Software - Open Source
    Réponses: 0
    Dernier message: 03/07/2008, 17h44
  4. compilation pic16F877
    Par invite83d28800 dans le forum Électronique
    Réponses: 7
    Dernier message: 30/04/2008, 14h22
  5. [c++]compilation fichier
    Par invite9b88e44f dans le forum Logiciel - Software - Open Source
    Réponses: 1
    Dernier message: 20/07/2007, 12h20
Dans la rubrique Tech de Futura, découvrez nos comparatifs produits sur l'informatique et les technologies : imprimantes laser couleur, casques audio, chaises gamer...