IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

Aidez moi à trouver les erreurs de ce code embarqué


Sujet :

C

  1. #1
    Nouveau membre du Club
    Inscrit en
    Avril 2008
    Messages
    41
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 41
    Points : 35
    Points
    35
    Par défaut Aidez moi à trouver les erreurs de ce code embarqué
    Salut tout le monde
    J'ai ecrit ce code en langage c embarqué,j'ai compilé et j'ai plein d'erreur qui peut m'aider?
    Le code est:


    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
    #include "xparameters.h"
    #include "xgpio_l.h"
    #include "xutil.h"
    #include <stdio.h>
    #include <fcntl.h>
     
    int main (void)
    {
        Xuint32 *MLogicPtr;
        Xuint32 data,data1, data2, result;
        int i;
     
        Print ("-- Entering main () --\r\n\n");
     
        Do{
            MLogicPtr = (Xuint32 *)XPAR_M_LOGIC_0_BASEADDR;
     
            //Entrer la premiére valeur
            Do {
            data =XGpio_mGetDataReg(XPAR_PUSH_BUTTONS_3BIT_BASEADDR, 1) ;
            data1 =XGpio_mGetDataReg(XPAR_DIP_SWITCHES_8BIT_BASEADDR, 1) ;
     
            } while (data == 0);
     
            xil_printf("Data read from Push_Buttons_3Bit: 0x%x\r\n", data);
            xil_printf("Data read from DIP_Switches_8Bit: 0x%x\r\n", data1);
     
            *(MLogicPtr) = data1 ;
     
            for(i=0; i <= 100; i++) { ; } //Temporistaion
     
            //Entrer la deuxiéme valeur
            Do {
                data =XGpio_mGetDataReg(XPAR_PUSH_BUTTONS_3BIT_BASEADDR, 1) ;
                data2 =XGpio_mGetDataReg(XPAR_DIP_SWITCHES_8BIT_BASEADDR, 1) ;
     
            } while (data == 0);
     
            xil_printf("Data read from Push_Buttons_3Bit: 0x%x\r\n", data);
            xil_printf("Data read from DIP_Switches_8Bit: 0x%x\r\n", data2);
     
            *(MLogicPtr + 0x21) = data2;
     
            for(i=0; i <= 100; i++) { ; } //Temporistaion
     
            //Recuperer le resultat
            result= *(MLogicPtr + 0x44);
     
            print ("Le resultat est \r\n");
            xil_printf("%d + %d = %d \r\n", data1,data2,result);
            xil_printf("%x + %x = %x \r\n\n", data1,data2,result);
     
            for(i=0; i <= 100; i++) { ; } //Temporistaion
     
        } while(1); // Toujours tant qu'il y'a une entrée de la part de l'utilisateur
     
        print("-- Exiting main() --\r\n\n\n");
     
        return 0;
    }
    avec "xparameter.h" est:

    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
    *******************************************************************/
     
    #define STDIN_BASEADDRESS 0x40600000
    #define STDOUT_BASEADDRESS 0x40600000
     
    /******************************************************************/
     
    #define XPAR_DLMB_CNTLR_BASEADDR 0x00000000
    #define XPAR_DLMB_CNTLR_HIGHADDR 0x00003FFF
    #define XPAR_ILMB_CNTLR_BASEADDR 0x00000000
    #define XPAR_ILMB_CNTLR_HIGHADDR 0x00003FFF
     
    /******************************************************************/
     
    #define XPAR_XUARTLITE_NUM_INSTANCES 2
    #define XPAR_DEBUG_MODULE_BASEADDR 0x41400000
    #define XPAR_DEBUG_MODULE_HIGHADDR 0x4140FFFF
    #define XPAR_DEBUG_MODULE_DEVICE_ID 0
    #define XPAR_DEBUG_MODULE_BAUDRATE 0
    #define XPAR_DEBUG_MODULE_USE_PARITY 0
    #define XPAR_DEBUG_MODULE_ODD_PARITY 0
    #define XPAR_DEBUG_MODULE_DATA_BITS 0
    #define XPAR_RS232_BASEADDR 0x40600000
    #define XPAR_RS232_HIGHADDR 0x4060FFFF
    #define XPAR_RS232_DEVICE_ID 1
    #define XPAR_RS232_BAUDRATE 9600
    #define XPAR_RS232_USE_PARITY 0
    #define XPAR_RS232_ODD_PARITY 0
    #define XPAR_RS232_DATA_BITS 8
     
    /******************************************************************/
     
    #define XPAR_XGPIO_NUM_INSTANCES 2
    #define XPAR_PUSH_BUTTONS_3BIT_BASEADDR 0x40000000
    #define XPAR_PUSH_BUTTONS_3BIT_HIGHADDR 0x4000FFFF
    #define XPAR_PUSH_BUTTONS_3BIT_DEVICE_ID 0
    #define XPAR_PUSH_BUTTONS_3BIT_INTERRUPT_PRESENT 0
    #define XPAR_PUSH_BUTTONS_3BIT_IS_DUAL 0
    #define XPAR_DIP_SWITCHES_8BIT_BASEADDR 0x40020000
    #define XPAR_DIP_SWITCHES_8BIT_HIGHADDR 0x4002FFFF
    #define XPAR_DIP_SWITCHES_8BIT_DEVICE_ID 1
    #define XPAR_DIP_SWITCHES_8BIT_INTERRUPT_PRESENT 0
    #define XPAR_DIP_SWITCHES_8BIT_IS_DUAL 0
     
    /******************************************************************/
     
    #define XPAR_M_LOGIC_NUM_INSTANCES 1
    #define XPAR_M_LOGIC_0_DEVICE_ID 0
    #define XPAR_M_LOGIC_0_BASEADDR 0x73600000
    #define XPAR_M_LOGIC_0_HIGHADDR 0x7360FFFF
     
    /******************************************************************/
    Les erreurs sont:

    TestApp_Memory/src/TestApp_Memory.c: In function `main'
    TestApp_Memory/src/TestApp_Memory.c:14: error: `Do' undeclared (first use in
    this function
    TestApp_Memory/src/TestApp_Memory.c:14: error: (Each undeclared identifier is
    reported only onc

    TestApp_Memory/src/TestApp_Memory.c:14: error: for each function it appears in.
    TestApp_Memory/src/TestApp_Memory.c:14: error: parse error before '{' toke
    TestApp_Memory/src/TestApp_Memory.c: At top level
    TestApp_Memory/src/TestApp_Memory.c:21: error: parse error before "while
    TestApp_Memory/src/TestApp_Memory.c:22: error: parse error before string constan
    TestApp_Memory/src/TestApp_Memory.c:22: error: conflicting types for 'xil_printf
    /cygdrive/c/EDK/gnu/microblaze/nt/bin/../lib/gcc/microblaze/3.4.1/../../../../mi
    croblaze/sys-include/stdio.h:135: error: previous declaration of 'xil_printf'
    was her
    TestApp_Memory/src/TestApp_Memory.c:22: error: conflicting types for 'xil_printf
    /cygdrive/c/EDK/gnu/microblaze/nt/bin/../lib/gcc/microblaze/3.4.1/../../../../mi
    croblaze/sys-include/stdio.h:135: error: previous declaration of 'xil_printf'
    was her
    TestApp_Memory/src/TestApp_Memory.c:22: warning: data definition has no type or
    storage clas
    TestApp_Memory/src/TestApp_Memory.c:23: error: parse error before string constan
    TestApp_Memory/src/TestApp_Memory.c:23: warning: data definition has no type or
    storage clas
    TestApp_Memory/src/TestApp_Memory.c:25: error: `data1' undeclared here (not in a
    function
    TestApp_Memory/src/TestApp_Memory.c:25: warning: data definition has no type or
    storage clas
    TestApp_Memory/src/TestApp_Memory.c:27: error: parse error before "for
    TestApp_Memory/src/TestApp_Memory.c:30: error: syntax error before '{' toke
    TestApp_Memory/src/TestApp_Memory.c:32: error: initializer element is not
    constan
    TestApp_Memory/src/TestApp_Memory.c:32: warning: data definition has no type or
    storage clas
    TestApp_Memory/src/TestApp_Memory.c:34: error: parse error before '}' toke
    TestApp_Memory/src/TestApp_Memory.c:35: error: parse error before string constan
    TestApp_Memory/src/TestApp_Memory.c:35: warning: data definition has no type or
    storage clas
    TestApp_Memory/src/TestApp_Memory.c:36: error: parse error before string constan
    TestApp_Memory/src/TestApp_Memory.c:36: warning: data definition has no type or
    storage clas
    TestApp_Memory/src/TestApp_Memory.c:38: error: parse error before '+' toke
    TestApp_Memory/src/TestApp_Memory.c:43: error: initializer element is not
    constan
    TestApp_Memory/src/TestApp_Memory.c:43: warning: data definition has no type or
    storage clas
    TestApp_Memory/src/TestApp_Memory.c:45: error: parse error before string constan
    TestApp_Memory/src/TestApp_Memory.c:45: error: conflicting types for 'print
    /cygdrive/c/EDK/gnu/microblaze/nt/bin/../lib/gcc/microblaze/3.4.1/../../../../mi
    croblaze/sys-include/stdio.h:137: error: previous declaration of 'print' was her
    TestApp_Memory/src/TestApp_Memory.c:45: error: conflicting types for 'print
    /cygdrive/c/EDK/gnu/microblaze/nt/bin/../lib/gcc/microblaze/3.4.1/../../../../mi
    croblaze/sys-include/stdio.h:137: error: previous declaration of 'print' was her
    TestApp_Memory/src/TestApp_Memory.c:45: warning: data definition has no type or
    storage clas
    TestApp_Memory/src/TestApp_Memory.c:46: error: parse error before string constan
    TestApp_Memory/src/TestApp_Memory.c:46: warning: data definition has no type or
    storage clas
    TestApp_Memory/src/TestApp_Memory.c:47: error: parse error before string constan
    TestApp_Memory/src/TestApp_Memory.c:47: warning: data definition has no type or
    storage clas
    TestApp_Memory/src/TestApp_Memory.c:53: error: parse error before string constan
    TestApp_Memory/src/TestApp_Memory.c:53: warning: data definition has no type or
    storage clas

  2. #2
    Rédacteur/Modérateur
    Avatar de Trap D
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    4 942
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 4 942
    Points : 6 498
    Points
    6 498
    Par défaut
    Il a l'air de manquer
    #include "xgpio_l.h"
    #include "xutil.h"


    Es-tu sur que la fonction Print (avec un P majuscule existe ?

    De plus "Do / while" s'écrit "do / while" avec un 'd' minuscule

  3. #3
    Nouveau membre du Club
    Inscrit en
    Avril 2008
    Messages
    41
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 41
    Points : 35
    Points
    35
    Par défaut
    Merci beaucoooooooooooooup ça marcher

  4. #4
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 5
    Points : 4
    Points
    4
    Par défaut Qq chose m'echappe
    La fonction XGpio_mGetDataReg fait parti du kernel. Comment tu fais pour appeler une fonction du kernel depuis un programme en userspace ?!?

    Je me trompe pas, c'est bien un simple executable que tu fais et pas un module, hein ?

    Je voudrais voir ton makefile et en particulier tes options de link... Qq chose m'echappe. Qd j'essaye de compiler une version simplifiée, tout ce que j'obtient c'est:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    /tmp/ccM8RIBT.o: In function `main':
    test_gpio.c:(.text+0x30): undefined reference to `XIo_Out32'
    collect2: ld returned 1 exit status
    make: *** [test_gpio] Error 1

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Débutant] trouver les erreurs dans un code
    Par rouliane dans le forum C++
    Réponses: 11
    Dernier message: 26/01/2008, 12h47
  2. [Visual Web] trouver l'erreur dans le code "sen email"
    Par diamonds dans le forum NetBeans
    Réponses: 4
    Dernier message: 21/11/2006, 20h05
  3. [langage] Aidez-moi avec les threads
    Par GnuVince dans le forum Langage
    Réponses: 2
    Dernier message: 24/10/2006, 09h21
  4. Trouver les redondances dans un code
    Par progfou dans le forum C
    Réponses: 9
    Dernier message: 17/03/2006, 08h53
  5. pas moyen de trouver l'erreur de ce code Javascript !!!
    Par NATHW dans le forum Général JavaScript
    Réponses: 7
    Dernier message: 25/11/2004, 21h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo