PBP projects for R/C models


Results 1 to 40 of 772

Threaded View

  1. #13
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    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 .....
    Last edited by ScaleRobotics; - 18th January 2010 at 05:34.

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. PBP Extensions, What are they?
    By PJALM in forum PBP Extensions
    Replies: 9
    Last Post: - 28th September 2021, 11:26
  3. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 19:01
  4. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th December 2005, 23:30
  5. Making PBP code more modular
    By forgie in forum General
    Replies: 30
    Last Post: - 25th October 2005, 16:24

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts