Very first use of PBP (newbie!)


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Default A few things are wrong here

    Rich,

    "define osc 8" Is NOT changing oscillator frequency, It's just telling PBP at which frequency the oscillator is running. And most important, all defines must be in UPPERCASE when using PBP. Not 100% sure if required, but I would also try writing PORTB.0 uppercase.

    BobK is right too, try adding define TRISB = %00000000. I don't exactly remember why, but I had some problem a while ago using high and low without having defined the port as an output, (but PORTB.0=1 was working fine!)

    Picaxe is fantastic to learn PIC, but is missing all details related with PIC registers. When you're programming with PBP you have to read and understand the datasheet of the chip you're using. Then you will be able enjoy PBP and use all the flexibility of you're PIC.

    J-P
    Last edited by GrandPa; - 15th September 2007 at 19:41.

  2. #2
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Fixed it

    Hi all,

    thanks for your help everyone. It ended up being the setting of ANSEL and ANSELH. I added the ANSEL line and portb.0 started working. So I tried to alternate all portb pins between low and high in same block of code. Then the portb.0 through portb.5 pins didn't work but portb6 and 7 did. So I added ANSELH=0 and then they all started working.

    I have learnt something. Read and understand the datasheet. This is my first experience of translating the datasheet into programming registers and now I know how important it is. It's not a PICAXE!!

    So if DEFINE OSC 8 doesn't change internal osc freq, what does I wonder. I am of course, not using an external osc and the chip supports 8mhz. I will read datasheet and see if I can work it out but if I haven't posted back here by the time someone sees this, please enlighten me!

    Thanks again guys

    Rich

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Check out page 64 of the datasheet. It will tell you how to set the internal oscillator frequency.

    To set the oscillator to 8Mhz for example:

    Code:
    define osc 8
    OSCON=%01110000
    or 4Mhz:

    Code:
    define osc 4
    OSCON=%01100000
    *edit* Page 64 according to adobe anyway - page 62 according to the page numbers at the bottom of the pages.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Rich,
    You picked a PIC with lots of options that differ from run of the mill, Multi config registers and the like. Hard to learn to drive in a performance car, maybe start out with a Rambler or a Fiat check your other post for answers.
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Cool guys, very cool. I now understand how to use the registers a lot better. Setting the osc freq makes perfect sense!

    I am using the 16f886 because I used to do a lot with Picaxe and it is the chip that the 28x1 Picaxe chip is based on. I have a few of them so I am reusing.

    When I was young I used to do lots of handbrake turns and all sorts of crazy stuff. Whilst I'm sure I am lucky to still be alive, I really believe it has made me a better driver!

    Thanks again

    Rich

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. PBP, ASM and LST files
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th January 2010, 13:43
  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. PBP / XP Crash
    By pondindustrial in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th November 2005, 03:16

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