Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale...
-
Upload
blaze-lane -
Category
Documents
-
view
216 -
download
2
Transcript of Freescale Semiconductor Confidential and Proprietary Information. Freescale™ and the Freescale...
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. 2005.
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. 2005.
Slide 2
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. 2005.
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. 2005.
Slide 4
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. 2005.
Slide 5
TPM Function Overview
Input Capture (IC)
Output Compare (OC)
PWM
CPWM
When the CPWM control bit CPMWS In TPM status and control register Is cleared, each channel In TPM can be
configured 1 of 3 functionality listed In
left box
When the CPWM control bit CPMWS In TPM status and control
register Is set, all channels In TPM will
be configured In CPWM functionality
CPWMS0 1
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. 2005.
Slide 6
Architectural Components
TPM1
TPM1SC
TPM1CnVH:L
TPM1CnSC
TPMMODH:L
TPM1CNTH:L
TPM1CLK
TPM1CH0
TPM1CH1
TPM1CH2
TPM1CH3
TPM1CH4
TPM1CH5
Clock source/prescaler
TPM counter
TPM modulo value
Channel function select
Channel value
TPM1 Registers TPM1 PinsH/W Layer
LLD Layer
Char TPM_Init(TPMConfig* tpm1cfg)
void isr_TMR1_Chnl1(void);
Char InputCapture(UCHAR IC_Chnl,UCHAR IC_Mode,void (*CaptureEvent)(void))
Void TPM1_Disable(void)
Void TPM1_Enable(void)
Char OutputCompare(UCHAR OC_Chnl,UCHAR OC_Mode,UINT ChnlVal,void (*CompareEvent)(void))
HAL Layer
Char TPMChnl_Init(TPMChnlConfig* TPMChnlCfg);
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. 2005.
Slide 7
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. 2005.
Slide 8
Architectural Components Interface
Operation Level Function Name
Module Level char TPM_Init(TPMConfig* TPMCfg);
Module Events1.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. 2005.
Slide 9
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 Members Description
UCHAR TPM TPM module selection bit, 1: TPM1, 2 : TPM2
UCHAR CPWMS CPWM select bit, 1:CPWMS,0:other functions
UCHAR ClkSrc TPM clock source select
UCHAR Prescaler prescaler of TPM
UINT reg_TPMMOD the 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. 2005.
Slide 10
TPM channel configuration structure
typedef struct TPMChnlConfig_t
{
UCHAR Channel;
UCHAR Mode;
UINT reg_TPMCnV;
void (*ChnlEvent)(void);
}TPMChnlConfig;
Structure Members Description
UCHAR Channel TPM channel selection, refer to the tpm_drv.h
UCHAR Mode Channel mode selection, refer to the tpm_drv.h
UINT reg_TPMCnV Channel 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. 2005.
Slide 11
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. 2005.
Slide 12
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. 2005.
Slide 13
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. 2005.
Slide 14
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. 2005.
Slide 15
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. 2005.