Here, this chaser works with the hardware you are using:
MPASM required, you must comment out the config in the .inc file for 16f690 in PBP root.
Code:
@MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON
@MyConfig = MyConfig & _MCLRE_ON & _BOR_OFF
@ __config MyConfig
DEFINE OSC 4
PortA = 0
PortB = 0
PortC = 0
TRISA = 0
TRISB = 0
TRISC = 0
i var byte
main:
portc = 0
pause 500
for i = 1 to 15; step -1
portC = i
i=i << 1
pause 250
next i
goto main
end
Here's a blinkey:
Code:
DEFINE OSC 4
PortA = 0
PortB = 0
PortC = 0
TRISA = 0
TRISB = 0
TRISC = 0
LED_1 var PortC.0 ' Define an alias in the program
led_1 = 0
Main:
HIGH LED_1
PAUSE 1000
LOW LED_1
PAUSE 1000
Goto Main ' Loop forever
end
OK here is your code reworked:
Code:
DEFINE OSC 4
LED_1 VAR BIT ' PORT FLAG BIT
LED_1 = 0 ' SET INITIAL VALUE
TRISC.0 = 0 ' Make PORTC.0 an output
Main:
IF LED_1 = 0 THEN
LED_1=1
ELSE
LED_1 = 0
ENDIF
PORTC.0 = LED_1
PAUSE 250 ' Delay for 1 second (compiler errors with this line - I guess the command isn't right!)
Goto Main ' Loop forever
It appears as though the PIC cannot read and change it's own output without an intermediary like a flag variable. Probably
A RMW thing, I do not know.
Bookmarks