| |
wlfk Veteran Location: uk
| This bit seems fine.
Delay200 clrf DelayL ; clear DelayL to 0 clrf DelayM ; clear DelayM to 0 movlw 1H ; set DelayH to 3 - ? set delayh to 1, surely?! movlw 1 movwf DelayH Wait1 decfsz DelayL, f ; subtract 1 from DelayL my compiler gpasm would give me a warning for not specifying to decrement the memory address rather than register w. But it would do the right thing anyway goto Wait1 ; if not 0, goto Wait1 decfsz DelayM, f ; subtract 1 from DelayM goto Wait1 ; if not 0, goto Wait1 decfsz DelayH, f ; subtract 1 from DelayH goto Wait1 ; if not 0, goto Wait1 return ; finished the delay
My personal feeling is that most of your comments are redundant. They're simply explaining what the instructions do, and as you learn to program you won't need them. A problem in this part shouldn't cause an LED to fail to light anyway - if it hangs then the LED will simply stay lit forever.
I would try to 'watch' the values in DelayL and DelayM - they should decrement. The problem is probably simply that this bit will take zillions of cycles on the simulator, which will seem to take forever, but in real life it will execute rather quickly - 3 instructions per loop; 65536 loops - 1/5 second or thereabouts.
Some debate over whether you're wasting time for 200 or 500mS
The rest of the program looks broadly OK to me, though bugs aren't always evident and I don't use the 84 much.
I would tend to add a 'goto $' after I'd tried to light the first LED, then use a voltmeter to check the pin. Are you sure the hardware side of things is working OK?
Personally, if you're using 5 LEDs or fewer, I'd use a 12F629 as you can get away without any external components for the clock.
K
A bit like a kite, but 500 times more expensive |
| 03-20-2008 02:45 PM | | | |