PIC16F767 blinking code


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    At last, after two weeks and a new programmer, a 16F767 working blinking code:

    @ DEVICE PIC16F767, INTRC_OSC_NOCLKOUT ; System Clock Options
    @ DEVICE PIC16F767, WDT_ON ; Watchdog Timer
    @ DEVICE PIC16F767, PWRT_ON ; Power-On Timer
    @ DEVICE PIC16F767, MCLR_OFF ; Master Clear Options (Internal)
    @ DEVICE pic16F767, PROTECT_OFF ; Code Protect Off

    OSCCON=%01110000

    main:
    High PORTB.7
    Pause 500

    Low PORTB.7
    Pause 500

    GoTo main
    End

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Hi Daniel,

    Is "DEFINE OSC 8" necessary in this case or not?

    Eventhough you set OSCCON, how does PBP know that it is 8Mhz?

    ------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Because OSCCON=%01110000 sets the internal oscillator to 8Mhz...

    Read the 16F767 datasheet section 4.6.3 for other frequencies...

    PICs makes me love and hate them at the same time....

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    In those situation, you need to take a break and have a cup of coffee
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1118&stc=1&d=116054038 5">
    Attached Images Attached Images  
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by danielhr77
    Because OSCCON=%01110000 sets the internal oscillator to 8Mhz...
    For sure it does set it to 8Mhz but don't we also need to state DEFINE?


    ---------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6


    Did you find this post helpful? Yes | No

    Default

    I don't think so... So far It's working fine...

    I think that DEFINE OSC is for external oscillators only, but not sure...

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    NOPE, DEFINE is a compiler directive and MUST be added at the top of the code. OSCCON is a PIC register that must be set like all the otheres. Let's Say TXSTA, RCSTA, SPBRG.

    Do a simple Test, with your current OSCCON setting do a simple LED blink. use DEFINE OSC 4.. then use DEFINE OSC 8

    what happen?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    NOPE, DEFINE is a compiler directive and MUST be added at the top of the code. OSCCON is a PIC register that must be set like all the otheres. Let's Say TXSTA, RCSTA, SPBRG.

    Do a simple Test, with your current OSCCON setting do a simple LED blink. use DEFINE OSC 4.. then use DEFINE OSC 8

    what happen?

    That is what I thought so.
    Daniel, could you pls test it and post the result?


    -----------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 23:31
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 22:31
  4. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  5. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26

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