32 volatile uint16_t* p33c_PwmGenerator_Handles[]={
33 &PG1CONL, &PG2CONL, &PG3CONL, &PG4CONL,
34 &PG5CONL, &PG6CONL, &PG7CONL, &PG8CONL
36 #elif defined (PG4CONL) 37 volatile uint16_t* p33c_PwmGenerator_Handles[]={
38 &PG1CONL, &PG2CONL, &PG3CONL, &PG4CONL
41 #pragma message "selected device has no supported PWM generators" 64 volatile uint16_t p33c_PwmModule_Initialize(
void)
66 volatile uint16_t retval=1;
68 retval = p33c_PwmModule_ConfigWrite(pwmConfigDefault);
93 volatile uint16_t p33c_PwmModule_Dispose(
void)
95 volatile uint16_t retval=1;
97 retval = p33c_PwmModule_ConfigWrite(pwmConfigClear);
121 pwm = p33c_PwmModule_GetHandle();
146 volatile uint16_t p33c_PwmModule_ConfigWrite(
volatile struct P33C_PWM_MODULE_s pwmConfig)
148 volatile uint16_t retval=1;
152 pwm = p33c_PwmModule_GetHandle();
180 pg = p33c_PwmGenerator_GetHandle(pgInstance);
203 volatile uint16_t p33c_PwmGenerator_ConfigWrite(
204 volatile uint16_t pgInstance,
208 volatile uint16_t retval=1;
212 pg = p33c_PwmGenerator_GetHandle(pgInstance);
213 if (pg == NULL)
return(0);
237 volatile uint16_t p33c_PwmGenerator_Initialize(
volatile uint16_t pgInstance)
239 volatile uint16_t retval=1;
244 pg = p33c_PwmGenerator_GetHandle(pgInstance);
245 if (pg == NULL)
return(0);
248 retval &= p33c_PwmGenerator_Disable(pg);
252 retval &= p33c_PwmGenerator_ConfigWrite(pgInstance, pgConfigClear);
279 volatile uint16_t p33c_PwmGenerator_Dispose(
volatile uint16_t pgInstance)
281 volatile uint16_t retval=1;
284 p33c_PwmGenerator_ConfigWrite(pgInstance, pgConfigClear);
307 volatile uint16_t retval=1;
308 volatile uint16_t timeout=0;
310 if(pg == NULL)
return(0);
329 while((!PCLKCONbits.HRRDY) && (timeout++<5000));
330 if ((timeout >= 5000) || (PCLKCONbits.HRERR))
359 volatile uint16_t retval=1;
361 if(pg == NULL)
return(0);
395 volatile uint16_t retval=1;
397 if(pg == NULL)
return(0);
424 volatile uint16_t retval=1;
450 volatile uint16_t p33c_PwmGenerator_SetPeriod(
452 volatile uint16_t period
455 volatile uint16_t retval=1;
483 volatile uint16_t p33c_PwmGenerator_SetDutyCycle(
485 volatile uint16_t duty
488 volatile uint16_t retval=1;
517 volatile uint16_t p33c_PwmGenerator_SetDeadTimes(
519 volatile uint16_t dead_time_rising,
520 volatile uint16_t dead_time_falling
523 volatile uint16_t retval=1;
525 if(pg == NULL)
return(0);
552 volatile uint16_t retval=1;
559 retval = (
volatile uint16_t)
560 (((
volatile uint16_t)&pg->
PGxCONL - (
volatile uint16_t)&PG1CONL) / P33C_PWMGEN_SFR_OFFSET) + 1;
562 if (retval > P33C_PG_COUNT)
584 volatile uint16_t retval=1;
585 volatile uint16_t pgInstance;
592 pgInstance = p33c_PwmGenerator_GetInstance(pg);
595 if (pgInstance > P33C_PG_COUNT)
597 else if (pgInstance > 4)
639 volatile uint16_t p33c_PwmGenerator_SyncGenerators(
641 volatile uint16_t pgMotherTriggerOutput,
643 volatile bool ChildImmediateUpdate
646 volatile uint16_t retval=1;
647 volatile uint16_t pgMotherInstance=0;
648 volatile uint16_t pgChildInstance=0;
649 volatile uint16_t pgMotherGroup=0;
650 volatile uint16_t pgChildGroup=0;
651 volatile uint16_t pgInstance;
654 if ((pgHandleMother == NULL) || (pgHandleChild == NULL))
658 pgMotherInstance = p33c_PwmGenerator_GetInstance(pgHandleMother);
659 pgMotherGroup = p33c_PwmGenerator_GetGroup(pgHandleMother);
661 pgChildInstance = p33c_PwmGenerator_GetInstance(pgHandleChild);
662 pgChildGroup = p33c_PwmGenerator_GetGroup(pgHandleChild);
673 pgHandleMother->
PGxEVTL.
bits.PGTRGSEL = (pgMotherTriggerOutput & 0x0003);
676 pgHandleChild->
PGxCONH.
bits.UPDMOD = (0b010 | ChildImmediateUpdate);
694 if (pgMotherGroup == pgChildGroup)
699 if (pgMotherGroup == 1)
700 pgHandleChild->
PGxCONH.
bits.SOCS = pgMotherInstance;
701 else if (pgMotherGroup == 2)
702 pgHandleChild->
PGxCONH.
bits.SOCS = (pgMotherInstance - 4);
712 pgInstance = p33c_PwmGenerator_GetInstance(pgHandleChild);
745 .vFSCL.value = 0x0000,
746 .vFSMINPER.value = 0x0000,
747 .vMPHASE.value = 0x0000,
748 .vMDC.value = 0x0000,
749 .vMPER.value = 0x0000,
750 .vLFSR.value = 0x0000,
751 .vCMBTRIGL.value = 0x0000,
752 .vCMBTRIGH.value = 0x0000,
753 .LOGCON_A.value = 0x0000,
754 .LOGCON_B.value = 0x0000,
755 .LOGCON_C.value = 0x0000,
756 .LOGCON_D.value = 0x0000,
757 .LOGCON_E.value = 0x0000,
758 .LOGCON_F.value = 0x0000,
759 .PWMEVT_A.value = 0x0000,
760 .PWMEVT_B.value = 0x0000,
761 .PWMEVT_C.value = 0x0000,
762 .PWMEVT_D.value = 0x0000,
763 .PWMEVT_E.value = 0x0000,
764 .PWMEVT_F.value = 0x0000
785 .vFSCL.value = 0x0000,
786 .vFSMINPER.value = 0x0000,
787 .vMPHASE.value = 0x0000,
788 .vMDC.value = 0x0000,
789 .vMPER.value = 0x0000,
790 .vLFSR.value = 0x0000,
791 .vCMBTRIGL.value = 0x0000,
792 .vCMBTRIGH.value = 0x0000,
793 .LOGCON_A.value = 0x0000,
794 .LOGCON_B.value = 0x0000,
795 .LOGCON_C.value = 0x0000,
796 .LOGCON_D.value = 0x0000,
797 .LOGCON_E.value = 0x0000,
798 .LOGCON_F.value = 0x0000,
799 .PWMEVT_A.value = 0x0000,
800 .PWMEVT_B.value = 0x0000,
801 .PWMEVT_C.value = 0x0000,
802 .PWMEVT_D.value = 0x0000,
803 .PWMEVT_E.value = 0x0000,
804 .PWMEVT_F.value = 0x0000
828 .PGxCONH.value = 0x0000,
829 .PGxSTAT.value = 0x0000,
830 .PGxIOCONL.value = 0x0000,
831 .PGxIOCONH.value = 0x0000,
832 .PGxEVTL.value = 0x0000,
833 .PGxEVTH.value = 0x0000,
834 .PGxFPCIL.value = 0x0000,
835 .PGxFPCIH.value = 0x0000,
836 .PGxCLPCIL.value = 0x0000,
837 .PGxCLPCIH.value = 0x0000,
838 .PGxFFPCIL.value = 0x0000,
839 .PGxFFPCIH.value = 0x0000,
840 .PGxSPCIL.value = 0x0000,
841 .PGxSPCIH.value = 0x0000,
842 .PGxLEBL.value = 0x0000,
843 .PGxLEBH.value = 0x0000,
844 .PGxPHASE.value = 0x0000,
845 .PGxDC.value = 0x0000,
846 .PGxDCA.value = 0x0000,
847 .PGxPER.value = 0x0000,
848 .PGxTRIGA.value = 0x0000,
849 .PGxTRIGB.value = 0x0000,
850 .PGxTRIGC.value = 0x0000,
851 .PGxDTL.value = 0x0000,
852 .PGxDTH.value = 0x0000,
853 .PGxCAP.value = 0x0000
union P33C_PWM_GENERATOR_s::@279 PGxSPCIL
union P33C_PWM_MODULE_s::@212 vPCLKCON
union P33C_PWM_GENERATOR_s::@270 PGxIOCONH
union P33C_PWM_GENERATOR_s::@286 PGxPER
union P33C_PWM_GENERATOR_s::@271 PGxEVTL
union P33C_PWM_GENERATOR_s::@266 PGxCONL
union P33C_PWM_GENERATOR_s::@269 PGxIOCONL
struct tagPG1CONLBITS bits
union P33C_PWM_GENERATOR_s::@290 PGxDTL
union P33C_PWM_GENERATOR_s::@282 PGxLEBH
union P33C_PWM_GENERATOR_s::@291 PGxDTH
union P33C_PWM_GENERATOR_s::@268 PGxSTAT
union P33C_PWM_GENERATOR_s::@267 PGxCONH
union P33C_PWM_GENERATOR_s::@284 PGxDC