Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
fr:avr:interrupts [2010/03/19 11:00] – créée sdeniaudfr:avr:interrupts [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 20: Line 20:
 </box> </box>
  
-Global allowing of all interrupts is configured from the control and status register SREG. The option to allow or disallow all interrupts at once is there to help protect dataSince interrupts disrupt the execution of the main programsome data used by the main program may be disturbed or corrupted in the processSituations like this can be avoided by simply disallowing all interrupts before dealing with such delicate dataDisallowing interrupts globally is easyif it can be done by changing only one register (SREG). After the critical part of the program has been executedthe interrupts can easily be allowed again and all the interrupts that would have fired in the meanwhile will get executed.+Globalement on utilise les interruptions pour contrôler le registre SREG. L'option pour permettre ou interrompre toutes les interruptions est là pour aider à protéger les donnéesPuisque l'interruption perturbent l'exécution du programme principalquelques données utilisées selon le programme principal peuvent être dérangées ou corrompues dans le processusLes situations comme cela peuvent être évitées en rejetant simplement toute interruption avant de traiter avec de telles données délicatesRejeter une interruption est assez facilecela peut être réalisé en changeant simplement un registre (SREG). Après l'exécution la partie critique du programmel'interruption peut facilement être admise de nouveau et toute interruption dont on aurait besoin pourrait alors être exécutée.
  
-~~PB~~+<pagebreak>
  
 <box 100% round #EEEEEE|Exemple> <box 100% round #EEEEEE|Exemple>
  
-Let's suppose there is a 16-bit variable in use in the programwhich is changed by both the main program and the interrupt program and the value of this variable is later given to another variable:+Supposons que nous utilisons une variable de 16 bits dans le programmecette variable peut à la fois être modifiée par le programme principal ou par l'interruption. La valeur de la variable et ensuite affectée à une seconde variable:
  
 <code c> <code c>
Line 53: Line 53:
 </code> </code>
  
-The program itself is very simple - first, variable x is given a value of 0x1111 and laterits value is given to variable y. If an interrupt fires between those two operations, x gets a value of 0x3333. By logic, variable y can have two possible values by the end of the programbut on an 8-bit AVR there is also a third option. This is because 8-bit architecture needs 2 cycles to move 16-bit data and therefore a badly-timed interrupt can corrupt the integrity of the dataConsequentlyy can have a value of 0x1111 or 0x3333, but it can also have a value of 0x3311 at the end of the programTo avoid getting the third, unwanted valueall interrupts should be temporarily disallowed before performing operations that take more than 1 cycle.+Le programme en lui-même est assez simple - dans un premier temps on affecte la valeur 0x1111 à la variable x, puis cette valeur est affectée à la variable y. Si l'interruption est exécutée entre ces deux opérationsla valeur de change et prend la valeur de 0x3333. Logiquementla variable y pourrait avoir deux valeurs possibles à la fin du programmemais avec un AVR bits il existe une troisième option. Tout cela parce que l'architecture en bits nécessite 2 cycles pour affecter une donnée de 16 bits et par conséquent une interruption mal tombée pourrait corrompre l'intégrité de la valeur de la variableEn conséquenceon peut obtenir les valeurs de 0x1111 ou de 0x3333, mais on peut aussi à la fin du programme obtenir la valeur de 0x3311. Pour éviter d'avoir cette troisième valeurtoutes les interruptions doivent être temporairement désactivées afin de réaliser les opérations qui nécessitent plus d'un cycle.
  
-In the following examplethe value of is given to using a safe method:+Dans l'exemple suivantla valeur de la variable est affectée à la variable en utilisant la méthode de sauvegarde de donnée:
  
 <code c> <code c>
fr/avr/interrupts.1268996417.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0