金牌会员
- 积分
- 1375
- 威望
- 658
- 贡献
- 395
- 兑换币
- 416
- 注册时间
- 2013-6-8
- 在线时间
- 161 小时
|
下面是kl25的代码,可是不知道整两个函数相当于K60的哪个模块
void cmp_init ( unsigned char rising_falling )
{
// Filter and digital hysteresis disabled
CMP0_CR0 = 0x00;
// no sample(continuous), no window, -, HS mode,
// no invert, COUTA(unfiltered), output pin enable, moduledisable
CMP0_CR1 = CMP_CR1_PMODE_MASK | CMP_CR1_COS_MASK | CMP_CR1_OPE_MASK; //0x16;
// Filter disabled
CMP0_FPR = 0x00;
// Enable rising or falling edge interrupts, clear flags
CMP0_SCR = //CMP_SCR_IER_MASK |
rising_falling |
//CMP_SCR_IEF_MASK |
CMP_SCR_CFR_MASK |
CMP_SCR_CFF_MASK; //0x1E
// 6-bit DAC enabled, output set to 1/2-scale, Vdd reference
CMP0_DACCR = CMP_DACCR_DACEN_MASK |
CMP_DACCR_VRSEL_MASK |
CMP_DACCR_VOSEL(0x20); //0xE0;
// P-input as external channel 0, M-input as 6b DAC
CMP0_MUXCR = CMP_MUXCR_PSEL(0) |
CMP_MUXCR_MSEL(7); //0x07;
// enable CMP
CMP0_CR1 |= CMP_CR1_EN_MASK;
}
void cmp0_isr(void)
{
GPIOB_PSOR = 0x00080000; // set Port B 19 indicate wakeup
printf("\n[CMP0_ISR]****ISR entered*****\r\n\n");
printf("[CMP0_ISR]CMP0_SCR = %#02X ", (CMP0_SCR )) ;
if (CMP0_SCR & CMP_SCR_CFR_MASK) {
CMP0_SCR |= CMP_SCR_CFR_MASK;
printf(" CMP0_CFR set and is now clear \n");
printf("[CMP0_ISR]CMP0_SCR = %#02X ", (CMP0_SCR )) ;
}
if (CMP0_SCR & CMP_SCR_CFF_MASK) {
CMP0_SCR |= CMP_SCR_CFF_MASK;
printf(" CMP0_CFF set and is now clear \n");
printf("[CMP0_ISR]CMP0_SCR = %#02X ", (CMP0_SCR )) ;
}
return;
}
|
|