HPWM of the port of two HPWM


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2007
    Location
    japan
    Posts
    2

    Red face HPWM of the port of two HPWM

    questions on two ports was used.
    There is production winkers.
    The operation of HPWM doesn't move normally.
    The operation only of one port is something strange though it seems
    to move.
    The second port doesn't operate.
    The operation of usual HI and LOW is normal.
    I do not understand the cause though it is thought that the part
    related to HPWM is bad because the blinking mode becomes a defective
    operation, too, when changing it from the PWM mode into the blinking mode.
    It buys and it experiments on PIC16F616 that HPWM is a lot of.
    Please teach if there is what becomes some references.

    code:
    'Control of Winkers

    PORTC=0
    TRISC=0
    ADCON0 = 0
    ANSEL = 0

    DEFINE HPWM2_TMR 2

    Duty var byte
    T VAR WORD
    INPA var byte

    IL var PORTA.1
    IR var PORTA.2
    SELSW var PORTA.4

    LEDL VAR PORTC.5
    LEDR VAR PORTC.4

    t=1000

    Start:
    TRISA = %11111111
    INPA = PORTA
    IF INPA=%00000010 then gosub LPWM
    IF INPA=%00000100 THEN GOSUB RPWM
    IF INPA=%00010010 then gosub LPulse
    IF INPA=%00010100 THEN GOSUB RPulse
    ' bit5 modeSW
    goto Start


    LPWM: 'Lch PWMOUT
    for duty =0 to 255 step 2
    hpwm 2,DUTY,1000
    next
    for duty =255 to 0 step -2
    hpwm 2,DUTY,1000
    next
    return

    RPWM: 'Rch PWMOUT
    For duty =0 to 255 step 2
    hpwm 1,DUTY,2000
    next
    for duty =255 to 0 step -2
    hpwm 1,DUTY,2000
    next
    return

    'Lch out HiLow
    LPulse:
    HIGH LEDL
    PAUSE T
    LOW LEDL
    PAUSE T
    return

    'Rch out HiLow
    RPulse:
    HIGH LEDR
    PAUSE T
    LOW LEDR
    PAUSE T
    return

    end
    Last edited by ja2rqk; - 24th April 2007 at 14:39.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ja2rqk View Post
    DEFINE HPWM2_TMR 2
    Should be:
    DEFINE HPWM2_TIMER 2

    You might not get a compiler error, but the compiler will take any DEFINE...such as

    DEFINE THIS_IS_A_LOAD_OF_CRAP 1

    and ignore it if it doesn't apply to anything.

  3. #3
    Join Date
    Apr 2007
    Location
    japan
    Posts
    2


    Did you find this post helpful? Yes | No

    Smile Hpwm 2port 16f616

    Thank you for answering.
    It did not change though the register value related to the setting related to DEFINE or HPWM was reviewed.
    HPWM is difficult though it experimented variously.
    The method of the output to two ports has not been understood simultaneously with one from using the HPWM command in two ports though it came to operate by a usual PWM instruction.
    There is the site that becomes some references or it looks for.
    Even if the manual is seen, it is difficult.
    It operates by the following PWM instruction.
    It is the one to blink the output by PWM or the pulse picking up the winker signal.
    It looks for the reference because two channel output simultaneously has the necessity for using HPWM.

    'Control of Winkers PWM

    PORTC=0
    TRISC=0
    ADCON0 = 0
    ANSEL = 0

    Duty var byte
    T VAR WORD
    INPA var byte

    IL var PORTA.1
    IR var PORTA.2
    SELSW var PORTA.4

    LEDL VAR PORTC.5
    LEDR VAR PORTC.4

    steps VAR WORD
    cycles var Word
    t=1000
    cycles=1

    Start:
    TRISA = %11111111
    INPA = PORTA
    IF INPA=%00000010 then gosub LPWM
    IF INPA=%00000100 THEN GOSUB RPWM
    IF INPA=%00010010 then gosub LPulse
    IF INPA=%00010100 THEN GOSUB RPulse
    ' bit5 modeSW
    goto Start


    'Lch out PWM
    LPWM:
    upL:
    For steps=0 TO 255 step 5
    PWM LEDL,steps,cycles
    Next
    High LEDL
    Pause 100
    downL:
    For steps=255 TO 1 STEP -5
    PWM LEDL,steps,cycles
    Next
    Low LEDL
    Pause 100
    INPA=0
    return

    'Rch out PWM
    RPWM:
    upR:
    For steps=0 TO 255 step 5
    PWM LEDR,steps,cycles
    Next
    High LEDR
    Pause 100
    downR:
    For steps=255 TO 1 STEP -5
    PWM LEDR,steps,cycles
    Next
    Low LEDR
    INPA=0:Pause 100
    return

    'Lch out HiLow
    LPulse:
    HIGH LEDL
    PAUSE T
    LOW LEDL
    PAUSE T
    return

    'Rch out HiLow
    RPulse:
    HIGH LEDR
    PAUSE T
    LOW LEDR
    PAUSE T
    return

    end

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ja2rqk View Post
    ADCON0 = 0
    ANSEL = 0
    Check your 16F616 datasheet concerning these 2 registers and the pins that you are trying to use.

Similar Threads

  1. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27
  2. HPWM down
    By lerameur in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th January 2007, 01:06
  3. PWM problem CCP2 port
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 20th September 2006, 00:34
  4. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 15:14
  5. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 03:43

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