删除 CC6.C
This commit is contained in:
396
CC6.C
396
CC6.C
@@ -1,396 +0,0 @@
|
||||
//****************************************************************************
|
||||
// @Module Capture / Compare Unit 6 (CCU6)
|
||||
// @Filename CC6.C
|
||||
// @Project CL2.0.dav
|
||||
//----------------------------------------------------------------------------
|
||||
// @Controller Infineon XC886CLM-8FF
|
||||
//
|
||||
// @Compiler Keil
|
||||
//
|
||||
// @Codegenerator 1.3
|
||||
//
|
||||
// @Description This file contains functions that use the CCU6 module.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2025/3/28 16:46:42
|
||||
//
|
||||
//****************************************************************************
|
||||
|
||||
// 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 CC6_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 their reset state.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Returnvalue None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Parameters None
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// @Date 2025/3/28
|
||||
//
|
||||
//****************************************************************************
|
||||
|
||||
// USER CODE BEGIN (Init,1)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
void CC6_vInit(void)
|
||||
{
|
||||
// USER CODE BEGIN (Init,2)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
SFR_PAGE(_cc1, noSST); // switch to page 1
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Timer Control Register
|
||||
/// -----------------------------------------------------------------------
|
||||
|
||||
CCU6_TCTR0L = 0x00; // load CCU6 timer control register 0 low
|
||||
CCU6_TCTR0H = 0x00; // load CCU6 timer control register 0 high
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of CCU6 Timer 12:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - timer 12 Input clock selected is 1
|
||||
/// - the additional prescaler for T12 is enabled.
|
||||
/// - timer 12 run bit is set
|
||||
/// - single shot mode is disabled
|
||||
/// - timer 12 works in edge aligned mode
|
||||
/// - interrupt on period match is disabled
|
||||
/// - interrupt on one match is disabled
|
||||
|
||||
CCU6_T12PRL = 0x5F; // load CCU6 T12 period register low
|
||||
CCU6_T12PRH = 0x09; // load CCU6 T12 period register lhigh
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of CCU6 Timer 13:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - Timer T13 Input clock selected is 1
|
||||
/// - The additional prescaler for T13 is disabled
|
||||
/// - timer 13 run bit is set
|
||||
/// - single shot mode is disabled
|
||||
/// - interrupt on period match is disabled
|
||||
/// - interrupt on compare match is disabled
|
||||
|
||||
CCU6_T13PRL = 0x5F; // load CCU6 T13 period register low
|
||||
CCU6_T13PRH = 0x09; // load CCU6 T13 period register high
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Dead-Time Control Register for Timer T12
|
||||
/// -----------------------------------------------------------------------
|
||||
|
||||
CCU6_T12DTCL = 0x01; // load CCU6 dead time control register low
|
||||
// for timer T12
|
||||
|
||||
CCU6_T12DTCH = 0x03; // load CCU6 dead time control register high
|
||||
// for timer T12
|
||||
|
||||
SFR_PAGE(_cc0, noSST); // switch to page 0
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of CCU6 Channel 0:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - compare mode 1 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'
|
||||
/// - dead time generation is enabled
|
||||
|
||||
/// - generation interrupt on flag ICC60R is disabled
|
||||
/// - generation interrupt on flag ICC60F is disabled
|
||||
|
||||
CCU6_CC60SRL = 0x60; // load CCU6 capture/compare shadow register
|
||||
// low for channel 0
|
||||
CCU6_CC60SRH = 0x09; // load CCU6 capture/compare shadow register
|
||||
// high for channel 0
|
||||
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of CCU6 Channel 1:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - compare mode 1 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'
|
||||
/// - dead time generation is enabled
|
||||
|
||||
/// - generation interrupt on flag ICC61R is disabled
|
||||
/// - generation interrupt on flag ICC61F is disabled
|
||||
|
||||
CCU6_CC61SRL = 0x60; // load CCU6 capture/compare shadow register
|
||||
// low for channel 1
|
||||
CCU6_CC61SRH = 0x09; // load CCU6 capture/compare shadow register
|
||||
// high for channel 1
|
||||
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of CCU6 Channel 2:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - channel 2 is disabled
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of CCU6 Channel 3:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - T13 output is not inverted
|
||||
|
||||
|
||||
CCU6_CC63SRL = 0x00; // load CCU6 capture/compare shadow register
|
||||
// low for channel 3
|
||||
CCU6_CC63SRH = 0x00; // load CCU6 capture/compare shadow register
|
||||
// high for channel 3
|
||||
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Multi-Channel Mode Output Register
|
||||
/// -----------------------------------------------------------------------
|
||||
|
||||
CCU6_MCMOUTSL = 0x00; // load CCU6 multi channel mode output
|
||||
// control register low
|
||||
CCU6_MCMOUTSH = 0x00; // load CCU6 multi channel mode output
|
||||
// control register high
|
||||
|
||||
SFR_PAGE(_cc2, noSST); // switch to page 2
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Timer Control Register
|
||||
/// -----------------------------------------------------------------------
|
||||
|
||||
CCU6_TCTR2L = 0x00; // load CCU6 timer control register 2 low
|
||||
CCU6_TCTR2H = 0x00; // load CCU6 timer control register 2 high
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// 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_TRPCTRL = 0x00; // load CCU6 trap control register low
|
||||
CCU6_TRPCTRH = 0x00; // load CCU6 trap control register high
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Multi Channel Mode:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - multi channel mode is disabled
|
||||
|
||||
CCU6_MODCTRL = 0x05; // load CCU6 modulation control register low
|
||||
CCU6_MODCTRH = 0x00; // load CCU6 modulation control register high
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Multi_Channel Mode Control Register
|
||||
/// -----------------------------------------------------------------------
|
||||
|
||||
CCU6_MCMCTR = 0x00; // load CCU6 multi channel mode control
|
||||
// register
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of T12 Capture/Compare Mode Select Register
|
||||
/// -----------------------------------------------------------------------
|
||||
|
||||
CCU6_T12MSELL = 0x11; // load CCU6 T12 campture/compare mode
|
||||
// select register low
|
||||
|
||||
CCU6_T12MSELH = 0x00; // load CCU6 T12 campture/compare mode
|
||||
// select register high
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Passive State Level Register
|
||||
/// -----------------------------------------------------------------------
|
||||
|
||||
CCU6_PSLR = 0x00; // load CCU6 passive state level register low
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of CCU6 interrupt control:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - for channel 0 interrupts is node I0 selected
|
||||
/// - for channel 1 interrupts is node I0 selected
|
||||
/// - for channel 2 interrupts is node I0 selected
|
||||
/// - for correct hall event interrupt is node I0 selected
|
||||
/// - for error interrupts is node I0 selected
|
||||
/// - for T12 interrupts is node I0 selected
|
||||
/// - for T13 interrupts is node I0 selected
|
||||
|
||||
CCU6_INPL = 0x00; // load CCU6 capture/compare interrupt node
|
||||
// pointer register low
|
||||
CCU6_INPH = 0x00; // load CCU6 capture/compare interrupt node
|
||||
// pointer register high
|
||||
|
||||
CCU6_IENL = 0x00; // load CCU6 capture/compare interrupt
|
||||
// enable register low
|
||||
CCU6_IENH = 0x00; // load CCU6 capture/compare interrupt
|
||||
// enable register high
|
||||
|
||||
SFR_PAGE(_cc3, noSST); // switch to page 3
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of Compare State Register
|
||||
/// -----------------------------------------------------------------------
|
||||
|
||||
CCU6_CMPSTATH = 0x00; // load CCU6 compare status register high
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of CCU6 module input signals:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - signal CC60_0 is used as output
|
||||
/// - signal CC61_2 is used as output
|
||||
/// - signal CC62 is not used
|
||||
/// - signal #CTRAP is not used
|
||||
|
||||
CCU6_PISEL0L = 0x00; // load CCU6 Port Input Select Register 0 Low
|
||||
|
||||
/// - signal CCPOS0 is not used
|
||||
/// - signal CCPOS1 is not used
|
||||
/// - signal CCPOS2 is not used
|
||||
/// - signal T12HR is not used
|
||||
|
||||
CCU6_PISEL0H = 0x3F; // load CCU6 Port Input Select Register 0
|
||||
// High
|
||||
|
||||
/// - signal T13HR is not used
|
||||
|
||||
CCU6_PISEL2 = 0x00; // load CCU6 Port Input Select Register 2
|
||||
|
||||
|
||||
/// Pin P3.0 is used as CC60_0 Output
|
||||
/// Pin P3.1 is used as CC61_2 Output
|
||||
|
||||
SFR_PAGE(_pp2, noSST); // switch to page 2
|
||||
|
||||
P3_ALTSEL0 |= 0x01; // set AltSel0
|
||||
P3_ALTSEL1 &= ~(ubyte)0x01; // set AltSel1
|
||||
|
||||
P3_ALTSEL0 &= ~(ubyte)0x02; // set AltSel0
|
||||
P3_ALTSEL1 |= 0x02; // set AltSel1
|
||||
|
||||
SFR_PAGE(_pp0, noSST); // switch to page 0
|
||||
P3_DIR |= 0x03; // set Direction as Output
|
||||
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Configuration of the used CCU6 Channels Interrupts:
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - capture/compare interrupt node 0 is disabled
|
||||
/// - capture/compare interrupt node 1 is disabled
|
||||
/// - capture/compare interrupt node 2 is disabled
|
||||
/// - capture/compare interrupt node 3 is disabled
|
||||
|
||||
SFR_PAGE(_cc0, noSST); // switch to page 0
|
||||
|
||||
/// -----------------------------------------------------------------------
|
||||
/// Timer Control Register
|
||||
/// -----------------------------------------------------------------------
|
||||
/// - enable shadow transfer to T12 and T13
|
||||
|
||||
CCU6_TCTR4L = 0x40; // load CCU6 timer control register 4 low
|
||||
|
||||
CCU6_TCTR4H = 0x40; // load CCU6 timer control register 4 high
|
||||
|
||||
/// Start timer settings
|
||||
|
||||
CCU6_TCTR4L = 0x02; // start timer 12
|
||||
|
||||
CCU6_TCTR4H = 0x02; // start timer 13
|
||||
|
||||
// USER CODE BEGIN (Init,3)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
} // End of function CC6_vInit
|
||||
|
||||
|
||||
// USER CODE BEGIN (CCU6_General,10)
|
||||
|
||||
// USER CODE END
|
||||
|
||||
Reference in New Issue
Block a user