CN104796118B - A kind of limitation output pwm of breakthrough MCU hardware method - Google Patents

A kind of limitation output pwm of breakthrough MCU hardware method Download PDF

Info

Publication number
CN104796118B
CN104796118B CN201510211221.8A CN201510211221A CN104796118B CN 104796118 B CN104796118 B CN 104796118B CN 201510211221 A CN201510211221 A CN 201510211221A CN 104796118 B CN104796118 B CN 104796118B
Authority
CN
China
Prior art keywords
pwm
mcu
output
formula
time
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510211221.8A
Other languages
Chinese (zh)
Other versions
CN104796118A (en
Inventor
宋志超
陈志杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Zhenbang intelligent Polytron Technologies Inc
Original Assignee
SHENZHEN ZHENBANG INTELLIGENT TECHNOLOGY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SHENZHEN ZHENBANG INTELLIGENT TECHNOLOGY Co Ltd filed Critical SHENZHEN ZHENBANG INTELLIGENT TECHNOLOGY Co Ltd
Priority to CN201510211221.8A priority Critical patent/CN104796118B/en
Publication of CN104796118A publication Critical patent/CN104796118A/en
Application granted granted Critical
Publication of CN104796118B publication Critical patent/CN104796118B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a kind of limitation output pwm of breakthrough MCU hardware method, it is characterised in that comprises the following steps:S1, initialization clock configuration, the continuous clock that one 8 are configured in MCU overflow interruption;, after the time of setting, there is an interruption in S2, normal operation;And S3, judge whether I/O output identifications are true, when I/O output identifications are true, low level time is to clock timer in heavily loaded pwm, and I/O output identifications are set to false, and I/O mouthful export low levels, then repeat step S2;High level time is to clock timer in I/O output identifications are fictitious time, heavily loaded pwm, and I/O output identifications are set to true, I/O mouthfuls of output high level, then repeat step S2.The product up-gradation construction cycle is short, it is not necessary to changes hardware circuit, addition high speed outer crystal oscillator or changes high speed MCU, reduces cost.

Description

A kind of limitation output pwm of breakthrough MCU hardware method
Technical field
The present invention relates to the method in pulsewidth modulation field, more particularly to a kind of limitation output pwm of breakthrough MCU hardware.
Background technology
MCU perfect in shape and function in current various electronic equipments, wherein just comprising pwm output functions;Its MCU hardware supported Pwm output function, it is only necessary to which pwm configurations are carried out to current MCU, you can obtain the pwm outputs of corresponding frequency.
But the frequency of MCU hardware pwm outputs is limited for the MCU crystal oscillators selected and electronic circuit, in order to carry The frequency of high pwm output, existing technology has three kinds:
(1)Hardware circuit is changed, pwm delivery outlets are changed to the outlet of other pwm function numbers.Defect is:Product up-gradation is more Change circuit and software to carry out simultaneously, the upgrading construction cycle is long, and negative value is more;
(2)High speed outer crystal oscillator is added, makes the increase of pwm output frequencies.Defect is:It need to upgrade circuit and most of software is matched somebody with somebody Put, the upgrading construction cycle is long, product cost rise, negative value is more;
(3)Change more high speed MCU.Defect is:Product cost is raised, and software is developed again, and the cycle is long.
The content of the invention
It is an object of the invention to provide a kind of breakthrough MCU hardware limitation output pwm method, increase hardware unit and Pwm output frequencies are lifted in the case of circuit structure.
The technical scheme is that a kind of limitation output pwm of breakthrough MCU hardware method, comprises the following steps:
S1, initialization clock configuration, the continuous clock that one 8 are configured in MCU overflow interruption;
, after the time of setting, there is an interruption in S2, normal operation;And
S3, judge whether I/O output identifications are true, when I/O output identifications are true, low level time is given in heavily loaded pwm Clock timer, I/O output identifications are set to false, I/O mouthfuls of output low levels, then repeat step S2;When I/O output identifications are false When, high level time is to clock timer in heavily loaded pwm, and I/O output identifications are set to true, I/O mouthfuls of output high level, then repeats Step S2.
The technical program carries out simulation pwm output functions using 8 bit clock timers so that can by I/O mouthfuls in MCU Dutycycle number Dc is adjusted to carry out any setting.Such as by Dc=100, then Dc<255 ;So that frequency is raised, breach original The pwm output functions of MCU hardware.The product up-gradation construction cycle is short, it is not necessary to change hardware circuit, addition high speed outer crystal oscillator Or high speed MCU is changed, reduce cost.
Further, in step S2, the time of the setting meets following formula:
Tx=255*t
In formula, Tx represents the time apart from next interruption, and t represents MCU instruction cycle.Program runs to time Tx When, there is an interruption;When off-duty is to Tx, continue to run with.
Further, in step S3, low level time meets following formula in heavily loaded pwm:
Tl=(255-Dc+Dd)*t
In formula, Tl represents low level time in pwm, and t represents MCU instruction cycle, and Dc represents adjustable duty cycle number, Dd represents the corresponding numerical value of dutycycle.
Further, in step S3, high level time meets following formula in heavily loaded pwm:
Th=(255-Dd)*t
In formula, Th represents high level time in pwm, and t represents MCU instruction cycle, and Dd represents the corresponding number of dutycycle Value.
Further, the pwm waveforms that the MCU I/O mouths final output stable cycle is T, the cycle T meets formula:
T=Th+Tl=Dc*t (1)
In formula, T represents pwm cycle, and t represents the MCU instruction cycles, and Dc represents adjustable duty cycle number;
The dutycycle of the pwm waveforms is(Dd/Dc)*100%;
According to formula(1)It can draw, the frequency of MCU I/O mouth final output pwm waveforms meets formula:
Fpwm=1/T=1/(Dc*t)
In formula, Dc represents adjustable duty cycle number, and t represents MCU instruction cycle
Beneficial effect:Simulation pwm output functions are carried out by using 8 bit clock timers so that can be by I/O in MCU Mouth adjustable duty cycle number Dc carries out any setting so that frequency is raised, and breaches the pwm output works of original MCU hardware Energy.The product up-gradation construction cycle is short, it is not necessary to changes hardware circuit, addition high speed outer crystal oscillator or changes high speed MCU, reduces Cost.
Brief description of the drawings
Fig. 1 is the workflow diagram of an embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawings, the preferably embodiment to the present invention is described in further detail:
Referring to Fig. 1, a kind of limitation output pwm of breakthrough MCU hardware method comprises the following steps:
S1, initialization clock configuration, the continuous clock that one 8 are configured in MCU overflow interruption;
, after the time of setting, there is an interruption in S2, normal operation;And
S3, judge whether I/O output identifications are true, when I/O output identifications are true, low level time is given in heavily loaded pwm Clock timer, I/O output identifications are set to false, I/O mouthfuls of output low levels, then repeat step S2;When I/O output identifications are false When, high level time is to clock timer in heavily loaded pwm, and I/O output identifications are set to true, I/O mouthfuls of output high level, then repeats Step S2.
In step S2, the time of the setting meets following formula:
Tx=255*t
In formula, Tx represents the time apart from next interruption, and t represents MCU instruction cycle.Program runs to time Tx When, there is an interruption;When off-duty is to Tx, continue to run with.
In step S3, low level time meets following formula in heavily loaded pwm:
Tl=(255-Dc+Dd)*t
In formula, Tl represents low level time in pwm, and t represents MCU instruction cycle, and Dc represents adjustable duty cycle Number, Dd represents the corresponding numerical value of dutycycle.
In step S3, high level time meets following formula in heavily loaded pwm:
Th=(255-Dd)*t
In formula, Th represents high level time in pwm, and t represents MCU instruction cycle, and Dd represents the corresponding number of dutycycle Value.
The pwm waveforms that the MCU I/O mouths final output stable cycle is T, the cycle T meets formula:
T=Th+Tl=Dc*t (1)
In formula, T represents pwm cycle, and t represents the MCU instruction cycles, and Dc represents adjustable duty cycle number;
The dutycycle of the pwm waveforms is(Dd/Dc)*100%;
According to formula(1)It can draw, the frequency of MCU I/O mouth final output pwm waveforms meets formula:
Fpwm=1/T=1/(Dc*t)
In formula, Dc represents adjustable duty cycle number, and t represents MCU instruction cycle.
In the present embodiment, MCU model MB95F564K, t=0.25, it is assumed that Dd=50, Dc=100, then pwm waveforms are accounted for Empty ratio is:
50/100*100=50%,
The frequency of MCU I/O mouth final output pwm waveforms is:
(1/100*0.25)MHz=40KHz。
Therefore, it is assigned to Dd by 50 in software, so that it may so that it is 50% that the MCU, which exports 40KHz dutycycle, Pwm waveforms.
The present embodiment carries out simulation pwm output functions using 8 bit clock timers so that can be adjustable by I/O mouthfuls in MCU Dutycycle number Dc carries out any setting.Such as by Dc=100, then Dc<255 ;So that frequency is raised, original MCU is breached The pwm output functions of hardware.The product up-gradation construction cycle is short, it is not necessary to change hardware circuit, addition high speed outer crystal oscillator or more High speed MCU is changed, cost is reduced.
Above content is to combine specific preferred embodiment further description made for the present invention, it is impossible to assert The specific implementation of the present invention is confined to these explanations.For general technical staff of the technical field of the invention, On the premise of not departing from present inventive concept, some simple deduction or replace can also be made, should all be considered as belonging to the present invention's Protection domain.

Claims (4)

1. the limitation output pwm of a kind of breakthrough MCU hardware method, it is characterised in that comprise the following steps:
S1, initialization clock configuration, the continuous clock that one 8 are configured in MCU overflow interruption;
, after the time of setting, there is an interruption in S2, normal operation;And
S3, judge whether I/O output identifications are true, when I/O output identifications are true, low level time is to clock in heavily loaded pwm Timer, I/O output identifications are set to false, I/O mouthfuls of output low levels, then repeat step S2;When I/O output identifications be fictitious time, High level time is to clock timer in heavily loaded pwm, and I/O output identifications are set to true, I/O mouthfuls of output high level, then repeats to walk Rapid S2;
In step S3, low level time meets following formula in heavily loaded pwm:
Tl=(255-Dc+Dd)*t
In formula, Tl represents low level time in pwm, and t represents MCU instruction cycle, and Dc represents adjustable duty cycle number, Dd tables Show the corresponding numerical value of dutycycle.
2. the limitation output pwm of breakthrough MCU hardware according to claim 1 method, it is characterised in that in step S2, The time of the setting meets following formula:
Tx=255*t
In formula, Tx represents the time apart from next interruption, and t represents MCU instruction cycle.
3. the limitation output pwm of breakthrough MCU hardware according to claim 2 method, it is characterised in that in step S3, High level time meets following formula in heavily loaded pwm:
Th=(255-Dd)*t
In formula, Th represents high level time in pwm, and t represents MCU instruction cycle, and Dd represents the corresponding numerical value of dutycycle.
4. the limitation output pwm of breakthrough MCU hardware according to claim 3 method, it is characterised in that MCU I/O mouths The pwm waveforms that the final output stable cycle is T, the cycle T meets formula:
T=Th+Tl=Dc*t (1)
In formula, T represents pwm cycle, and t represents the MCU instruction cycles, and Dc represents adjustable duty cycle number;
The dutycycle of the pwm waveforms is(Dd/Dc)*100%;
According to formula(1)It can draw, the frequency of MCU I/O mouth final output pwm waveforms meets formula:
Fpwm=1/T=1/(Dc*t)
In formula, Dc represents adjustable duty cycle number, and t represents MCU instruction cycle.
CN201510211221.8A 2015-04-29 2015-04-29 A kind of limitation output pwm of breakthrough MCU hardware method Active CN104796118B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510211221.8A CN104796118B (en) 2015-04-29 2015-04-29 A kind of limitation output pwm of breakthrough MCU hardware method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510211221.8A CN104796118B (en) 2015-04-29 2015-04-29 A kind of limitation output pwm of breakthrough MCU hardware method

Publications (2)

Publication Number Publication Date
CN104796118A CN104796118A (en) 2015-07-22
CN104796118B true CN104796118B (en) 2017-09-26

Family

ID=53560678

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510211221.8A Active CN104796118B (en) 2015-04-29 2015-04-29 A kind of limitation output pwm of breakthrough MCU hardware method

Country Status (1)

Country Link
CN (1) CN104796118B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105446417B (en) * 2014-08-21 2018-07-27 Tcl集团股份有限公司 A kind of method and system obtaining high precision timing signal

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6995592B2 (en) * 2003-11-06 2006-02-07 Stmicroelectronics Pvt. Ltd. Method and system for generating variable frequency cyclic waveforms using pulse width modulation
CN1996729A (en) * 2006-12-23 2007-07-11 深圳市拓邦电子科技股份有限公司 Multi-channel PWM generation system and method
US7348755B2 (en) * 2003-12-18 2008-03-25 The Boeing Company Time sliced DSP operation for very high frequency pulse width modulated controllers
CN103312300A (en) * 2013-06-24 2013-09-18 哈尔滨工业大学 Pulse-width modulation (PWM) signal generator based on field programmable gate array (FPGA)

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1653618A3 (en) * 2004-10-29 2008-05-28 STMicroelectronics Pvt. Ltd. A PWM generator providing improved duty cycle resolution

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6995592B2 (en) * 2003-11-06 2006-02-07 Stmicroelectronics Pvt. Ltd. Method and system for generating variable frequency cyclic waveforms using pulse width modulation
US7348755B2 (en) * 2003-12-18 2008-03-25 The Boeing Company Time sliced DSP operation for very high frequency pulse width modulated controllers
CN1996729A (en) * 2006-12-23 2007-07-11 深圳市拓邦电子科技股份有限公司 Multi-channel PWM generation system and method
CN103312300A (en) * 2013-06-24 2013-09-18 哈尔滨工业大学 Pulse-width modulation (PWM) signal generator based on field programmable gate array (FPGA)

Also Published As

Publication number Publication date
CN104796118A (en) 2015-07-22

Similar Documents

Publication Publication Date Title
ATE554443T1 (en) INSTRUCTION-DRIVEN DATA PROCESSING DEVICE AND METHOD
TW200616317A (en) Method and apparatus for intelligently setting dead time
CN103427419A (en) Active power filter selective harmonic compensation control method
CN103401425B (en) Control circuit and digital power control circuit for power converter
CN104919704B (en) Complementary output generator block
CN100561395C (en) Timer construction and microcontroller and light ballast resistor with this timer construction
CN104796118B (en) A kind of limitation output pwm of breakthrough MCU hardware method
CN107743682A (en) Extremely low power crystal oscillator with adaptive self-starting
TW200603430A (en) System and method for controlling LED indicator
US8432208B2 (en) Maintaining pulse width modulation data-set coherency
CN102624368A (en) Pulse width modulation implementation method for random switching frequency of power electronic device
US9356579B2 (en) Waveform generation
US20150115856A1 (en) Motor drive controller and motor drive control method
CN204759104U (en) Bassinet control assembly
CN104702251B (en) Timer-based PWM (Pulse Width Modulation) wave generation method
CN105811971A (en) Counter-based variable frequency clock source and FPGA device
CN205121471U (en) Computer power control system
CN105487597A (en) Clock management method and device of central processing unit
CN203204421U (en) Circuit board of electric clothes hanging rack
CN106059400B (en) A kind of motor HALL rate smoothing processing method
CN206226395U (en) A kind of switching frequency pulse generation device high
JP2014108021A (en) Pwm output device
CN104970689B (en) A kind of power supply self study electric cooker
CN204030148U (en) A kind of power board device that can arbitrary timing control in 24 hours
CN202939448U (en) Network servo controller based on microprocessor

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address

Address after: 518000 Guangdong province Shenzhen Guangming New District Gongming street Gongming South Avenue Geya Technology Building 3 building 1-4 layer

Patentee after: Shenzhen Zhenbang intelligent Polytron Technologies Inc

Address before: 518000 Guangdong, Nanshan District, Taoyuan, Longjing street, industrial zone, building A, building 2, building A, building on the ground floor, building B, building, building 6, building C, block B, building, building No. 3

Patentee before: SHENZHEN ZHENBANG INTELLIGENT TECHNOLOGY CO., LTD.

CP03 Change of name, title or address