HPWM on a 628 is not changing freq.


Closed Thread
Results 1 to 3 of 3
  1. #1
    dtit's Avatar
    dtit Guest

    Default HPWM on a 628 is not changing freq.

    I tried differnent settings, but when i put a scope on it's allways 1ms freq.
    snip:
    @ DEVICE HS_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
    DEFINE OSC 20
    CMCON = 7
    VRCON = 0
    TRISB = %00000000
    PR2 = 130 ' 38KHz
    CCPR1L = 63 ' 50%
    CCP1CON = %00001100 ' Mode PWM
    T2CON = %00000100 ' Timer2 ON + 1:1 prescale

    Allsow tried:
    @ DEVICE XT_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
    DEFINE OSC 4
    CMCON = 7
    VRCON = 0
    TRISB = %00000000
    PR2 = 25 ' 38KHz
    CCPR1L = 13 ' 50%
    CCP1CON = %00001100 ' Mode PWM
    T2CON = %00000100 ' Timer2 ON + 1:1 prescale

    Hardware: 22pF on crystal, 1uF between Vss&Vdd = Vdd 5V Ok

    But the freq is not changing from 1ms wathever PR2,CCPR1L i tried
    Has anyone experied this problem?

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


    Did you find this post helpful? Yes | No

    Default

    do you want to change frequency or duty cycle?

    do you want to change frequency or duty while your program's runing?

    what about if you enable watch dog timer???

    BTW at 38KHZ, If i refer to PIC16F628's datasheet :
    @ 20Mhz,38KHZ 50% duty cycle:
    period = 2.63 uSec
    duty = 512
    Code:
    PR2 = 130
    CCP1CON = %00001100 ' 2 LSB of 512 at bit 5 & 4
                        ' PWM mode bit 3 & 2
    
    CCPR1L = 128 ' 8 MSB of 512 
    TRISB=0
    T2CON = %00000100 ' set timer2 prescaller to 1:1
    what about now...
    Steve

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

  3. #3
    dtit's Avatar
    dtit Guest


    Did you find this post helpful? Yes | No

    Default did make some changes

    thanks mister_e fore your concern

    The only thing i tried to do is get a 38.5Khz to drive a IRled array, wanted a duty at max 50% tough gona overdrive them a little.
    With the trusth in your tips, i stripped down my setup to a minimum and start testing. (hard decision)
    Did found two broken 628 and some bad cable connection. One did just put out 1V on ccp1 when a scoped it.
    Yes i got to work, but figured out that your suggestion of CCPR1L = 128 equals a duty very high. Tested with 63 and get a 50/50. After two late night a have learn me a lesson to keep testboard small and tidy. When expanding, make circuit board and solder down your stuff. Afterwords use board again. It's very time costing to have right code and wrong in hardware setup.
    Thanks to you I have new way of thinking

Similar Threads

  1. Maximum HPWM freq. 12F683
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th August 2008, 15:55
  2. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  3. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43
  4. Changing Freq of HPWM
    By Rayneobid in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 12th April 2005, 18:55
  5. HPWM min freq ?
    By swordman in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 6th September 2004, 14:41

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