Votre avis PIC 18f4680
Répondre à la discussion
Affichage des résultats 1 à 18 sur 18

Votre avis PIC 18f4680



  1. #1
    invite5b138f33

    Votre avis PIC 18f4680


    ------

    bonjour,
    j'esseye de faire un code en C sous MPlab pour faire fonctionner un potars sur une carte PICDEM CAN LIN 2 et afficher la valeurs sur les 8 led en binaire , j'ai ecrit le code mais j'arrive pas a compiler , j'ai chercher par tout et la je bloque , je me tourne vers vous pour peut remarquer un truc qui cloche, quand j esseye de complier il me dit "" Executing: "C:\Program files\Picc\CCSC.exe" +FH "main.c" #__DEBUG=1 +ICD +DF +LN +T +A +M +Z +Y=9 +EA #__18F4680=TRUE
    *** Error 128 "C:\Program Files\PICC\devices\p18f4680.h" Line 10(1,2): A #DEVICE required before this line
    1 Errors, 0 Warnings.
    Build Failed.
    Halting build on first failure as requested.
    BUILD FAILED: Tue Apr 02 13:45:04 2013 ""


    voila mon code


    Code:
    #include <p18f4680.h>
    #include <adc.h>
    #include <pconfig.h>
    #use delay (clock = 8mhz) // voir quartz !
    byte lecture;
    
    
    
    void main(void) {
                                                                  //OSCCON = 0b01111000;                          // vitesse horloge 500KHz
                    set_tris_D(0xFF);                             // déclaration du port D en sortie
                    set_tris_A(0);                                // déclaration 
                                   
                                         
                    TRISAbits.TRISA5 = 1;                         //Potentionmetre connecter au port RA5...set as input
                    ANSELAbits.ANSA4 = 1;                         //analogique
                                                                  //ADCON0 = 0b00010101;                          //select RA5 as source of ADC and enable the module (AN3)
                                                                  //ADCON1 = 0b00000000;                          //left justified - FOSC/8 speed - Vref is Vdd
       
                    setup_adc_ports(AN4, VSS_VDD);                // port AN4
                    setup_ADC(ADC_CLOCK_DIV_64|ADC_TAD_MUL_12);
                    set_ADC_channel(3);
                    delay_us(15);
    
                    read_adc(ADC_START_ONLY);
       
               while(!adc_done());
                            
                    lecture = read_adc(ADC_READ_ONLY);            // lecture de la donnee
                    lecture = (ADRESH * 256 ) + ADRESL;           // multiplier par 256 ADRESH et ajouter ADRESL
                    output_D (lecture);
                             
        
        }
    Une idee ?

    -----
    Dernière modification par gienas ; 02/04/2013 à 21h20. Motif: Ajouté les balises code, obligatoires pour les programmes

  2. #2
    invite5b138f33

    Re : Votre avis PIC 18f4680

    je trouve toujours pas quoi faire ! Svp éclairer moi pour quoi ya cette erreur ?

  3. #3
    spown

    Re : Votre avis PIC 18f4680

    ça fait mal au yeux pour lire ton code. Essaye avec les balises [ CODE ] ( sans espace ).

    Tu utilises quoi comme compilateur ?

    Tu as combien de fichier type ***.c dans ta liste à gauche ?

  4. #4
    invite5b138f33

    Re : Votre avis PIC 18f4680

    Merci , pour le compilateur j'utilise le CCS sous MPlab , et j'ai qu'un seule fichier ***.C sur la gauche. revoilà le code plus propre et désolé pour la première publication.

    #include <p18F4680.h>
    #DEVICE ADC=10
    #include <adc.h>
    #include <pconfig.h>
    #use delay (clock = 8mhz) // voir quartz !
    byte lecture;



    void main(void) {
    set_tris_D(0xFF); // déclaration du port D en sortie
    set_tris_A(0); // déclaration
    TRISAbits.TRISA5 = 1; // Potentionmetre connecter au port RA5...set as input
    ANSELAbits.ANSA4 = 1; // analogique
    setup_adc_ports(AN4, VSS_VDD); // port AN4
    setup_ADC(ADC_CLOCK_DIV_64|ADC _TAD_MUL_12);
    set_ADC_channel(3);
    delay_us(25);
    read_adc(ADC_START_ONLY);

    while(!adc_done());
    lecture = read_adc(ADC_READ_ONLY); // lecture de la donnee
    lecture = (ADRESH * 256 ) + ADRESL; // multiplier par 256 ADRESH et ajouter ADRESL
    output_D (lecture);


    }

  5. A voir en vidéo sur Futura
  6. #5
    invite5b138f33

    Re : Votre avis PIC 18f4680

    je tien a signaler que avant j'utilise l'include 18F4680 ,mais avec l'utilisation de ADC il ma demander l'include p18F4680 , alors je l'ai mis dans le repertoire , apres il me dit "" Executing: "C:\Program files\Picc\CCSC.exe" +FH "ZEBI.c" #__DEBUG=1 +ICD +DF +LN +T +A +M +Z +Y=9 +EA #__18F4680=TRUE
    *** Error 128 "C:\Program Files\PICC\devices\p18F4680.h" Line 10(1,2): A #DEVICE required before this line
    1 Errors, 0 Warnings.
    Build Failed.
    Halting build on first failure as requested.
    BUILD FAILED: Wed Apr 03 09:59:13 2013 """

    SVP je me tourne vers vous j'ai toute esseyer !

  7. #6
    invite5b138f33

    Re : Votre avis PIC 18f4680


  8. #7
    invite5b138f33

    Re : Votre avis PIC 18f4680

    Aidez moi SVP !

  9. #8
    invitea2d82c8f

    Re : Votre avis PIC 18f4680

    Salut,
    Essaye d'inclure <18F4680.h> ET <p18F4680.h> !
    Bonne chance

  10. #9
    invite5b138f33

    Re : Votre avis PIC 18f4680

    Merci _asm_ , je vais devenir fou !!
    quand j inclue les deux il me dit !

    Executing: "C:\Program files\Picc\CCSC.exe" +FH "ZEBI.c" #__DEBUG=1 +ICD +DF +LN +T +A +M +Z +Y=9 +EA #__18F4680=TRUE
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 11(7,12): Expecting a (
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 11(21,24): Expecting a (
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 12(22,25): Expecting a (
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 12(29,30): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 13(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 13(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 13(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 14(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 14(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 14(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 15(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 15(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 15(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 16(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 16(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 16(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 17(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 17(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 17(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 18(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 18(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 18(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 19(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 19(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 19(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 20(12,17): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 20(18,19): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 20(19,20): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 21(1,2): Expecting a declaration
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 21(3,15): Expecting a (
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 22(22,25): Expecting a (
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 23(22,25): Expecting a (
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 23(28,29): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 38(1,2): Expecting a declaration
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 38(3,15): Expecting a (
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 39(22,25): Expecting a (
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 40(22,25): Expecting a (
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 40(29,30): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 41(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 41(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 41(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 42(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 42(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 42(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 43(12,17): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 43(18,19): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 43(19,20): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 44(12,17): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 44(18,19): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 44(19,20): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 45(12,17): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 45(18,19): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 45(19,20): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 46(12,17): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 46(18,19): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 46(19,20): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 47(12,17): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 47(18,19): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 47(19,20): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 48(12,17): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 48(18,19): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 48(19,20): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 49(1,2): Expecting a declaration
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 49(3,15): Expecting a (
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 50(22,25): Expecting a (
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 51(22,25): Expecting a (
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 51(29,30): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 52(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 52(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 52(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 53(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 53(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 53(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 54(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 54(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 54(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 55(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 55(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 55(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 56(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 56(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 56(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 57(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 57(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 57(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 58(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 58(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 58(18,19): Expecting a declaration
    *** Error 36 "C:\Program Files\PICC\devices\p18F4680.h" Line 59(12,16): Expecting a ; or ,
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 59(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 59(18,19): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 60(1,2): Expecting a declaration
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 60(3,15): Expecting a (
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 61(22,25): Expecting a (
    *** Error 48 "C:\Program Files\PICC\devices\p18F4680.h" Line 62(22,25): Expecting a (
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 62(29,30): Expecting a declaration
    --- Info 300 "C:\Program Files\PICC\devices\p18F4680.h" Line 13(12,16): More info: First Declaration of SID3
    *** Error 31 "C:\Program Files\PICC\devices\p18F4680.h" Line 63(12,16): Identifier is already used in this scope
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 63(17,18): Expecting a declaration
    *** Error 43 "C:\Program Files\PICC\devices\p18F4680.h" Line 63(18,19): Expecting a declaration
    --- Info 300 "C:\Program Files\PICC\devices\p18F4680.h" Line 14(12,16): More info: First Declaration of SID4
    *** Error 31 "C:\Program Files\PICC\devices\p18F4680.h" Line 64(12,16): Identifier is already used in this scope
    100 Errors, 0 Warnings.
    Build Failed.
    Halting build on first failure as requested.

  11. #10
    invitea2d82c8f

    Re : Votre avis PIC 18f4680

    Re salut,
    Je me suis penché sur ton code :
    ça ca marche :

    #include <18F4680.h>
    #DEVICE ADC=10
    //#include <adc.h>
    //#include <pconfig.h>
    #use delay (clock = 8mhz) // voir quartz !
    byte lecture;



    void main(void) {
    set_tris_D(0x00); // déclaration du port D en sortie
    set_tris_A(0xFF); // déclaration A en entrée
    //TRISAbits.TRISA5 = 1; // Potentionmetre connecter au port RA5...set as input
    //ANSELAbits.ANSA4 = 1; // analogique
    setup_adc_ports(AN0_TO_AN4 | VSS_VDD); // port AN4
    setup_ADC(ADC_CLOCK_DIV_64|ADC _TAD_MUL_12);
    set_ADC_channel(4); //AN4 ?
    delay_us(25);
    read_adc(ADC_START_ONLY);

    while(!adc_done());
    lecture = read_adc(ADC_READ_ONLY); // lecture de la donnee
    //lecture = (ADRESH * 256 ) + ADRESL; // multiplier par 256 ADRESH et ajouter ADRESL
    output_D (lecture);

    }


    Si j'ai bien compris tu veux faire une seule fois la mesure ?

  12. #11
    invitea2d82c8f

    Re : Votre avis PIC 18f4680

    Ca compile... mais il y a encore quelques choses a regarder... comme le fait que du n'aura que le byte de poids faible de la conversion dans le portd...

  13. #12
    invite5b138f33

    Re : Votre avis PIC 18f4680

    merci pour ton aide , franchement merci , et pour te repondre non je veut que sa soit cyclique , via la boucle while ? non ? alors comment on fait pour que sa soit cyclique ?

  14. #13
    invite5b138f33

    Re : Votre avis PIC 18f4680

    et pour le byte a poids faible, avant dans mon programme j'avais mis un décalage pour afficher sur les 8 bits, mais je l'ai enlever et simplifié au max le programme parsque il ne marcher pas !

  15. #14
    invite5b138f33

    Re : Votre avis PIC 18f4680

    et ASM ; le code que ta modifier il me dit
    " Executing: "C:\Program files\Picc\CCSC.exe" +FH "ZEBI.c" #__DEBUG=1 +ICD +DF +LN +T +A +M +Z +Y=9 +EA #__18F4680=TRUE
    *** Error 12 "ZEBI.c" Line 16(32,35): Undefined identifier ADC
    1 Errors, 0 Warnings.
    Build Failed.
    Halting build on first failure as requested.
    BUILD FAILED: Wed Apr 03 13:43:17 2013

  16. #15
    invite5b138f33

    Re : Votre avis PIC 18f4680

    C bon , sa compile il y avais un espace de plus dans la ligne 17 , merci je test sa et je te tiens au courant

  17. #16
    invite5b138f33

    Re : Votre avis PIC 18f4680

    Merci asm , un GRAND merci le programme marche , et jai tout mis dans une boucle while(1) pour lire cycliquement ! mais il est mal calibrer je vais me pencher la deçu ! encore merci !!!!!!

  18. #17
    invitea2d82c8f

    Re : Votre avis PIC 18f4680

    Re :
    Si ça peux t'aider... je pense que tu veux faire ça :
    Code:
    #include <18F4680.h>
    #DEVICE ADC=8	// <---------------------- 8 bits 
    #use delay (clock = 8mhz) // voir quartz !
    
    byte lecture;
    
    void main(void) {
    	set_tris_D(0x00); // déclaration du port D en sortie
    	set_tris_A(0xFF); // déclaration A en entrée
    	
    	setup_adc_ports(AN0_TO_AN4 | VSS_VDD); // port AN4
    	setup_ADC(ADC_CLOCK_DIV_64|ADC_TAD_MUL_12);
    	set_ADC_channel(4); //AN4 ?
    	delay_us(25);
    	
    	
    	while(1){
    		lecture = read_adc(ADC_START_AND_READ); // <----- start and read -> test du godone inclus
    		output_D (lecture);
    	}
    }
    edit : J'avais pas vu la deuxième page^^ c'est cool que tout marche... A+

  19. #18
    invite5b138f33

    Re : Votre avis PIC 18f4680

    Merci Beaucoup ASM !

Discussions similaires

  1. Qestion Pic 18f4680 .
    Par invite5b138f33 dans le forum Électronique
    Réponses: 8
    Dernier message: 29/03/2013, 16h16
  2. Bonjour, j'ai besoin de votre aide & de votre avis !
    Par invitef5a1df17 dans le forum Environnement, développement durable et écologie
    Réponses: 5
    Dernier message: 12/02/2010, 09h18
  3. Votre avis sur cet avis de pro du CESI
    Par stein42 dans le forum Habitat bioclimatique, isolation et chauffage
    Réponses: 7
    Dernier message: 15/04/2009, 13h59
  4. votre avis
    Par invite4a3d0e7b dans le forum Technologies
    Réponses: 4
    Dernier message: 30/11/2007, 21h30
Dans la rubrique Tech de Futura, découvrez nos comparatifs produits sur l'informatique et les technologies : imprimantes laser couleur, casques audio, chaises gamer...