generate 38 KHz help


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326

    Default generate 38 KHz help

    Good day to all in this forum,
    I have a pic18f252 witha a 10 Mhz XTAL an d a X4 PLL multiplier that gives 40 MHz clock speed.
    I need to generate 38 KHZ to control some IR devices.
    How to do that please ?
    Thanks
    regards,
    Ambrogio

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: generate 38 KHz help

    One way is to use HPWM, here is an example.

    http://www.picbasic.co.uk/forum/showthread.php?t=20921

  3. #3
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: generate 38 KHz help

    Thanks a lot for the kind assistance: HPWM works very well.

    I also follow the indicated links and I found this code:

    TRISC.2 = 0 ' CCP1 (PortC.2 = Output)
    PR2 = 25 ' Set PWM Period for approximately 38KHz
    CCPR1L = 13 ' Set PWM Duty-Cycle to 50%
    CCP1CON = %00001100 ' Mode select = PWM
    T2CON = %00000100 ' Timer2 ON + 1:1 prescale

    Question: Why I do have a frequency equivalent to 10 times 38 KHz ( about 384 KHz ! ) ?
    I did declare osc= 40 Mhz too.

    Thanks for any clarification,
    regards,
    Ambrogio

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: generate 38 KHz help

    I believe the example was for 4 or 8mhz oscillator. You need to adjust PR2 and CCCPR1L for your 40Mhz clock.

    Try this calculator
    http://www.micro-examples.com/public...alculator.html
    Last edited by mark_s; - 9th May 2017 at 00:20.

  5. #5
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: generate 38 KHz help

    thanks Mark_s,
    the suggeted calculator is very OK !
    Bye,
    Ambro

Similar Threads

  1. DEFINE OSC for 31 khz
    By gunayburak in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2015, 00:23
  2. 1 KHz Sine Wave
    By Art in forum General
    Replies: 12
    Last Post: - 29th December 2013, 09:58
  3. 40 KHz burst
    By aherrera in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 25th November 2009, 22:36
  4. 40 kHz wave
    By RUBiksCUbe in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 14th December 2005, 20:01
  5. Catching 12 khz
    By SuB-ZeRo in forum Schematics
    Replies: 4
    Last Post: - 15th June 2005, 07:11

Members who have read this thread : 1

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