| Moteur de recherche de fiches techniques de composants électroniques |
|
AN2618 Fiches technique(PDF) 13 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN2618 Fiches technique(HTML) 13 Page - STMicroelectronics |
|
13 / 23 page ![]() AN2618 Code example 3.etpuc_pwm.c 13/23 Appendix C Code example 3.etpuc_pwm.c #include <etpuc_PWM.h> /*--------------------------------------------------------------------+ | Global Variable Definitions | +--------------------------------------------------------------------*/ int DutyCycle = 500; /******************************************************************************** * FUNCTION: PWM * * PURPOSE: This is the eTPU function that modulate an eTPU output pin as PWM * * signal based on the host service request and the parameters passed * * from the host. * * * * INPUTS NOTES: This function has 2 parameters * * RETURNS NOTES: N/A * * * * WARNING: * ********************************************************************************/ void PWM(int Period, unsigned fract24 Duty) { static int StartTimeHi; int HighTime; if (hsr == hsrInitPWM) // Init PWM HSR -- Required to initialize the signal. { InitPWM: SetChannelMode(em_nb_dt); SetupMatch_B(tcr1, Mtcr1_Ctcr1_ge, low_high);//set output high immediately } else if (matchA_transB)// Here on Match1 (falling edge) { FallingMatch: ClearMatchALatch(); SetupMatch_B((StartTimeHi + Period), Mtcr1_Ctcr1_ge, low_high); //set up for rising match } else if (matchB_transA) // Here on Match2 (rising edge) { RisingMatch: ClearMatchBLatch(); StartTimeHi = GetCapRegB(); // Store the time the pulse transition to high if (Duty == 0xffffff) // Special case for 100% modulation { HighTime = 32 ; // arbitrary value having no efect on the output signal SetupMatch_A(HighTime, Mtcr1_Ctcr1_ge, match_no_change); } else { HighTime = Period * Duty + StartTimeHi; SetupMatch_A(HighTime, Mtcr1_Ctcr1_ge, high_low); //setup for falling match } } else |
|
|
Lien URL |
| ALLDATASHEET vous a-t-il été utile ? [ DONATE ] |
À propos de Alldatasheet | Publicité | Contactez-nous | Politique de confidentialité | Lien vers la fiche technique | Echange de liens | Fabricants All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |