Hwpw


Results 1 to 2 of 2

Thread: Hwpw

Threaded View

  1. #1
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    156

    Question Hwpw

    Im running a few chips 16f876a at 20 mhz, 18f26k22 10mhz with 4x speed so 40mhz

    Even using timer 1 and timer 2 with two different ports, portc1 and portc2 you can not get two different PW is this correct

    I have also noticed at times one pulse is half the duty cycle other times it can be changed this could be because i used the same timer for both

    define OSC 40

    OSCCON2.7 = 1 ' SYSTEM CLOCK 1=4XPLL 0= OSCILLATOR OTHER THAN 4XPLL
    TRISA = %11111010
    TRISB = %11111100
    ADCON1 = %0110
    ADCON0 = %000

    T0CON = %00000000
    INTCON = %00000000
    INTCON2 = %00000000

    LED VAR PORTA.5 ' Assign name "LED" to PORTA.5
    HIGH LED
    PAUSE 2000
    LOW led
    PWM PORTA.5, 64, 6000

    DEFINE CCP1_REG PORTC ' USED FOR HWPW
    DEFINE CCP1_BIT 2 ' USED FOR HWPW PORTC PIN 2
    DEFINE HPWM2_TIMER1 ' DEFINE TIMER USE FOR PWM

    DEFINE CCP2_REG PORTC ' USED FOR HWPW
    DEFINE CCP2_BIT 1 ' USED FOR HWPW PORTC PIN 1
    DEFINE HPWM1_TIMER2 ' DEFINE TIMER USE FOR PWM

    HPWM 1, 128, 5000 ' OUTPUT PORTC.2
    'HPWM 2, 64, 5000 ' OUTPUT PORTC.1

    ' HPWM 1, 128, 39000 ' HIGHEST HPWM @ 50% DUTY 78.06 khz
    ' HPWM 1, 128, 30000 ' HPWM @ 50% DUTY 60.19 khz
    ' HPWM 1, 128, 20000 ' HPWM @ 50% DUTY 39.96 khz
    ' HPWM 1, 128, 10000 ' HPWM @ 50% DUTY 19.98 khz
    ' HPWM 1, 128, 5000 ' HPWM @ 50% DUTY 9.99 khz
    ' HPWM 1, 128, 2441 ' LOWEST HPWM @ 50% DUTY 4.88 khz
    Last edited by l_gaminde; - 20th June 2025 at 17:30.

Members who have read this thread : 5

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