Can someone show me how to set ccp3 to RC6 on pic 18f24k22


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,160


    Did you find this post helpful? Yes | No

    Default Re: Can someone show me how to set ccp3 to RC6 on pic 18f24k22

    Quote Originally Posted by BH_epuk View Post
    Don't know what happend to the code i posted earlier in the thread, it seems to have been reformatted missing bits so would never work...

    The top left icon above the post box has two As; click on it to get SOURCE mode. That will leave your code intact.

    To have your post box in SOURCE mode by default:
    - click on SETTINGS at top right.
    - click on General Settings on left side.
    - scroll down to Miscellaneous Options.
    - click on Standard Editor - Extra formatting controls

    Robert

    Code:
    '************************************************************************************
    '*   HPWM Demo Code for PIC18F24K22		                                    *
    '*                                                                                  *
    '*                                                                                  *
    '*                                                                                  *
    '************************************************************************************
    
    
    
    asm
            __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H & _PLLCFG_OFF_1H & _PRICLKEN_ON_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
            __CONFIG    _CONFIG2L, _PWRTEN_ON_2L & _BOREN_OFF_2L & _BORV_285_2L
            __CONFIG    _CONFIG2H, _WDTEN_NOSLP_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _CCP2MX_PORTB3_3H & _PBADEN_OFF_3H & _CCP3MX_PORTB5_3H & _HFOFST_OFF_3H & _T3CMX_PORTB5_3H & _P2BMX_PORTB5_3H & _MCLRE_EXTMCLR_3H
            __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
            __CONFIG    _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L 
            __CONFIG    _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
            __CONFIG    _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L 
            __CONFIG    _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H  
            __CONFIG    _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L 
            __CONFIG    _CONFIG7H, _EBTRB_OFF_7H       
    
    ENDASM
    
    Define OSC 8
    
    
    
    LED2    var PORTA.0     ' Status LED
    LED1    var PORTA.1     ' Status LED 
    RA2     var PORTA.2     '     
    RA3     var PORTA.3     '   
    RA4     var PORTA.4     '    
    RA5     var PORTA.5     ' 
    RA6     VAR PORTA.6     ' Xtal
    RA7     var PORTA.7     ' Xtal
    
    PWM1    VAR PORTB.0     ' CH1 PWM Output
    RB1     VAR PORTB.1     ' 
    RB2     VAR PORTB.2     ' 
    PWM2    VAR PORTB.3     ' CH2 PWM Output
    RB4     VAR PORTB.4     ' Spare
    PWM3    VAR PORTB.5     ' CH3 PWm Output
    RB6     VAR PORTB.6     ' PGC / TX2
    RB7     VAR PORTB.7     ' PGD / RX2
    
    RC0     var PORTC.0     '  
    RC1     var PORTC.1     '    
    RC2     var PORTC.2     '      
    RC3     var PORTC.3     '    
    RC4     var PORTC.4     '    
    RC5     var PORTC.5     ' 
    TXD1    var PORTC.6     ' TX1
    RXD1    var PORTC.7     ' RX1
    
    RE0     VAR PORTE.0     ' VPP/nMCLR
                         
    ch1     var byte
    ch2     var byte
    ch3     var byte
    
    update  var bit
    
    
    OSCCON = %01100010          ' Set internal 8Mhz OSC
    OSCCON2 = %00001100
    while OSCCON.2 = 0 : WEND   ' Wait for stable flag
    
    clear
    
    
    PORTA = %00100000       ' Setup ports
    PORTB = %00000000
    PORTC = %00000000
    
    ANSELA = %00000000
    ANSELB = %00000000
    ANSELC = %00000000      ' Config A2d
    
    ADCON2 = %10101101
    ADCON1 = %00001000
    ADCON0 = %00011000
    
    VREFCON0 = %10100000    ' Enable voltage referance 2.048V
    
    TRISA = %00000000       ' Setup TRIS
    TRISB = %10000110
    TRISC = %10011000
    
        GOTO start
        
    '-------------------------------------------------------------------------------
    ' Main program starts here
    '-------------------------------------------------------------------------------
    
    
    start:
    
        ch1 = 64			' load some levels for the outputs
        ch2 = 128
        ch3 = 192			
        update = 1			' set flag to update PWM outputs
        
    
    '-------------------------------------------------------------------------------
    ' Main Loop 
    '-------------------------------------------------------------------------------
        
        
    main:   
    
        if update then		' If the flag is set to update then
            hpwm 4,ch1,500		' load the PWM outputs with new values
            hpwm 3,ch2,500
            hpwm 2,ch3,500    
            update = 0		' clear update flag
        endif
        
        
        goto main
         
             
     
        end

  2. #2
    Join Date
    Nov 2008
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Can someone show me how to set ccp3 to RC6 on pic 18f24k22

    Cheers Robert, It was going to be something simple.

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