我的系统要实现两个互为90度相位差的PWM输出,考虑来去,决定用板子IC内的12-bit Interval Timer 来实现, Interval Timer时钟选用外部低速时钟,设定比较值为32,使能中断,
初始化部分如下
- /* supply IT clock RTC and 12bit interval timer enable*/
- RTCEN = 1U;
- /* disable IT operation */
- ITMC.itmc = _0000_IT_OPERATION_DISABLE;
- /* disable INTIT interrupt */
- ITMK = 1U;
- /* clear INTIT interrupt flag */
- ITIF = 0U;
- /* Set INTIT level 1 priority */
- ITPR1 = 0U;
- ITPR0 = 1U;
- /* Set the compare value */
- ITMC.itmc = _0020_ITMCMP_VALUE;
- IT_compare_value = _0020_ITMCMP_VALUE;
源代码这里下载:
src.rar
(73.25 KB)
(下载次数: 8, 2013-10-16 15:30 上传)
实现的结果用仿真器仿真,效果很好,如下图
[
本帖最后由 shower.xu 于 2013-10-16 15:30 编辑 ]