PWM configuration


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Location
    CA
    Posts
    78

    Default PWM configuration

    hello everyone,

    I am using the 16F77 with a 20Mhz crystal, I have tried the software PWM multiple times and and a bit dissatisfied because I cannot do anything else while I am in the PWM loop. What I want to do is have the PWM going in the background, but I do not want to use the HPWM option I have with PBP. but instead want to just set the appropriate registers myself. I was wondering if someone is willing to help me.

    here is what I have so far. I have read the CHIP's manual and here is what it recommend I do.
    1)Set the PWM period by wrigint to the PR2 register.
    2)Set the PWM duty cycle b writing to the CCPR1L register and CCP1CON <5:4>
    3)Make the CCP1 pin an output by clearing the TRISC<2> bit
    4) Set the TMR2 prescalar value and enable Timer2 by writing to T2CON
    5)Configure the CCP1 module for PWM operation.


    Since I wanted to generate a signal around roughly 1khz and have the duty run from 0 to 100% .

    I have the following at the top of my code

    PR2 = %11111111 'equivalent to 0xFF for 1.22khz at 20Mhz
    CCP1CON = %00110000
    TRISC = %00000000
    T2CON = %00000111 'starts timer and set prescalar to 16


    I am not sure if this is all that is required to start the PWM function for this PIC microcontroller. Again I do not want to use the HPWM that is readily available to me by PBP.

    Please, Any help with this would be greatly appreciated. Thank you.


    srigopal

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


    Did you find this post helpful? Yes | No

    Default

    Steve

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

Similar Threads

  1. Half-bridge PWM with a 16F684 ?
    By Byte_Butcher in forum General
    Replies: 7
    Last Post: - 17th January 2010, 22:18
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. PWM: Vernacular/Function (Newbee)
    By TerryN in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd July 2008, 16:58
  4. PWM setting PIC16F887
    By Gevo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th June 2008, 07:24
  5. Tidying Up PWM Routine
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st February 2005, 00: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