Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc TM AW60 Low Level Driver Design Training Freescale Semiconductor Inc
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 1 Agenda Timer/PWM Module (TPM) TPM Block Diagram Overview of TPM Functionality Architectural Components Modes of Operation Architectural Components Interface Demo Code Implement PWM and CPWM on the AW60 EVB.
Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc TM Timer/PWM Module (TPM)
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 3 TPM Block Diagram
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 4 TPM Function Overview
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 5 Architectural Components
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 6 Modes of Operation Mode, Edge and Level Selection
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 7 Architectural Components Interface Operation LevelFunction Name Module Levelchar TPM_Init(TPMConfig* TPMCfg); Module Events 1.void isr_TMR1_OV(void); 2.void isr_TMR2_OV(void); Channel Level 1. char TPMChnl_Init(TPMChnlConfig* TPMChnlCfg); 2. char InputCapture(UCHAR IC_Chnl,UCHAR IC_Mode,void (*CaptureEvent)(void)); 3. char OutputCompare(UCHAR OC_Chnl,UCHAR OC_Mode,UINT ChnlVal,void (*CompareEvent)(void)); 4. char PWM(UCHAR PWM_Chnl,UCHAR PWM_Mode,UINT ChnlVal,void (*PWMEvent)(void)); 5. char CPWM(UCHAR CPWM_Chnl,UCHAR CPWM_Mode,UINT ChnlVal,void (*CPWMEvent)(void)); Channel Events 1.void isr_TMR1_Chnl0(void); 2.void isr_TMR1_Chnl1(void); 3.void isr_TMR1_Chnl2(void); 4.void isr_TMR1_Chnl3(void); 5.void isr_TMR1_Chnl4(void); 6.void isr_TMR1_Chnl5(void); 7.void isr_TMR2_Chnl0(void); 8.void isr_TMR2_Chnl1(void);
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 8 TPM module configuration structure typedef struct TPMConfig_t { UCHAR TPM; UCHAR CPWMS; UCHAR ClkSrc; UCHAR Prescaler; UINT reg_TPMMOD; void (*TPMEvent)(void); }TPMConfig; Note: void (*TPMEvent)(void) is the function pointer pointing to user application space associated to the TPM interruption. Structure MembersDescription UCHAR TPMTPM module selection bit, 1: TPM1, 2 : TPM2 UCHAR CPWMSCPWM select bit, 1:CPWMS,0:other functions UCHAR ClkSrcTPM clock source select UCHAR Prescalerprescaler of TPM UINT reg_TPMMODthe variable in flash to store the configuration of TPMMODH:L void (*TPMEvent)(void) the function pointer points to the events invoked upon the interruption of TPM
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 9 TPM channel configuration structure typedef struct TPMChnlConfig_t { UCHAR Channel; UCHAR Mode; UINT reg_TPMCnV; void (*ChnlEvent)(void); }TPMChnlConfig; Structure MembersDescription UCHAR ChannelTPM channel selection, refer to the tpm_drv.h UCHAR ModeChannel mode selection, refer to the tpm_drv.h UINT reg_TPMCnVChannel value will pass to the register of TPMCnV void (*ChnlEvent)(void) Function pointer points to the events invoked upon the interruption of corresponding channel Note: void (*ChnlEvent)(void) is the function pointer pointing to user application associated to the corresponding TPM channel interruption.
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 10 Demo Code of TPM void main(void) { UCHAR icgmode,pt,re; EnableInterrupts; //enable interrupts /* include your code here */ /*GPIO test code */ pt = GPIO_InitPort(PORTA,&paconfig); pt = PTAD; pt = GPIO_SetPin(PORTA,PIN4); pt = PTAD; /*ICG test code*/ ICG_Init(&icgconfig); icgmode = Get_ICG_Mode(); /*TPM test code*/ re = TPM_Init(&tpm1cfg); //tpm1 module initialization re = PWM(CHNL10,CPWM_CO,200,NULL); //edge-aligned pwm,clear output on compare for(;;) { __RESET_WATCHDOG(); /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave this function */ }
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 11 PWM Wave Capture
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 12 CPWM Wave Capture
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 13 Thanks
TM Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc Slide 14 Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc