PIC16F616 HWPM Problem


Closed Thread
Results 1 to 4 of 4
  1. #1

    Default PIC16F616 HWPM Problem

    I am using a PIC16F616. I can't get the HWPM to work. I threw in the Toggle command for a channel to check if the processor is operating. PortC.5 is going hi/lo.
    Any ideas?

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 4/3/2009                                          *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    INCLUDE "modedefs.bas"
    
    OPTION_REG.7 = 0 'Pull Ups enabled
    
    TRISA.2=1
    TRISC.0 = 1
    TRISC.1 = 0
    TRISC.2 = 0
    TRISC.3 = 1
    TRISC.4 = 0
    TRISC.5 = 0
    '0 Digital 1 Analogue
    ANSEL.7=0
    ANSEL.6=0
    ANSEL.5=0
    ANSEL.4=1
    ANSEL.3=0
    ANSEL.2=0
    ANSEL.1=0
    ANSEL.0=0
    
    ADCON0.7=1 'Right Justified
    ADCON0.6=0 ''Voltage reference is VDD
    ADCON0.5=0 'Turns on AN4 to analogue
    ADCON0.4=1
    ADCON0.3=0
    ADCON0.2=0
    
    
    'HPWM DEFINES
    DEFINE CCP1_REG PORTC  
    DEFINE CCP1_BIT 1 'Hpwm 2 --> portc.1
    DEFINE CCP2_REG PORTC  
    DEFINE CCP2_BIT 2 'Hpwm 1--> portc.2
    
    Define ADC_BITS 8 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uSec
    
    Switch       var PortA.2   '
    FF           var PortC.0
    FrontOut     var PortC.1
    RearOut      var PortC.2
    GS           var PortC.3
    Watch        var PortC.5
    
    HPWM 1,127,400
    HPWM 2,127,400
    
    Loop:
    If Switch = 1 then
       Toggle Watch 
       pause 100
    endif
    goto Loop

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


    Did you find this post helpful? Yes | No

    Default

    Are you sure it's a PIC16F616?

    The 616 only has 1 CCP module.
    It's on RC5 and can't be changed with a DEFINE.
    <br>
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Come on isn't that just a minor technical difficulty??? I thought I was doing good reading the spec sheet. Table 2 has RC5 as CCP1, I thought that I could get away using RC2,3, and 4 because there was P1B, P1C, and P1D. What would I use RC2, 3, and 4 as if they are labeled as P1B, P1C, and P1D? Does that mean I can use them as HPWM's yet they will share the same pulse width as the CCP1? For my project I need two different PWM's so I would need a chip that has two CCP's?
    Thanks
    Toby

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Tobias View Post
    Come on isn't that just a minor technical difficulty???
    Insignificant, in the scope of world events. <hr>
    The CCP module on that chip is an ECCP.
    The P1A thru P1D outputs can be used to run "half-bridge" or "full-bridge" motor drivers and a few other tricky things. All the outputs would have the same PWM freq/duty, but uses complimentary signals with programmable delays when switching states.

    But the way the HPWM command uses the CCP module, it's a single output on the CCP pin.

    You can only get 1 PWM signal out of it.

    For my project I need two different PWM's so I would need a chip that has two CCP's?
    Depends on what you need. There are alternatives to HPWM.
    <br>
    DT

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 19:52
  2. Problem with servo and PIC16F616
    By Forkosh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th November 2007, 21:22
  3. PIC16F616 Comparator problem
    By JimA in forum General
    Replies: 0
    Last Post: - 15th October 2007, 14:56
  4. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

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