Hi,
Who could explain me that ???
This simple program is a flip-flop with button debouncing ... simple, eh !
( Button1 is on the low side - LOW level if pushed )
When using MCLR ... output ( GPIO.2) is LOW at power-up ... Ok
When disabling MCLR ( internal reset ) ... output is HIGH at power-up ... ???
Instead to what it should be !!!
Did I miss something ???
AlainCode:' Madproject ' 'Anti rebond pour sauter à la perche ( ??? ) ' ' 16F629 mode INTOSC @ 4 Mhz ' ' le 03/09/2009 139 Lignes '****************************************************************************** '****************************************************************************** '****************************************************************************** ' CONFIG '****************************************************************************** @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _BODEN_ON DEFINE OSC 4 DEFINE OSCCAL_1K 1 DEFINE BUTTON_PAUSE 100 ADCON0 = 0 ANSEL = 0 CMCON = 7 VRCON = 0 OPTION_REG.5 = 0 OPTION_REG.7 = 1 'Disable Pull-Ups Bouton1 VAR GPIO.0 Bouton2 VAR GPIO.1 Sortie VAR GPIO.2 'LedVisu VAR GPIO.3 ' Attention : Sortie PIC en C/O !!! LedVisu VAR GPIO.4 'set VAR GPIO.5 x VAR byte Delay VAR byte GPIO = %00000011 'All pins LOW IF outputted - no startup bug. TRISIO = %00000011 'set GPIO.0 & GPIO.1 as inputs Others Output '****************************************************************************** Attente: ' On attend !!! '****************************************************************************** Delay = 0 BUTTON Bouton1,0,255,0,Delay,1,Action ' Poussoir à la masse enfoncé PAUSE 10 ' 10 ms entre scans GOTO Attente ' Non? : retour départ '****************************************************************************** Action: ' On a enfoncé le bouton plus de 100 ms '****************************************************************************** TOGGLE Sortie ' On inverse la sortie TOGGLE LedVisu '****************************************************************************** Attente2: ' On attend que le bouton soit relâché ... '****************************************************************************** Delay = 0 BUTTON Bouton1,1,255,0,Delay,1,Attente ' Le bouton est il relaché ??? ' GOTO Attente2 ' NON On boucle '****************************************************************************** END





Bookmarks