ECCP module problem


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2006
    Posts
    37

    Default ECCP module problem

    why is this code not working on 18F1320.any ideas!!!!

    Define OSC 8
    ADCON1 = 7

    DUTY var WORD

    P1A var PORTB.3 ' ECCP pin defines . Replace those with your actual device pins
    P1B var PORTB.2
    P1C var PORTB.6
    P1D var PORTB.7
    TMR2IF var PIR1.1 ' TMR2 interrupt flag



    P1A=1 'Tristate
    P1B=1 ' Tristate
    P1C=1 ' Tristate
    P1D=1 'Tristate
    PR2 = 249 ' set PR2 to 249 , that is 1Khz PWM frequency
    CCP1CON =0 ' PWM generator stopped
    CCPR1L = 0 ' zero Duty Cycle
    'CLEAR TMR2IF
    TMR2IF=0



    FORWARD:
    DUTY=200
    CCP1CON=0 ; stop the PWM generator
    P1A=0 ' P1A = 1 ; P1A = active
    P1B=1 ; P1B = tristate
    P1C=1 ; P1C = tristate
    P1D=0 ; P1D = PWM modulated
    ;------------------------
    CCP1CON.4 = DUTY.0 ; here we stat loading the CCPR1
    CCP1CON.5 = DUTY.1 ; with the value of DUTY Cycle parameter
    CCPR1L = DUTY >> 2 ;
    ;-----------------------
    CCP1CON = %01001100 ; set CCP1CON to full bridge , high output, Forward
    T2CON = %00000101 ; start TMR2 , also TMR2 prescaler 1:4
    WHILE TMR2IF = 0
    WEND ; wait for a TMR2 period to expire
    RETURN

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by hell_pk View Post
    why is this code not working on 18F1320.any ideas!!!!

    Code:
    P1A  var PORTB.3    ' ECCP pin defines . 
    P1B  var PORTB.2    
    P1C  var PORTB.6    
    P1D  var PORTB.7    
    TMR2IF  var PIR1.1 ' TMR2 interrupt flag
    
    
    
        P1A=1        'Tristate
        P1B=1        ' Tristate
        P1C=1        ' Tristate
        P1D=1        'Tristate
    Those are changing the PORT value, not it's input/output state.

    Try TRISB.x for P1A-D.
    <br>
    DT

  3. #3
    Join Date
    Jun 2006
    Posts
    37


    Did you find this post helpful? Yes | No

    Default still not working

    Hi!
    still not working!!!

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Is there more to your program?

    If not, then the FORWARD routine is RETURNing but it wasn't called with a GOSUB.

    Also,
    Code:
    ;------------------------
    CCP1CON.4 = DUTY.0 ; here we stat loading the CCPR1
    CCP1CON.5 = DUTY.1 ; with the value of DUTY Cycle parameter
    CCPR1L = DUTY >> 2 ;
    ;-----------------------
    CCP1CON = %01001100 ; set CCP1CON to full bridge , high output, Forward
    By setting CCP1CON after seting to 2 LSB's of the dutycycle, it overwrites those bits and you lose resolution.
    <br>
    DT

  5. #5
    Join Date
    Jun 2006
    Posts
    37


    Did you find this post helpful? Yes | No

    Default ok its done

    thanks its done with a little bit of messing around.i wasnt using my head and was relying too much on forum help.
    btw thanks to fanie & gabi as well.

Similar Threads

  1. Version Control
    By btaylor in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 16th October 2011, 17:12
  2. Problem displaying data from GPS module & using 16f877a
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 15th April 2010, 10:27
  3. Vinculum VNC1L Vdrive2 module problems
    By the_virus in forum Serial
    Replies: 9
    Last Post: - 21st July 2008, 07:01
  4. problem with sending data using RF module
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 51
    Last Post: - 10th April 2008, 17:08
  5. Replies: 5
    Last Post: - 1st December 2004, 12:49

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