At 04:41 AM 3/12/04, you wrote: >but you seem to have got bored with that by the time you got to the Main Loop: > > MOVLW B'11110100' > MOVWF CNT1 > >so I (and perhaps you!) can't see what you're doing there. I think this >is another timing value, but how >long? The 2 delay sections were an inexact attempt to force the interrupt to occur CNT1 * CNT2. I had set timer0 to 255 so it would force the interrupt after 1 tick which I had calculated to .000016 seconds. So I thought I needed to force the interrupt 62500 times to get approximately a second. So I created 2 nested counters. CNT1 loaded with 244 and CNT2 loaded with 256. It didn't turn out as exact as I thought it would be but it worked ok, it runs a little bit faster than 1 second. I have been shown a better way now, to start the timer at 0 and count the rollovers. >You use Binary for all your literals, which in some cases is appropriate, >but in others it would be easier if >you'd used hex or decimal, for example: > > movlw B'00010000' ; RB4 input, all other output (my switch) > MOVWF TRISB > >is right because you're dealing with bits and you can easily see which one >is set, but: > > MOVLW B'11110100' > MOVWF CNT1 > >is hard to read because it's representing a number (of counter-ticks, I >presume) and expressing it in decimal >would make it easier to understand - try decreasing it by 5, and you'll >see what I mean! :-) I keep the windows calculator open while programming (it has a great hex/dec/oct/bin converter) but I see your point and will take your advice. >You are very inconsistent in your use of case, with this being the best >example: > > Rrncf PORTD, 1 ; rotate right port D > CALL Delay > goto loop > >where you've used Proper, UPPER, and lower case for the instructions and >parameters all in three lines :-) >Please pick a style and stick to it - it's much faster to read when it's >all the same. My own "Standard" is >to use UPPER case for the instructions and special registers like ports, >and Proper case for labels and my own >variables, so this is how I would have written it: > > RRNCF PORTD, 1 ; Rotate Right Port D > CALL Delay > GOTO Loop This was the result of copying and pasting 5 different code examples from the PIClist archives and combining them. There are an amazing number of styles. In the future I will examine more closely my style. >Please don't take any of this as personal criticism - I'm trying to help >you write more readable programs, and >(as I used to tell people in my team) almost all programs have much more >time spent reading than writing them, >so saving a few keystrokes as you're writing will cost you, or someone >else, much more later. (I can just >hear my former colleagues groaning: "He's not STILL banging on about >that, is he?" :-) These are the types of comments I was looking for. It will help me to improve my skills and start me off on the right foot. Thank you very much for your time. David Bearrow Dallas, TX, USA -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads