📄 cc6.c
字号:
/// - dead time generation is enabled
/// - generation interrupt on flag ICC61R is disabled
/// - generation interrupt on flag ICC61F is disabled
CCU6_CC61SRL = 0x00; // load CCU6 capture/compare shadow register
// low for channel 1
CCU6_CC61SRH = 0x80; // load CCU6 capture/compare shadow register
// high 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 '1'
/// - 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 '1'
/// - dead time generation is enabled
/// - generation interrupt on flag ICC62R is disabled
/// - generation interrupt on flag ICC62F is disabled
CCU6_CC62SRL = 0x00; // load CCU6 capture/compare shadow register
// low for channel 2
CCU6_CC62SRH = 0x40; // load CCU6 capture/compare shadow register
// high for channel 2
/// -----------------------------------------------------------------------
/// 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 = 0x3F; // 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 = 0x33; // load CCU6 T12 campture/compare mode
// select register low
CCU6_T12MSELH = 0x03; // load CCU6 T12 campture/compare mode
// select register high
/// -----------------------------------------------------------------------
/// Configuration of Passive State Level Register
/// -----------------------------------------------------------------------
CCU6_PSLR = 0x3F; // 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 = 0x2A; // load CCU6 compare status register high
/// -----------------------------------------------------------------------
/// Configuration of CCU6 module input signals:
/// -----------------------------------------------------------------------
/// - signal CC60_0 is used as output
/// - signal CC61_0 is used as output
/// - signal CC62_0 is used as output
/// - 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 = 0x00; // 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 COUT60_0 Output
/// Pin P3.2 is used as CC61_0 Output
/// Pin P3.3 is used as COUT61_0 Output
/// Pin P3.4 is used as CC62_0 Output
/// Pin P3.5 is used as COUT62_0 Output
SFR_PAGE(_pp2, noSST); // switch to page 2
P3_ALTSEL0 |= 0x3F; // set AltSel0
P3_ALTSEL1 &= ~(ubyte)0x3F; // set AltSel1
SFR_PAGE(_pp0, noSST); // switch to page 0
P3_DIR |= 0x3F; // 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
// USER CODE BEGIN (Init,3)
// USER CODE END
} // End of function CC6_vInit
// USER CODE BEGIN (CCU6_General,10)
// USER CODE END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -