在线时间461 小时
UID2023373
注册时间2013-7-5
NXP金币40
TA的每日心情 | 开心 2018-7-2 06:04 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]初来乍到
金牌会员
 
- 积分
- 6020
- 最后登录
- 2020-9-28
|
发表于 2014-1-8 13:03:38
|
显示全部楼层
回复:k10的cmp总是能进入中断 但是检测不出来上升或下降标志?求大神指点
这个是CMP初始化函数
static void hscmp_init(void)
{
//Enable HSCMP module clock
SIM_SCGC4 |= (SIM_SCGC4_CMP_MASK );
//Set up HSCMP0 in NVIC. ISR put into vector table in isr.h file
enable_irq(INT_CMP0-16); //CMP0 Vector is 39. IRQ# is 39-16=23
// Configure CMP.
CMP_CR0_REG(CMP0_BASE_PTR) = 0x00; // Filter and digital hysteresis disabled
CMP_CR1_REG(CMP0_BASE_PTR) = 0x15; // Continuous mode, high-speed compare, unfiltered output, output pin disabled
CMP_FPR_REG(CMP0_BASE_PTR) = 0x00; // Filter disabled
CMP_SCR_REG(CMP0_BASE_PTR) = 0x1E; // Enable rising and falling edge interrupts, clear flags
CMP_DACCR_REG(CMP0_BASE_PTR) = 0xF0; // 6-bit reference DAC enabled, output set to vdd/64*(48+1)= 2.53v, (Vin selected is vin2=Vdd)
CMP_MUXCR_REG(CMP0_BASE_PTR) = 0x0F; // P-input as external channel 1. M-input as 6b DAC = 2.53v, it is adjustable with CMP_DACCR_REG
CMP_CR1_REG(CMP0_BASE_PTR) |= CMP_CR1_OPE_MASK; // Enable output pin for HSCMP0.
} |
|