+ Reply to Thread
Results 1 to 10 of 10

Thread: pic16f876 20mhz resonator

  1. #1
    Licensed User n.mirzai's Avatar
    Join Date
    Apr 2005
    Location
    uk
    Posts
    13

    Default pic16f876 20mhz resonator

    Can anyone help
    I am using PIC16F876 20 MHZ chip, it works with 8MHZ resonator but not with 20MHZ, your help is apperciated

    Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?

    Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE

    Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS




  2. If you're a Licensed user of PROTON DEVELOPMENT SUITE, apply for Licensed User Status to remove these pesky messages
     and get access to additional forum areas, Beta test downloads and more!

  3. #2
    Licensed User captainslarty's Avatar
    Join Date
    Sep 2006
    Location
    A Marina in Portugal
    Posts
    3,064


    Default Re: pic16f876 20mhz resonator

    Hi Sir,
    resonator or xtal ?
    also sample code for setup would be appreciated.then maybe someone can help.
    Joe
    Civilisation is the limitless mutiplication of unecessary necessities ... (Mark Twain)

  4. #3
    Licensed User n.mirzai's Avatar
    Join Date
    Apr 2005
    Location
    uk
    Posts
    13


    Default Re: pic16f876 20mhz resonator

    hi,
    Thanks for your help. as I said it works with 8MHZ but not with 20MHZ, ucontroller is 20MHZ device.
    using resonator:
    sample code:

    Device = 16F876
    XTAL = 20
    ALL_DIGITAL = TRUE ' Set PORTA to all digital for optical use only

    TRISB = %00011111 ' PortB RSIN, B2,B3,enb
    TRISC = %00000000 ' PortC as output to LCD
    TRISA = %011111 'port A.0 A.1 A.2 A.3 A.4 as input A.5 output
    ' Graphic LCD pin Assignments
    Declare LCD_DTPORT PORTC 'portC is used for LCD data
    Declare LCD_ENPIN PORTB.3 'Enable LCD
    Declare LCD_RSPIN PORTB.2 'RS for LCD
    Declare LCD_INTERFACE 8 '8Bit system lcd
    LCD_LINES = 2 'four line display
    LCD_TYPE = 0

    DelayMS 300 ' device to settle down
    ' Define program variables

    Dim ratio As Byte
    Dim inpulse As Byte
    '*********** Start **********
    ratio = 0
    inpulse =0
    main:
    GoSub setratio
    Print At 1,1,"Freq Divider"
    Print At 2,1, "Ratio = ",@ratio

    start:
    If PORTB.1 &1<>1 Then GoTo start
    start1:
    If PORTB.1 &1<>1 Then GoTo start1
    checkagain:
    If PORTB.1 &1=1 Then GoTo checkagain
    inpulse =inpulse +1
    If inpulse<ratio Then GoTo start1
    High PORTB.5
    DelayUS 1 ' to be decided by user soon
    Low PORTB.5
    inpulse =0
    GoTo start1
    '**** Set ratio ******
    setratio:
    Cls
    Print At 1, 1, "Set Ratio "
    Print At 2, 1, " OK"
    '********* ok acknowledged here **********
    GoSub okbut:
    '********************* Inc ratio ***********************
    increst:
    Cls
    ratio = ratio + 1
    If ratio>250 Then ratio=1

    Print At 1, 1, " Ratio = ", @ratio
    Print At 2, 1, " OK OR INC"
    If PORTB.0 &1 =1 Then GoSub incbut
    DelayMS 70
    If PORTB.4 &1=1 Then GoSub okbut
    final:
    If PORTB.0 &1 = 1 Then GoTo increst
    DelayMS 70
    If PORTB.4 &1 <> 1 Then GoTo final:
    GoSub okbut
    DelayMS 50
    Cls
    Return ' return for setratio

    '**************** Inc But ************************
    incbut:
    If PORTB.0 &1 <> 1 Then GoTo incbut
    DelayMS 70
    inc2:
    If PORTB.0 &1 = 1 Then GoTo inc2
    DelayMS 70
    If PORTB.0 &1 = 1 Then GoTo inc2
    DelayMS 70
    Return
    ' **************** OK BUT ************************
    okbut:
    If PORTB.4 &1 <> 1 Then GoTo okbut
    DelayMS 80 'Debounce
    okbut1:
    If PORTB.4 &1 = 1 Then GoTo okbut1:
    DelayMS 80
    If PORTB.4 &1 = 1 Then GoTo okbut1:
    DelayMS 80
    Return

  5. #4
    Licensed User captainslarty's Avatar
    Join Date
    Sep 2006
    Location
    A Marina in Portugal
    Posts
    3,064


    Default Re: pic16f876 20mhz resonator

    Hello N.Mirzai
    you need to set the config fuses.
    Download Fuse configurator from wiki - also check the datasheet for fuse (config) values -
    Joe
    Civilisation is the limitless mutiplication of unecessary necessities ... (Mark Twain)

  6. #5
    Licensed User n.mirzai's Avatar
    Join Date
    Apr 2005
    Location
    uk
    Posts
    13


    Default Re: pic16f876 20mhz resonator

    Hello,
    I tried wiki , could not down load as asking for user name /password. I tried my proton forum's user name /password did not accept. how do i register for downlaod .
    Thanks

  7. #6
    Licensed User teo's Avatar
    Join Date
    Sep 2010
    Location
    Bucharest, Romania
    Posts
    43


    Default Re: pic16f876 20mhz resonator

    username : protonuser
    password : forumfiles
    Teo

  8. #7
    Licensed User n.mirzai's Avatar
    Join Date
    Apr 2005
    Location
    uk
    Posts
    13


    Default Re: pic16f876 20mhz resonator

    Thanks i will try it.

  9. #8
    Licensed User n.mirzai's Avatar
    Join Date
    Apr 2005
    Location
    uk
    Posts
    13


    Default Re: pic16f876 20mhz resonator

    Hi I tried it and it added this:
    Config CP_OFF, DEBUG_OFF, WRT_ENABLE_ON, CPD_OFF, LVP_OFF, BODEN_OFF, PWRTE_OFF, WDT_OFF, XT_OSC
    to my program when selected the microcontoller, still the same.no charactor on the display,
    any advice ? thanks

  10. #9
    Licensed User pic-ignorant's Avatar
    Join Date
    Oct 2007
    Location
    Sunny Kent
    Posts
    2,125


    Default Re: pic16f876 20mhz resonator

    Try changing XT_OSC to HS_OSC

    John

  11. #10
    Licensed User n.mirzai's Avatar
    Join Date
    Apr 2005
    Location
    uk
    Posts
    13


    Default Re: pic16f876 20mhz resonator

    Thanks for your help, I am using resonator rather than xtal , as I said it works with 8mhz not 20, pic is 20mhz decice.
    I have:
    Config HS_OSC,WDT_ON,PWRTE_ON,BODEN_ON,LVP_OFF still not working,
    any idea.
    Thanks

+ Reply to Thread

Similar Threads

  1. sms send sht11 pic16f876 nokia 6210
    By elektro2009 in forum GSM / SMS
    Replies: 13
    Last Post: 25th April 2012, 17:01
  2. Interfacing GPS receiver module with PIC16F876
    By dongol4u in forum GSM / SMS
    Replies: 3
    Last Post: 9th July 2008, 10:15
  3. Resonator, crystal or oscillator for USB PIC?
    By Don Stratton in forum The Lounge
    Replies: 6
    Last Post: 26th July 2007, 22:16
  4. Using 20MHz Xtal
    By PortlandJohn in forum The Lounge
    Replies: 5
    Last Post: 10th May 2005, 08:06

Members who have read this thread since 2nd May 2012, 19:39 : 0

Actions :  (Set Date)  (Clear Date)

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