Hey Ken, you can either take the serial out, or change it a bit. Here is one to use a slower baudrate, without using the baudcon.3 setting.
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_SPBRG 64 ' 19200 Baud @ 20MHz, 0.16%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
I use a program from Mister E, called Mister E PIC Multi-Calc that spits all these above settings out after you pic a baud rate. Pretty cool! http://www.picbasic.co.uk/forum/show...9&postcount=38
Sometimes PIC chips can be a pain because the newer chips will move things around on us. So when we try to learn a different chip, or upgrade to a different part, things do not work without a bit of leg work.
I was using a PIC18F2520, which had a register called T0CON for adjusting the Timer0 or TMR0. That sounds like it makes sense. However, on the PIC16F887 that you are using, the same Timer0 TMR0 is adjusted by using .... the Option Register. Not quite making as much sense, is it.
Anyway.... HOW do I know this? Answer: I do not. I have to look up both data sheets for each of those pic chips, and compare them. Not all 375 pages, but just whatever portions I think are giving me trouble. In this case, the Timer0. Then I have to see that everything that is set in the PIC18F2520 for the timer, is set for the PIC16F887. Then I will probably have to do the same thing for the other timers. AND, it will probably not work when I first try it, because I will probably miss something.
So, looking at page 77 of your data sheet, and page 125 of my data sheet, lets see what we can screw up, I mean "test".
Well I had it set to:
TMR0ON - off
T08Bit - configured as a 16 bit timer (this could be a problem)
T0CS - Internal instruction cycle clock
T0SE - increment on low to high transition of clock pin
PSA - use prescaler selection bits
T0PS - 1:4 prescaler selection bits
Now lets see what we have for the Option register...
Well, looking at the data sheet, your chip's T0 is only 8 bit, but if we are lucky, we will just have lower resolution. Timer0 is the time base for creating a servo pulse out from 1 to 2 ms.
Option_Reg
RBPU - Port B pull ups (nothing to do with timer) probably leave off - 1
INTEDG - Nothing to do with timer
T0CS - keep at 0 like above
T0SE - keep at 0 like above
PSA - keep at 0 like above
PS - we can start at 001 like above, but we might have to change things up since this
is not a 16 bit timer.....If I was smarter about how these worked, I could mathematically figure this out.....
Now, how do we start this timer0, because it looks like bit 7 is NOT going to do this for us...
To be continued .....
Bookmarks