2 PWM in 16F690 problems


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Aug 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Hi.

    Did you get anywhere with the PWM code for the 18F1330?

    I don't think that you can use HPWM with this device as it's PWM module is completely different to the normal PWM module found in 16F chips. It requires many registers to be set manually.

    Am currently working on this, but experiencing problems...

    Andy

  2. #2
    Join Date
    Apr 2008
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Working with 18F1330 PWM

    You have to acces direct to the registers, and configure the internal OSC to work with it..
    The pwm duty cycle works with 14 bits, so you have to write directly the value on the PDC0L register for the less significant bits and the PDC0H for the more significant bits of the PWM 0 channel..

    I hope these can help you, if you download the datasheet you will understand more the code that I wrote.. These is part of the code of my program:

    OSCCON.6 = 1 'configure the internal oscilator to work at 4 MHz
    OSCCON.5 = 1
    OSCCON.4 = 0
    OSCCON.1 = 1

    PTCON0 = $00 ' configure frequency and the PWM sets
    PTCON1 = $C0
    PWMCON0 = $37
    PWMCON1 = 0
    PTPERL = $AA
    PTPERH = $01

    PDC0L = $FF ' Set the duty cycle for PWM 0
    PDC0H = $00
    PDC1L = $FF ' Set the duty cycle for PWM 1
    PDC1H = $01

  3. #3
    Join Date
    Aug 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Hi, thanks for the reply.. I got it working in the end.

    The thing that I was doing wrong was having a larger duty cycle value in PDC0L and PDC0H than the value in PTPERL and PTPERH. Since the PWM module counts upwards until it reaches the duty cycle value, and then continues to count upwards to the end of the frequency cycle as determined by the values in PTPERx registers, PDCxx must be lower than PTPERx.

    Thanks again,

    Andy

Similar Threads

  1. 12F683 2 x PWM Outputs
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 23rd July 2021, 20:20
  2. 16f877 generate pwm according 2 analog input
    By madxice in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 9th July 2009, 14:47
  3. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Variable PWM on 2 Channels using software.
    By Tissy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd September 2006, 01:34

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