Pic18f2320


Closed Thread
Results 1 to 5 of 5

Thread: Pic18f2320

  1. #1
    Join Date
    Apr 2005
    Location
    Auckland/New Zealand
    Posts
    19

    Default Pic18f2320

    Hi,
    I have 18F2320 has anyone used HPWM on this PIC? I have EPIC programmer is ok to program this chip?
    I looks it has 16 bit PWM can I use it for 8 bit only? has anyone used both pwm's since it has two?
    Regards,
    Suded

  2. #2
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Pic18f2320

    You can use the HPWM command or you can manually control the PWM function. In the Data Sheet in the CCP section, PWM subsection, the ASM code is listed for firing up TMR2, activating the PWM, then controlling it from there. In order to use the PWM function at any higher than 8-bit resolution, you have to do it manually. You will be controlling the Duty Cycle with CCPR1L & CCPR1H for PWM Channel 1 and CCPR2L & CCPR2H for Channel 2. PBP3 only works with 8-bit control over PWM.

    Mike Holler

  3. #3
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Pic18f2320

    The following is used on a PIC16F1824. Check your Data Sheet to double check the Special Function Registers as applicable to your chip:

    Code:
    ; --- *** Timer 2 SFRs, Used for PWM Period *** --------------------------------
    T2CON       =   %01111011               ;.2 = 1/0
    PR2         =   %11111111
    PIE1.1      =   0                       ;TMR2IE
    
    
    ; --- *** CCP1 PWM SFRs *** ----------------------------------------------------
    CCP1CON     =   %00001100
    
    
    DutyCycle   VAR WORD
    CCPR1L      =   DutyCycle.LOWBYTE
    ;HIGHBYTE comes from bits in CCP1CON
    
    
    ;Fill in other pertinent set-up data.
    
    
    Label:
        PIR1.1 = 0                      ;TMR2IF
        PIE1.1 = 1                      ;TMR2IE
        T2CON = %01111111               ;Turns TMR2 ON
    do
        loop while PIR1.1 = 0           ;TMR2IF
        PIR1.1 = 0                      ;TMR2IF
        DutyCycle = ;desired PWM
    Hope this helps.
    Last edited by mpgmike; - 23rd July 2017 at 18:59.

  4. #4
    Join Date
    Apr 2005
    Location
    Auckland/New Zealand
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Pic18f2320

    Hi Mike,
    Thanks for your help, I need to use directly from PBP, I have an older version.
    I'm thinking of using a single PWM PIC like PIC18F1320 to control two analogue values then use sample and hold get two outputs.
    Regards,
    Suded

  5. #5
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Pic18f2320

    Frequency is controlled by the scaler in T2CON and the value of PR2. The setting I'm using provides for the slowest frequency possible with my OSC speed; PR2 = $FF. The reason I do this the long way is PBP3 will actually toggle PR2 between 2 values to deliver the frequency requested in the HPWM command (HPWM 1,DutyCycle,Frequency). I needed a consistent cycle-to-cycle period timing and couldn't achieve it with HPWM.

Similar Threads

  1. DHT22, AM2302 and pic18F2320
    By bitmaniac in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 15th November 2015, 01:42
  2. PIC18F2320 RA4 output problem
    By Kristjan in forum General
    Replies: 2
    Last Post: - 31st May 2007, 00:56

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