16f1503 AND PWM modules


Today 00:13
Forum: The Lounge
Starter: _Gabi_
Views: 6753
Replies: 24
Yesterday 20:26
Forum: The Lounge
Starter: normnet
Views: 0
Replies: 0
Yesterday 17:28
Forum: Proton Plus Compiler v3
Starter: gtv_pic
Views: 0
Replies: 8
+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: 16f1503 AND PWM modules1161 days old

  1. #1
    Junior Member Maxi's Avatar
    Join Date
    Mar 2010
    Posts
    87
    Thumbs Up
    Received: 1
    Given: 22
    Total Downloaded
    2.39 GB

    0 Not allowed!

    Default 16f1503 AND PWM modules

    Have any body work with pwm? (hpwm)
    I cant work any
    maybe have some trick?


    Code:
    ;-------------------------------------------------------------------------------
    ;**** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings
    
    Device = 16F1503
    
    Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_OFF, CP_ON, BOREN_ON, CLKOUTEN_OFF
    Config2 WRT_OFF, STVREN_OFF, BORV_LO, LPBOR_OFF, LVP_OFF
    
    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------
    Declare Xtal=4
    OSCCON=101010
    TRISA=0011:PORTA=0000
    TRISC=0001:PORTC=0000
    'Declare All_Digital= true
    
    Declare CCP1_Pin PORTC.5
    Declare CCP2_Pin PORTC.3
    Declare CCP3_Pin PORTA.2
    Declare CCP4_Pin PORTC.1
    
    PWM1CON=110000
    PWM2CON=110000
    PWM3CON=110000
    PWM4CON=110000
    
    
    FVRCON=000000
    CM1CON0.7=0
    CM2CON0.7=0
        
    ADCON0=000011
    ADCON1=110000
    ANSELA=010011
    ANSELC=000001
    
    Declare Adin_Res 10
    Declare Adin_Tad FRC
    Declare Adin_Stime 50
    
    Dim AN0 As Word
    Dim AN1 As Word
    Dim AN3 As Word
    Dim AN4 As Word
        
    Loop:
    HPWM 1,127,1000
    HPWM 2,127,1000
    HPWM 3,127,1000
    HPWM 4,127,1000
    
    AN0=ADIn 0
    AN1=ADIn 1
    AN3=ADIn 3
    AN4=ADIn 4
    
    Toggle PORTC.4
    DelayMS 100
    
    GoTo Loop

  2. #2
    Junior Member Maxi's Avatar
    Join Date
    Mar 2010
    Posts
    87
    Thumbs Up
    Received: 1
    Given: 22
    Total Downloaded
    2.39 GB

    0 Not allowed!

    Default Re: 16f1503 AND PWM modules

    Its work now
    hpwm command not working on 16F1503
    this controller some different

    you need send duty value to xxxDCH registers
    and PR2 register adjust frequency but I dont know now how?

    Code:
    ;-------------------------------------------------------------------------------
    ;**** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings
    
    Device = 16F1503
    
    Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_OFF, CP_ON, BOREN_ON, CLKOUTEN_OFF
    Config2 WRT_OFF, STVREN_OFF, BORV_LO, LPBOR_OFF, LVP_OFF
    
    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------
    Declare Xtal=4
    OSCCON=101010
    TRISA=0011:PORTA=0000
    TRISC=0001:PORTC=0000
    Declare All_Digital= true
    
    T2CON.2=1
    'PR2 = 0x65
    
    PWM1CON=100000
    PWM2CON=100000
    PWM3CON=100000
    PWM4CON=100000
    
    Dim Duty1 As Byte
        
    Loop:
    
    Inc Duty1
    PWM1DCH = Duty1
    PWM2DCH = Duty1
    PWM3DCH = Duty1
    PWM4DCH = Duty1
    
    Toggle PORTC.4
    DelayMS 10
    
    GoTo Loop

  3. #3
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,373
    Thumbs Up
    Received: 86
    Given: 23
    Total Downloaded
    4.04 GB

    0 Not allowed!

    Default Re: 16f1503 AND PWM modules

    Maxi,

    From the first post I did not see the declare of the pins. From the manual page 235: -

    Notes
    Some devices, such as the PIC16F62x, and PIC18F4xx, have alternate pins that may be used
    for Hpwm. The following Declares allow the use of different pins: -
    Declare CCP1_Pin Port . Pin ' Select Hpwm port and bit for CCP1 module.
    Declare CCP2_Pin Port . Pin ' Select Hpwm port and bit for CCP2 module.
    See also
    I do not have the device to try it but had a similar problem with 16F88, not declaring the pin it did not work.
    Regards

    Joseph

  4. #4
    Junior Member Maxi's Avatar
    Join Date
    Mar 2010
    Posts
    87
    Thumbs Up
    Received: 1
    Given: 22
    Total Downloaded
    2.39 GB

    0 Not allowed!

    Default Re: 16f1503 AND PWM modules

    hi Joseph
    my first code have declare line for pwm

  5. #5
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,373
    Thumbs Up
    Received: 86
    Given: 23
    Total Downloaded
    4.04 GB

    0 Not allowed!

    Default Re: 16f1503 AND PWM modules

    Quote Originally Posted by Maxi View Post
    hi Joseph
    my first code have declare line for pwm
    Do not ask why I did not see it. Sorry.
    Regards

    Joseph

  6. #6
    Member Beginner's Avatar
    Join Date
    Jun 2006
    Posts
    105
    Thumbs Up
    Received: 3
    Given: 3
    Total Downloaded
    1.93 GB

    0 Not allowed!

    Default Re: 16f1503 AND PWM modules

    And 2 1/2 years later, it's still not fixed. Is there at least a workaround?

  7. #7
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,018
    Thumbs Up
    Received: 310
    Given: 114
    Total Downloaded
    1.51 GB

    1 Not allowed!
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  8. #8
    Member Beginner's Avatar
    Join Date
    Jun 2006
    Posts
    105
    Thumbs Up
    Received: 3
    Given: 3
    Total Downloaded
    1.93 GB

    0 Not allowed!

    Default Re: 16f1503 AND PWM modules

    Great! Thank you very much.

  9. #9
    Prolific Poster rcurl's Avatar
    Join Date
    Mar 2002
    Posts
    1,784
    Thumbs Up
    Received: 31
    Given: 51
    Total Downloaded
    1.61 GB

    0 Not allowed!

    Default Re: 16f1503 AND PWM modules

    I was writing code for a 16F1503 and I could not get PWM2 to work. PWM's 1,3, and 4 were fine. The PPI file for the PIC looks fine.

    I downloaded Les' PWM library replacement routine and it fixed the problem, but I'm curious as to why it was only PWM2 that was giving trouble. I'd rather keep my code lean and not have to use the replacement library.

    Here's the setup I was using:
    Code:
    '* Set I/O pin direction *
    APFCON = %00010000
    TRISA = 0       'all pins digital output
    TRISC = 0
    ANSELA = 0
    ANSELC = 0
    '* Set up the PWM Generators *
    PR2 = $FF
    PWM1DCH = 0        'all PWM duty cycles to zero
    PWM1DCL = 0
    PWM2DCH = 0
    PWM2DCL = 0
    PWM3DCH = 0
    PWM3DCL = 0
    PWM4DCH = 0
    PWM4DCL = 0
    T2CON =      %00000100  'T2 prescaler & postscaler = 1, timer ON
    PWM1CON = %11000000  'Enable all PWM generators
    PWM2CON = %11000000
    PWM3CON = %11000000
    PWM4CON = %11000000
    Any thoughts on this?

    Thanks!

    -Rick
    Last edited by rcurl; 5th July 2018 at 20:36.

  10. #10
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,018
    Thumbs Up
    Received: 310
    Given: 114
    Total Downloaded
    1.51 GB

    1 Not allowed!

    Default Re: 16f1503 AND PWM modules

  11. I don't have a 16F1503, so I'll get a sample of one from Microchip, just to make sure the changes I make actually work.

    I'll take a look at the compiler's library code, compared to the inc file code I created, and get it working from the HPWM command. It's going to be something silly, and simple, it's just finding it that takes the time. LOL. Then once it has been found, it is the "Ooooh of course!" moment. :-)

    The newer devices have their SFRs all over RAM banks now, and they keep changing them from family to family, so it may be something as simple as a RAM bank setting.

    Watch this space Rick!
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 8
    Last Post: 2nd August 2013, 12:57
  2. hbusout not working with 16F1503
    By Francis in forum Master Synchronous Serial Port (MSSP) module / 3-wire SPI / I2C / Master and Slave modes
    Replies: 2
    Last Post: 26th February 2013, 13:42
  3. 16F1503 def & ppi files - i2c bug
    By Francis in forum Master Synchronous Serial Port (MSSP) module / 3-wire SPI / I2C / Master and Slave modes
    Replies: 0
    Last Post: 3rd January 2013, 13:21
  4. Need a chip w/ 2 CCP modules and 2 PWM timers
    By HelpMe! in forum Proton Plus Compiler v3
    Replies: 12
    Last Post: 8th October 2007, 20:25

Members who have read this thread since 19th November 2018, 22:01 : 2

Actions :  (Set Date)  (Clear Date)

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

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