Thanks. the internal pullup seems to be working OK. I set the configuration at programming time, I thought that was sufficient?
Thanks. the internal pullup seems to be working OK. I set the configuration at programming time, I thought that was sufficient?
What if instead of
IF NOT GPIO.1 THEN
You use
IF GPIO.1=0 THEN
? just curious to see if there's any difference
picster
I always find it good practice to set the config bits in the code..
The following turns on an LED on GPIO.0 when GPIO.1 is grounded (external 10K pullup) - Hope it helps
Code:@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON ANSEL = 0 CMCON=7 TRISIO = %101010 LED var GPIO.0 main: IF GPIO.1=0 THEN LED=1 ELSE LED=0 ENDIF goto main:
It may not be the most structured of codes, but this also demonstrates the IF...Then...Else option
I think your original problem was in setting the PIC up as digital and turning off the analogue functions, hence the ANSEL and CMCON settingsCode:@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON ANSEL=0 CMCON=7 TRISIO = %101010 LED var GPIO.0 main: IF GPIO.1=0 THEN goto flash ELSE LED=0 ENDIF goto main: Flash: LED=1 If GPIO.1=1 then main: pause 100 LED=0 pause 100 goto flash:
Wow... I'm only a newbie and I've managed to pass on some advice... maybe my status should change from newbie to novice![]()
![]()
The IF THEN statements compile OK if I comment out the TRISIO line. The error message is: Warning line 15: $111110 numeric overflow. TRISIO never gave me a problem before, what is wrong?
rem device = 12F675
CMCON = 7
ANSEL = 0 'GPIO.0 TO GPIO.3 SET AS DIGITAL
OPTION_REG = 0 'WEAK PULLUPS ENABLED
TRISIO = $111110 'GPIO.0 SET AS OUTPUT, ALL OTHERS INPUT
GPIO = %111110 'PORT GPIO.0 SET LOW INITIALLY
WPU = %110110 'SETS WEAK PULLUP ON DIGITAL INPUTS
rem define variables
time1 var byte: time2 var byte: time4 var byte: time8 var byte
time var word
IF GPIO.1 = 0 THEN
time1 = 1
ELSE
TIME1 = 0
ENDIF
END
Thanks, I should have noticed that!
My program runs now, not quite right yet, but I am getting there.
Excellent... the 12F675 can be a finiky thing to configure right... especially for us newbies![]()
Bookmarks