Yes, this is not a major issue for code that is, let's say as an example, in the startup coe that only is run one at each power on anyway. Code readability and clarity is far mor importent in that case. > It also sounds like the compiler will actually generate > better code if I use the whole register. Yes, that will always be s simple 8 bit "load". Three instruction maximum (bank switch, MOVLW and MOVWF). Four on the (old) 684, the bankswitch takes two. :-) > I prefer binary over either hexadecimal or decimal > for setting the bits on a port. Right, for registers that hold a "value" (such as an timer register for example) the format (hex/bin/dec) is of less importance. Many times a decimal value can make the code easier to read such as when setting a timer to "one hundred and twenty three". Decimal (123) is easier to read then hex (7B). For registers where the individual bits has different functions (such as INTCON or similar) I prefer binary. That makes it easier to read out the bit settings. > Why is there a setting for the starting point of the counter in > both the Interrupt handler function and in the InitTimer function? I do not have the code in front of me, but I'd expect anything with "init" in its name to only run once at startup. So InitTimer run once at power on and setup the basic timer stuff. The ISR then sets whatever has to be set at each interrupt, such as reloading the timer value (if not freerunning). B.t.w, *if* one can find a setup where you get a usable "timing" while letting the timer fre-run (that is, without ever re-loading the timer value), it is often easier to get a consistent overall timing in the application without having to bother about specific adjustments for some extra instructions here and there. This can sometimes need a carefull selection of the crystal frequency. And that is also why there are all those "odd" crystal values... :-) Here is a good overview of crystal frequencies: http://en.wikipedia.org/wiki/Crystal_oscillator_frequencies Jan-Erik. Richard R. Pope wrote 2014-07-23 12:28: > Jan_Erik, > I'm not going to worry about the individual bits at this point. It > also sounds like the compiler will actually generate better code if I > use the whole register. I am also using the free version and my > understanding is that the paid for pro version generates better code. At > this point I am using 8.7% of the program space and 21.1% of the data > space. So I still have plenty of room left. > I have my 684 prototype board built. The program runs. The 684 chip > I have won't run at 20MHz so I changed the code to use 4MHz. No, I can't > read the printing on the chip. So I can't tell if it is a 4 or 20MHz > unit. I was trying to figure out how to use binary. I was trying to > use b'xxxxxxxx' were x are the individual bits. You showed me that the > format is 0bxxxxxxxx. I prefer binary over either hexadecimal or decimal > for setting the bits on a port. > David's hint about using the CTRL+Space for a drop down list is gre= at. > Why is there a setting for the starting point of the counter in > both the Interrupt handler function and in the InitTimer function? This > code came from the MicroElektronika timer calculator. I just used the > code and changed a few variable descriptors that weren't compatible with > the XC8 compiler. > Thanks, > rich! > > On 7/23/2014 4:37 AM, Jan-Erik Soderholm wrote: >> James Cameron wrote 2014-07-23 04:20: >> >>>> T1CONbits.T1GINC =3D 0; >>>> T1CONbits.TMR1GE =3D 0; >>>> T1CONbits.T1CKPS =3D 0b11; >>>> T1CONbits.T1OSCEN =3D 0; >>>> T1CONbits.T1SYNC =3D 0; >>>> T1CONbits.TMR1CS =3D 0; >>>> T1CONbits.TMR1ON =3D 1; >>> Yes, I guessed that both were possible, and for multiple bit fields >>> there is some advantage, but apart from that is there any other reason >>> for using the longer form over the shorter form? >>> >> > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .