Hi,
Really, is "It's not working" the best description you can come up with?
What's "not working"? What DOES it do? What DOESN'T it do?
In your original post you said PortB.0 and 30seconds, PortB.2 and 1 minute, PortB.3 and 2 minutes.....
Now you're saying PortB.7 and 500ms, PortB.6, 1000ms.... So, no you probably didn't explain your requirements very well.
I've now tried my previously posted code and it works just fine as per your original specifications. I then changed it to match the revised specification, tested it again at it works just fine here. I'll post it here again:
Code:
' Specify delay time in units of 100ms. 10=1second, 25=2.5seconds etc
LED1_Time CON 5 ' 0.5 seconds
LED2_Time CON 10 ' 1 seconds
LED3_Time CON 30 ' 3 seconds
LED1_Count VAR BYTE ' Timekeeping variables
LED2_Count VAR BYTE
LED3_Count VAR BYTE
LED1 VAR PortB.7 ' Pin aliases for the LEDs
LED2 VAR PortB.6
LED3 VAR PortB.5
TRISB = %00011111
Start:
' Preload timekeeping variables
LED1_Count = LED1_Time
LED2_Count = LED2_Time
LED3_Count = LED3_Time
Main:
' Decrement counters
LED1_Count = LED1_Count - 1
LED2_Count = LED2_Count - 1
LED3_Count = LED3_Count - 1
' Time for LED1 to toggle?
IF LED1_Count = 0 THEN
TOGGLE LED1
LED1_Count = LED1_Time ' Reload counter for next period.
ENDIF
'Time for LED2 to toggle?
IF LED2_Count = 0 THEN
TOGGLE LED2
LED2_Count = LED2_Time ' Reload counter for next period.
ENDIF
' Time for LED3 to toggle
IF LED3_Count = 0 THEN
TOGGLE LED3
LED3_Count = LED3_Time ' Reload counter for next period.
ENDIF
PAUSE 100
GOTO Main
Now, I've tested this on another device than what you're using so it's possible that there's something device specific that needs to be set. If you can't get this to work then please describe what it does or doesn't do and post your complete code.
/Henrik.
Bookmarks