Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
37 views
4 pages
CCP Dspic30f4013
Uploaded by
Carlos Amadeu Casarim
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Ccp Dspic30f4013 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
37 views
4 pages
CCP Dspic30f4013
Uploaded by
Carlos Amadeu Casarim
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Ccp Dspic30f4013 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Ccp Dspic30f4013 For Later
You are on page 1
/ 4
Search
Fullscreen
dsPIC30F3014/4013 13.0 OUTPUT COMPARE MODULE. Tote: This dala sheal summarizes fealrea of he group of dsPIC2OF devices and isnot intended fo be a complete Feference_ source. Far mare information on the CPU, Peripherals, register descriptions and general device functional, refer to the dsPICSOF Famiy Reference ‘Manual (0370048), This section describes the output compare module and associated Operational modes. The features provided by this module are useful in applications requiring (Operational modes, such as: + Generation of Variable Width Output Pulses + Power Factor Correction Figure 13-1 depicts a block diagram of the output compare module. The key operational features of the output compare ‘module include: + Timer2 and Timer3 Selection mode + Simple Output Compare Match mode + Dual Output Compare Match mode + Simple PWM mode + Output Compare During Sieep and Idle modes + Interrupt on Output Compare/PWM Event ‘These Operating modes are determined by setting the appropriate bits in the 16-bit OCxCON SFR (where x= 1,2,3,...N). The dsPIC devices contain up to 8 compare channels (.e., the maximum value of Nis 8) ‘The dsPIC30F3014 device contains 2 compare chan- nels while the dsPIC30F4013 device contains 4 com: pare channels. ‘OCKRS and OCXR in Figure 13-1 represent the Dual ‘Compare registers. In the Dual Compare mode, the ‘OCKR register is used forthe first compare and OCxRS is used for the second compare. 13.1 Timer2 and Timer3 Selection Mode Each output compare channel can select between one: (of two 16-bit timers, Timer? o Timer’. ‘The selection of the timers is controlled by the OCTSEL bit (OCxCON«3>), Timer? is the default timer resource forthe output compare madule, FIGURE 13-1: OUTPUT COMPARE MODE BLOCK DIAGRAM ‘Set Flag bit ‘OcKIF ‘OCKRS + Oupat 5 a} z ————| OO togic He uw t Output OO% Enable 1<2:0> ‘Comparator Select OcTsEL, OcFA (orx=1,2,3 074) or OCFB From GP (forx= 5,6, 7 or 8) Timer Module TMR2<150 TMRG<15:0> 122. MATCH TaP3_MATCH Note: Where > is shown, reference is made to the registers associated withthe respective output compare channels 1 through W. '© 2004 Microchip Technology in. Advance Information 108701386-page 81dsPIC30F3014/4013 13.2 Simple Output Compare Match Mode ‘When control bits OCM<2:0> (OCxCON«2:0>) (010 of 014, the selected output compare channel is, configured for one of three simple Output Compare Match modes: + Compare forces iO pin low + Compare forces V0 pin high + Compare toggles /0 pin ‘The OCKR register is used in these modes. The OCxR register is loaded with a value and is compared to the selected incrementing timer count. When a compare ‘occurs, one of these Compare Match modes occurs. If the counter resets to zero before reaching the value in (OCR, the state of the OCx pin remains unchanged 13.3 Dual Output Compare Match Mode ‘When control bits OCM<2:0> (OCXCON«2:0>) = 100 or 102, the selected output compare channel is config- tured for one of two Dual Output Compare modes, which are: + Single Output Pulse mode * Continuous Output Pulse mode 13.3.1 SINGLE PULSE MODE For the user to configure the madule for the generation of a single output pulse, the following steps are required (assuming timer is off + Determine instruction eye time Tov. + Calculate desired pulse with value based on Tov. + Calculate time to start pulse from timer start value cof 0x0000, + Write pulse width start and stop times into OCxR and OCxRS Compare registers (x denotes: channel 1, 2, Nl) + Set Timer Period register to value equal to, or greater than value in OCxRS Compare register, + Set OCM<2:0> = 200. + Enable timer, TON (TxCON«15>) = 1 To initiate another single pulse, issue another write to set OCM«2:0> = 299, 13.3.2. CONTINUOUS PULSE MODE For the user to configure the module for the generation of a continuous stream of outout pulses, the following steps are required + Determine instruction eyele time Tev. + Calculate desired pulse value based on Tor. + Calculate timer start pulse width from timer start value of 0x0000. + Write pulse width star and stop times into OCxR ‘and OCxRS (x denotes channel 4,2, .a!N) Compare registers, respectively. + Set Timor Period register to value equal to, or
= 102, + Enable timer, TON (TxCON«15> 13.4 Simple PWM Mode When control bits OCM«2:0> (OCxCONS2:0>) = 120, (or 112, the selected output compare channel is config- tured forthe PWM mode of operation. When configured forthe PWM mode of operation, OCxR isthe main latch (ead only) and OOXRS is the secondary latch. This enables gltchiess PWM transitions, ‘The user must perform the following steps in order to configure the output compare module for PWM ‘operation 41, Setthe PWM period by writing tothe appropriate period register 2. Setthe PWM duty cycle by writing to the OCxRS. register. 3. Configure the output compare module for PWM. ‘operation, 4. Set the TMRx prescale value and enable the Timer, TON (TxCONS15>) 13.4.1 INPUT PIN FAULT PROTECTION FOR PWM When control bits OCM<2:0> (OCxCON<2:0>) = 1 the selected output compare channel is again config red for the PWM mode of operation withthe adcltional feature of input FAULT protection. While in this mode, if logic'o'is detacted on the OCFAVB pin, the respeo- tive PWM output pin is placed in the high impedance Input state. The OCFLT bit (OCxCON<4>) indicates whether a FAULT condition has occurred. This state will 'be maintained until both of the following events have ‘occurred: + The extemal FAULT condition has been removed + The PWM mode has been re-enabled by writing to the appropriate control bits s70198C-page 82 Advance Information '© 2004 Microchip Technology ne.dsPIC30F3014/4013 13.4.2 PWMPERIOD ‘The PWM period is specified by writing to the PRX register. The PWM period can be calculated using Equation 13-1 EQUATION 13-1: PWM period = [(PRx)+1]+4+Tosc+ (TMRx prescale value) PWM frequency is defined as 1 / [PWM period] FIGURE 13-2: PWM OUTPUT TIMING When the selected TMRX is equal to its respective period register, PR, the folowing four events occur on the next increment cycle: + TMRx Is cleared. + The OCx pin is set = Exception 1: If PWM duty oye is 0x0000, the OCx pin wil remain low. = Exception 2: If duty cycle is greater than PRx, the pin will remain high, + The PWM duty cycle is latched from OCxRS into Oo, + The corresponding timer interrupt flag is set. ‘Soe Figure 13-2 for key PWM period comparisons. Timer3 is referred to in Figure 13-2 for clay Periog OcxR = OCHRS TMS = Duty Cycle (0cxR}) Duty Cycle : Tans = Ps “area See (roar lg) (raurupi ia) Sean OeaRS “TRS » Duty Cycle (oc) 13.5 Output Compare Operation During CPU Sleep Mode When the CPU enters Sleep mode, al internal clocks are stopped. Therefore, when the CPU enters the Sloop state, the output compare channel wil drive the pin to the active state that was observed prior to entering the CPU Sieep state, For example, ifthe pin was high when the CPU entered the Sleep state, the pin will remain high. Likewise, ifthe pin was low when the CPU entered the Sleep state, the pin will remain low. In either case, the output compare ‘module will resume operation when the device wakes up. 13.6 Output Compare Operation During CPU Idle Mode When the CPU enters the Idle mode, the output ‘compare module can operate with ful functionality The output compare channel will operate during the CPU ale mode ifthe OCSIDL bit (OCxCON<13>) is at logic ‘o'and the selected time base (Timer2 or Timer3) is enabled and the TSIOL bit ofthe selected timer is set to logic‘. 13.7 Output Compare Interrupts ‘The output compare channels have the abilly to gener- ‘ate an interrupt on a compare match, for whichever Match mode has been selected, For all modes except the PWM mode, when a compare: ‘event occurs, the respective interrupt flag (OCxIF) is asserted and an interrupt will be generated if enabled. The OCxIF bit is located in the corresponding IFS ‘Status register and must be cleared in software. The interrupt is enabled via the respective compare inter- nupt enable (OCxIE) bit located in the coresponding IEC Control register For the PWM mode, when an event occurs, he respec tive timer interrupt fag (TIF or T3IF) is asserted and an interrupt will be generated if enabled. The IF bit is located in the IFSO Status register and must be cleared in software. The interrupt is enabled via the respective timer interrupt enable bit (TZIE or T3IE) located in the IECO Control register. The output compare interrupt flag is never set during the PWM mode of operation. '© 2004 Microchip Technology in. Advance Information 10870386-page 83‘pjot 19 4018101 Jo suonduosop 10} (g+00ZSG) lenueyy ooussa}0y4 AjUte JOEDIASP 0} 10}0%4 ZO1ON a pecreninn toy Bua9 6600 4008 BOO wanes [so] TO | ee a nS ) 3009” 8608 0000 b008 asa PEO 7510 [__w¥90 3509 0008 0000_B000 Toy oepnog Fo8UuN WINS zai0 | Su¥00) 3009” 8008 0000_G000 wens SOT TO] = P= = = asso] == os noo00) 2509” 0000 0000-B000 ra ase 6 0D sei [ato 2600” 0000 0000-G000 ay puo F800 AO 3ue50) 2000” 0000 0000 G000 wea | 3810 [HBO T= = [= T= T= [= esl == W020) 2800” c008 0000 B000 “sy ue Z aBBCD FBO 3200) [isco -cc02-eo0a_ cone Ti Kepuo0s 7 ed09 aS 3a220) 2809” 0000 0000 8000 aeRO jane [nmol = [= [= | - [—-][= ]- 1] = fosop = [= No9120) [[2e02”6000-e000 e002 “ “aise us 8800 FG 100] [2ee2 soon e000 vo0e “aii Kepuo%8 | omdu00 Wao } ms ove | twa | twa] ue | viva | sve | owe | c¥e a [ova era | oe | vue | sr AV UBLSIOTY TUVANOD LNdLNO Eors0ed1dsP veaveryewnn ss punter 3eae 8608 0000 Boos wanes [sso | HO] SST STS TE TET Beso = [= [vate | no250 3809 6008 0000 B00 en TORSION sero | _we00) 3009” 0008 0000_G000 ou aepuoos Zona e810 [S420 2009” 0008 0000 G000 sono [rae ee ST = = ey 2509” 0000 9000 G000 ay pues 580409 WANG dsPIC30F3014/4013 ‘AVI YSLSIOTY SUVANOD LNdLNO PLOESOEDIGSP HEL TTSVL '© 2004 Microchip Technology ne. Advance Information s70198C-page 84
You might also like
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (648)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
4/5 (1175)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4.5/5 (1856)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1267)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4.5/5 (4103)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (903)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (629)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4.5/5 (1139)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (298)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (943)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2289)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (2886)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (233)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (244)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (144)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (919)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (836)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2546)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M.L. Stedman
4.5/5 (815)
Little Women
From Everand
Little Women
Louisa May Alcott
4.5/5 (2369)