PWM for Inverter Card using PIC16F72

Author
alap_shah
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2008/10/19 21:15:26
  • Location: 0
  • Status: offline
2008/10/19 21:29:14 (permalink)
0

PWM for Inverter Card using PIC16F72

Dear sir,
 
I am using PIC 16F72 for generating PWM pulses to drive MOSFET in inverter card.
 
I am using 20MHZ Crystal for generating PWM pulses.
 
I want to generate 100KHz pulses on pin 13 (CCP/PWM) of the microcontroller but able to generate only 28KHZ.
 
If i used readymade Hex code for generating 150KHZ PWM , my hardware generate it quite comfortably , so that there is no problem with hardware configuration.
 
There is some bug in my assembly language program.
 
I request any learned and experience member to kindly go through my program and give me proper guidance of how to generate 100KHZ PWM wave.
 
Hereby i am posting my program for the same.
 
LIST p=16F72
include "p16F72.inc"
__CONFIG _CP_OFF & _WDT_OFF & _HS_OSC    ;sets the configuration settings (oscillator type etc.)
  
   org   0x00
continue
   clrf  CCP1CON
   clrf  TMR2
   movlw  31h                                             ;PR2 SET FOR FREQUENCY OF 100 KHZ
   movwf  PR2   
   movlw  18h                                             ;DUTY CYCLE IS 25% OF PWM PERIOED
   movwf   CCPR1L
   clrf  INTCON                                            ;DISABLE INTERRUPT AND CLEAR T0IF
   bsf   STATUS,RP0                                     ;SELECTING BANK1
   bcf   TRISC,2                                           ;PWM1 PIN IS OUTPUT
   clrf  PIE1                                                 ;DISABLE PHERIPHERAL INTERRUPT
   bcf   STATUS,RP0                                     ;SELECTING BANK0
   clrf  PIR1                                                 ;CLEARING PHERIPHERAL INTERRUPT FLAG
   movlw  3ch                                              ;PWM MODE AND LSB OF DUTY CYCLE IS 10
   movwf  CCP1CON
   movlw  04h
   movwf  T2CON
   bsf   T2CON,TMR2ON                                  ;TIMER2 STARTS TO INCREMENTS
PERIEODMATCH
   btfss   PIR1,TMR2IF
   goto  PERIEODMATCH
   bcf   PIR1,TMR2IF
   goto  continue   
 end  

Best Regards
---------------
Alap Shah
#1

4 Replies Related Threads

    danish.ali
    Super Member
    • Total Posts : 1714
    • Reward points : 0
    • Joined: 2004/11/16 02:02:02
    • Location: Surrey, UK
    • Status: offline
    RE: PWM for Inverter Card using PIC16F72 2008/10/20 01:50:55 (permalink)
    0
    Hi Alep Shah,

    I think the problem relates to memory banking.
    The address for PR2 is 92h, but the op-code to write to memory only has 7 bits of address.
    The high bits are taken from the STATUS register, bits RP1 and RP0.

    In order for the write to work, you need to make sure those bits are correct. You can set/clear them by hand, but I recommend using the BANKSEL macro:
    ; example to write to PR2
            movlw   31h
            banksel PR2
            movwf   PR2
            banksel 0 ; back to normal bank
    When you assemble your code, you should have seen warning 302 saying that you were attempting to write to a bank which was not the "startup" bank of 0, and to ensure the bank bits are correct.

    Hope this helps,
    Danish
    #2
    biswajitkundu2007
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2013/04/21 10:22:51
    • Location: 0
    • Status: offline
    RE: PWM for Inverter Card using PIC16F72 2013/04/21 11:17:50 (permalink)
    0
    I am using PIC 16F72 for generating PWM pulses to drive MOSFET in inverter card. 
      
    I am using 20MHZ Crystal for generating PWM pulses. 
      
    I want to generate 50Hz pulses on RB0 & RB1 of the microcontroller. Please help me along with C Code.
     
    Thank you.
    #3
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: offline
    RE: PWM for Inverter Card using PIC16F72 2013/04/21 12:59:48 (permalink)
    0
    Not sure if you can, using HW PWM on that PIC at that frequency.
    You could use a software PWM...

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #4
    biswajitkundu2007
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2013/04/21 10:22:51
    • Location: 0
    • Status: offline
    RE: PWM for Inverter Card using PIC16F72 2013/04/21 21:44:48 (permalink)
    0
    Can you give me the code because I'm new one for Microchip. 
    #5
    Jump to:
    © 2017 APG vNext Commercial Version 4.5