phm78
February 3, 2020, 10:11pm
1
Bonjour,
Je viens de perdre 2 jours à comprendre un problème dans mon projet pour m'apercevoir que:
unsigned long a;
a = millis();
ne fonctionne plus après
noInterrupts();
Quelqu'un pourrait il me le confirmer, voir me l'expliquer ?
Merci pour votre support.
Jette un œil ici (ligne 65) :
/*
wiring.c - Partial implementation of the Wiring API for the ATmega8.
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2005-2006 David A. Mellis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
This file has been truncated. show original
La variable timer0_millis est actualisée par une routine d'interruption.
La question qu'il faut te poser est : pourquoi utiliser noInterrupts ?
Ce n'est pas interdit mais il faut avoir une très bonne raison, et en général on le fait pendant un très court laps de temps (comme dans la fonction millis() d'ailleurs: cli()).