Hwpw


Results 1 to 20 of 20

Thread: Hwpw

Threaded View

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


    Did you find this post helpful? Yes | No

    Default Re: Hwpw

    first question how do you get the code box to post into


    OK I was able to change the port from port a4 to port b5 now I need to figure out this

    CCP4CON = $0C ; PWM MODE + DUTY LSB 2 BITS ' PORT B0
    CCPR4L =%110010 ; DUTY MSB 8 BITS ' $32

    it does not seem to be very straight forward I will look at the posts you sent yesterday and see if I'm able to do the math, shifting and what ever else it takes.
    I did change the numbering to BIN so when looking in the manual I could line things up with the proper bits (don't get mad)


    Code:
    #CONFIG
      ERRORLEVEL -306	       			; turn off crossing page boundary message
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = ON
      CONFIG  PRICLKEN = ON
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRTEN = ON
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 190
      CONFIG  WDTEN = ON
      CONFIG  WDTPS = 32768
      CONFIG  CCP2MX = PORTC1
      CONFIG  PBADEN = OFF
      CONFIG  CCP3MX = PORTB5                                
      CONFIG  T3CMX = PORTC0
      CONFIG  HFOFST = ON
      CONFIG  P2BMX = PORTB5
      CONFIG  MCLRE = EXTMCLR
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG 
     
        DEFINE OSC 64
    
        ANSELB=0
        ANSELC=0
        ANSELA=0
    
        trisa = %11011111
        trisb = %11011110
        trisc = %11111001
    
    
        OSCCON = %1110000		; $70
        OSCTUNE.6 = 1
        
        T2CON = %0110        		; PRESCALE 16 TMR ON PORT B0	6
        T4CON = %0110         		; PRESCALE 16 TMR ON	PORT B5	6
        T6CON = %0110         		; PRESCALE 16 TMR ON	PORT C2	6
    
        PR2 = %1100011        		; 10 KHZ 					PORT B0	$63
        PR4 = %1001111        		; 12.5 KHZ				        PORT B5     $4F
        PR6 = %1111100         		;   8 KHZ					PORT C2	$7C
    
        CCP4CON = $0C   			; PWM MODE + DUTY LSB 2 BITS	' PORT B0
        CCPR4L  =%110010  		; DUTY MSB 8 BITS				' $32
        	
        CCP3CON = $0C   			; PWM MODE + DUTY LSB 2 BITS	' PORT B5 
        CCPR3L  = %10111			; DUTY MSB 8 BITS				' $27
    
        CCP1CON = $0C   			; PWM MODE + DUTY LSB 2 BITS	' PORT C2
        CCPR1L  = %111110  		; DUTY MSB 8 BITS				' $3E
        
        CCPTMRS1  = %00   		: TIMER2 = CCP4, 	 ' TIMER4 CCP5 (USED WITH BELOW)
        CCPTMRS0  = %1011010	 	; TIMER6 = CCP1, 	   TIMER4 = CCP3
    Last edited by Ioannis; - 25th July 2025 at 12:46.

Members who have read this thread : 13

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