?? ccu6.c
字號:
//****************************************************************************
// @Module Capture / Compare Unit 6 (CCU6)
// @Filename CCU6.C
// @Project T12_T13_AD_PEC.dav
//----------------------------------------------------------------------------
// @Controller Infineon XC164CM-8F40
//
// @Compiler Keil
//
// @Codegenerator 0.2
//
// @Description This file contains functions that use the CCU6 module.
//
//----------------------------------------------------------------------------
// @Date 2006-7-8 23:19:34
//
//****************************************************************************
// USER CODE BEGIN (CCU6_General,1)
// USER CODE END
//****************************************************************************
// @Project Includes
//****************************************************************************
#include "MAIN.H"
// USER CODE BEGIN (CCU6_General,2)
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (CCU6_General,3)
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (CCU6_General,4)
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (CCU6_General,5)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (CCU6_General,6)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN (CCU6_General,7)
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (CCU6_General,8)
// USER CODE END
//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************
// USER CODE BEGIN (CCU6_General,9)
// USER CODE END
//****************************************************************************
// @Function void CCU6_vInit(void)
//
//----------------------------------------------------------------------------
// @Description This is the initialization function of the CCU6 function
// library. It is assumed that the SFRs used by this library
// are in reset state.
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2006-7-8
//
//****************************************************************************
// USER CODE BEGIN (Init,1)
// USER CODE END
void CCU6_vInit(void)
{
// USER CODE BEGIN (Init,2)
// USER CODE END
/// -----------------------------------------------------------------------
/// Configuration of CCU6 Timer 12:
/// -----------------------------------------------------------------------
/// - prescaler factor is 1
/// - timer 12 run bit is set
/// - single shot mode is disabled
/// - timer 12 works in center aligned mode
/// - interrupt on period match is enabled
/// - interrupt on one match is disabled
CCU6_T12PR = 0x07CF; // load CCU6 T12 period register
/// -----------------------------------------------------------------------
/// Configuration of CCU6 Timer 13:
/// -----------------------------------------------------------------------
/// - prescaler factor is 1
/// - timer 13 run bit is reset
/// - T13 is started on a T12 compare event on channel 0, independent on
/// the count direction of T12
/// - single shot mode is enabled
/// - interrupt on period match is enabled
/// - interrupt on compare match is disabled
CCU6_T13PR = 0x0027; // load CCU6 T13 period register
CCU6_TCTR0 = 0x0080; // load CCU6 timer control register 0
CCU6_TCTR2 = 0x0066; // load CCU6 timer control register 2
/// -----------------------------------------------------------------------
/// Configuration of Multi Channel Mode:
/// -----------------------------------------------------------------------
/// - multi channel mode is disabled
/// -----------------------------------------------------------------------
/// Configuration of CCU6 Channel 0:
/// -----------------------------------------------------------------------
/// - compare mode 3 is selected
/// - T12 modulation for output CC60 is enabled
/// - T13 modulation for output CC60 is disabled
/// - the trap functionality of the pin CC60 is disabled
/// - the compare output CC60 drives passive level while CC60ST is '0'
/// - the passive level of the output CC60 is '0'
/// - T12 modulation for output COUT60 is enabled
/// - T13 modulation for output COUT60 is disabled
/// - the trap functionality of the pin COUT60 is disabled
/// - the compare output COUT60 drives passive level while CC60ST is '1'
/// - the passive level of the output COUT60 is '0'
/// - dead time generation is enabled
/// - generation interrupt on flag ICC60R is disabled
/// - generation interrupt on flag ICC60F is disabled
CCU6_CC60SR = 0x03E8; // load CCU6 capture/compare shadow register
// for channel 0
/// -----------------------------------------------------------------------
/// Configuration of CCU6 Channel 1:
/// -----------------------------------------------------------------------
/// - compare mode 3 is selected
/// - T12 modulation for output CC61 is enabled
/// - T13 modulation for output CC61 is disabled
/// - the trap functionality of the pin CC61 is disabled
/// - the compare output CC61 drives passive level while CC61ST is '0'
/// - the passive level of the output CC61 is '0'
/// - T12 modulation for output COUT61 is enabled
/// - T13 modulation for output COUT61 is disabled
/// - the trap functionality of the pin COUT61 is disabled
/// - the compare output COUT61 drives passive level while CC61ST is '1'
/// - the passive level of the output COUT61 is '0'
/// - dead time generation is enabled
/// - generation interrupt on flag ICC61R is disabled
/// - generation interrupt on flag ICC61F is disabled
CCU6_CC61SR = 0x03E8; // load CCU6 capture/compare shadow register
// for channel 1
/// -----------------------------------------------------------------------
/// Configuration of CCU6 Channel 2:
/// -----------------------------------------------------------------------
/// - compare mode 3 is selected
/// - T12 modulation for output CC62 is enabled
/// - T13 modulation for output CC62 is disabled
/// - the trap functionality of the pin CC62 is disabled
/// - the compare output CC62 drives passive level while CC62ST is '0'
/// - the passive level of the output CC62 is '0'
/// - T12 modulation for output COUT62 is enabled
/// - T13 modulation for output COUT62 is disabled
/// - the trap functionality of the pin COUT62 is disabled
/// - the compare output COUT62 drives passive level while CC62ST is '1'
/// - the passive level of the output COUT62 is '0'
/// - dead time generation is enabled
/// - generation interrupt on flag ICC62R is disabled
/// - generation interrupt on flag ICC62F is disabled
CCU6_CC62SR = 0x03E8; // load CCU6 capture/compare shadow register
// for channel 2
/// -----------------------------------------------------------------------
/// Configuration of CCU6 Channel 3:
/// -----------------------------------------------------------------------
/// - T13 output is not inverted
CCU6_CC63SR = 0x0000; // load CCU6 capture/compare shadow register
// for channel 3
CCU6_T12DTC = 0x0728; // load CCU6 dead time control register for
// timer T12
CCU6_T12MSEL = 0x0333; // load CCU6 T12 campture/compare mode
// select register
CCU6_CMPSTAT = 0x2A00; // load CCU6 compare status register
CCU6_PSLR = 0x0000; // load CCU6 passive state level register
CCU6_MODCTR = 0x003F; // load CCU6 modulation control register
CCU6_MCMOUTS = 0x0000; // load CCU6 multi channel mode output
// control register
CCU6_MCMCTR = 0x0000; // load CCU6 multi channel mode control
// register
/// - enable shadow transfer to T12 and T13
CCU6_TCTR4 = 0x4040; // load CCU6 timer control register 4
/// -----------------------------------------------------------------------
/// Configuration of CCU6 trap control:
/// -----------------------------------------------------------------------
/// - a trap can only be generated by SW by setting the bit TRPF
/// - the trap state is left when a zero-match of T12 (while counting up)
/// is detected (synchronization to T12)
/// - bit TRPF is automatically cleared by HW (according to TRPPEN, TRPM0
/// and TRPM1)
/// - trap interrupt is disabled
CCU6_TRPCTR = 0x0000; // load CCU6 trap control register
/// -----------------------------------------------------------------------
/// Configuration of CCU6 interrupt control:
/// -----------------------------------------------------------------------
/// - for channel 0 interrupts is node I2 selected
/// - for channel 1 interrupts is node I2 selected
/// - for channel 2 interrupts is node I2 selected
/// - for correct hall event interrupt is node I2 selected
/// - for error interrupts is node I2 selected
/// - for T12 interrupts is node I2 selected
/// - for T13 interrupts is node I2 selected
CCU6_INP = 0x2AAA; // load CCU6 capture/compare interrupt node
// pointer register
CCU6_IEN = 0x0280; // load CCU6 capture/compare interrupt
// enable register
/// -----------------------------------------------------------------------
/// Configuration of the used CCU6 Channel Port Pins:
/// -----------------------------------------------------------------------
/// - P1L.0 is used for CAPCOM6 output (CC60)
/// - P1L.2 is used for CAPCOM6 output (CC61)
/// - P1L.4 is used for CAPCOM6 output (CC62)
/// - P1L.1 is used for CAPCOM6 output (COUT60)
/// - P1L.3 is used for CAPCOM6 output (COUT61)
/// - P1L.5 is used for CAPCOM6 output (COUT62)
ALTSEL0P1L |= 0x003F; // select alternate output function
P1L = (P1L & ~(uword)0x003F) | 0x003F; //set data register
DP1L = (DP1L & ~(uword)0x003F) | 0x003F; //set direction register
/// -----------------------------------------------------------------------
/// Configuration of the used CCU6 Channels Interrupts:
/// -----------------------------------------------------------------------
/// NodeI2 service request node configuration:
/// - NodeI2 interrupt priority level (ILVL) = 13
/// - NodeI2 interrupt group level (GLVL) = 1
/// - NodeI2 group priority extension (GPX) = 0
CCU6_T12IC = 0x0075;
CCU6_TCTR4 = 0x0002; // load CCU6 timer control register 4
// USER CODE BEGIN (Init,3)
// USER CODE END
} // End of function CCU6_vInit
//****************************************************************************
// @Function void CCU6_viNodeI2(void)
//
//----------------------------------------------------------------------------
// @Description This is the interrupt service routine for the CCU6 node I2.
// If the content of the corresponding compare timer
// (configurable) equals the content of the capture/compare
// register or if a capture event occurs at the associated
// port pin, the interrupt request flag is set and an
// interrupt is triggered (only if enabled).
// Please note that you have to add application specific code
// to this function.
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2006-7-8
//
//****************************************************************************
// USER CODE BEGIN (NodeI2,1)
// USER CODE END
void CCU6_viNodeI2(void) interrupt CCU6_NodeI2_INT
{
// USER CODE BEGIN (NodeI2,2)
// USER CODE END
if(CCU6_IS & 0x0080) // if CCU6_IS_T12PM
{
// timer T12 period match detection
// USER CODE BEGIN (NodeI2,19)
// USER CODE END
CCU6_ISR = 0x0080; // clear flag CCU6_IS_T12PM
}
if(CCU6_IS & 0x0200) // if CCU6_IS_T13PM
{
// timer T13 period match detection
// USER CODE BEGIN (NodeI2,21)
// USER CODE END
CCU6_ISR = 0x0200; // clear flag CCU6_IS_T13PM
}
} // End of function CCU6_viNodeI2
// USER CODE BEGIN (CCU6_General,10)
// USER CODE END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -