Se connecter avec
S'enregistrer | Connectez-vous

syntaxe fonction interruption en C

Dernière réponse : dans Programmation

Bonjour, j'ai un pb! je dois programmer un PIC16F877 avec le logiciel MPLAB et (CC5X)
Je ne parviens pas a écrire comme il faut une fonction interruption, mon programme ne compil pas! please help
voici le programme :
  1. char byte_recu;
  2. /*Interruptions*/
  3. void interrupt USART_isr(void) @0x04
  4. {
  5. if(RCIF && RCIE)
  6. {
  7. byte_recu = Recep_Car();
  8. }
  9. else byte_recu ='-';
  10. RCIF=0; //libère le flag d'interruption
  11. }
  12.  
  13. char recep_Car(void)
  14. {
  15. while(!RCIF) /*attente réception d'un caractère*/
  16. continue;
  17.  
  18. return RCREG; /*caractère reçu fourni comme résultat*/
  19. }

Autres pages sur : syntaxe fonction interruption

Lassé par la pub ? Créez un compte

j'oublier, voila ce j'obtient quand je compile :

Citation :

Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\bknd\CC5X\CC5X.EXE" avecRS232.c -CC -fINHX8M -p16F877 -a -L -Q -V -FM
CC5X Version 3.3, Copyright (c) B Knudsen Data, Norway 1992-2006
--> FREE edition, 8-16 bit int, 24 bit float, 1k code, reduced optim.
avecRS232.c:

/*Interruptions*/
void interrupt USART_isr(void) @0x04
^------
Error[1] C:\Documents and Settings\Admin\Mes documents\L3GEII\PROJET\pgrm_MPLAB\avecRS232.c 20 : Too many types in declaration

/*Interruptions*/
void interrupt USART_isr(void) @0x04
^------
Error[2] C:\Documents and Settings\Admin\Mes documents\L3GEII\PROJET\pgrm_MPLAB\avecRS232.c 20 : Syntax error
(The expression must be corrected. The marker ^------ shows
the approximate position where CC5X gives up. The documentation
should be checked if the cause is not obvious)

Error options: -ew: no warning details -ed: no error details -eL: list details
BUILD FAILED: Wed Feb 21 20:21:19 2007

Expert Programmation

"interrupt" doit correspondre à une macro, je suppose puisque le nom de la fonction est après.
Il doit certainement te manquer un include, à moins que tu n'ais écrit n'importe quoi car "void interrupt function()" n'est pas du C.
Expert Programmation

Si un code était comme ça, c'est que "interruption" est bien une macro. D'autant plus que c'est une erreur syntaxique.
Donc:
- soit il te manque un "include" d'un fichier qui crée la macro
- soit c'est un compilateur particulier qui fait le préprocessing nécessaire, auquel cas, il te faudrait trouver une option de compilation qui va bien
Lassé par la pub ? Créez un compte
Tom's guide dans le monde