12F1572 HPWM issue


+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2014
    Posts
    83

    Default 12F1572 HPWM issue

    Hi,

    HPWM work right on PORTA.1 . Also , the PORTA.5 work well like a digitall port.
    I want to move the PWM1 from PORTA.1 to PORTA.5 . Theoretically is very simple, must set APFCON.0 =1 .
    Now I have a problem because on pin A5 I have nothing, also, the HPWM is missing on pin A.1 .
    I changed the PIC from another lot , but the same !
    If I set APFCON.1 = 1 , the PWM2 is moved from A.0 to A.4, so the APFCON have an effect.
    Something is missing or chip have some trouble ?

    Code:
    #CONFIG
            __config _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_OFF & _CP_ON & _BOREN_OFF & _CLKOUTEN_OFF
            __config _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_LO & _LPBOREN_OFF & _LVP_OFF
    #ENDCONFIG
    
    
    DEFINE OSC 4	' system clock at 4MHz
    OSCCON = %01101010
    
    
    
    
    DEFINE HPWM_OSC  16000000	' PWM clock at 16MHz
    APFCON.0 = 1
    
    
    ANSELA = %00000000
    PORTA  = %00000000
    
    
    main:
    hpwm 1 , 100, 16000 'PORTA.5
    
    
    goto main

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,918

    Default Re: 12F1572 HPWM issue

    try

    DEFINE CCP1_REG PORTA 'Channel-1 port
    DEFINE CCP1_BIT 5 'Channel-1 bit

    and maybe

    trisa.5=0
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Jan 2014
    Posts
    83

    Default Re: 12F1572 HPWM issue

    Now is working...

    Was necesary only to set the port RA.5 as output . Its iteresting that portA5 work well as digitall output pin but did'n work as PWM pin only if its set to output.

    Thank you very much Richard !

Similar Threads

  1. 12f1572
    By Rony in forum General
    Replies: 8
    Last Post: - 28th January 2017, 16:27
  2. IF-THEN issue
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th February 2014, 22:09
  3. Replies: 3
    Last Post: - 23rd October 2011, 12:53
  4. Code Issue - select case or 'if' issue - not sure why
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th October 2007, 08:52
  5. HPWM of the port of two HPWM
    By ja2rqk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2007, 15:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts