16 bit PWM using CCP1


Closed Thread
Results 1 to 40 of 61

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: 16 bit PWM using CCP1

    I didn't pickup what ver of pbp talat was using , and I'm not sure if the chk?rp macro exists in early versions


    but try
    Code:
    Asm
    PWM_INT
    CHK?RP   CCP1CON
    movlw 9 ; compare mode
    clrf CCP1CON ; clear reg
    movwf CCP1CON ; Set reg
    CHK?RP  PWM_VAL
    movf PWM_VAL+1,W ; hb
    CHK?RP   CCPRIL
    movwf CCPR1H ; put
    CHK?RP  PWM_VAL
    movf PWM_VAL,W ; lb
    CHK?RP   CCPRIL
    movwf CCPR1L ; put
    banksel 0
    bsf INTCON,7 ;GIE = 1
    bsf INTCON,6 ;PEIE = 1 Enable peripheral interrupts
    bsf PIE1,0 ; TMR1IE= 1 Enable TMR1
    bcf PIR1,0 ; TMR1IF = 0 Clear Timer1 Int Flag
    
    RETFIE ; Return from Interrupt
    EndAsm
    if that fails try

    banksel CCP1CON OR WHATERVER SFR

    OR
    read data sheet and find what bank each sfr is in


    with all that bank switching the effort may be pointless

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: 16 bit PWM using CCP1

    post 35 is wrong pie1 is not in bank0 either

    Code:
    Asm
    PWM_INT
    CHK?RP   CCP1CON
    movlw 9 ; compare mode
    clrf CCP1CON ; clear reg
    movwf CCP1CON ; Set reg
    CHK?RP  PWM_VAL
    movf PWM_VAL+1,W ; hb
    CHK?RP   CCPRIL
    movwf CCPR1H ; put
    CHK?RP  PWM_VAL
    movf PWM_VAL,W ; lb
    CHK?RP   CCPRIL
    movwf CCPR1L ; put
    banksel 0
    bsf INTCON,7 ;GIE = 1
    bsf INTCON,6 ;PEIE = 1 Enable peripheral interrupts
    CHK?RP   PIE1
    bsf PIE1,0 ; TMR1IE= 1 Enable TMR1
    BANKSEL 0
    bcf PIR1,0 ; TMR1IF = 0 Clear Timer1 Int Flag
    
    RETFIE ; Return from Interrupt
    EndAsm

    it just gets worse

  3. #3
    Join Date
    Nov 2009
    Posts
    14


    Did you find this post helpful? Yes | No

    Default Re: 16 bit PWM using CCP1

    Richard and EarlyBird,
    Thank you very much for your generosity and support.
    I'm using version 3.0.1.4.


    Talat

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Half-bridge PWM with a 16F684 ?
    By Byte_Butcher in forum General
    Replies: 7
    Last Post: - 17th January 2010, 22:18
  3. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  4. How to tell which PICs can handle 16 bit variables?
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st August 2005, 08:44
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 2

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