#include "p24hj128gp506.h"
#include "delay.h"
#include "Generic.h"
#include "incap.h"
#include "ports.h"
#include "timer.h"
#include "delay.h"
ulong ax=0;
UINT8 DataAvailable;
void __attribute__((interrupt,auto_psv)) _CNInterrupt (void)
{
// WriteTimer3(0X0000);
mPORTDToggleBits(IOPORT_BIT_0);
IFS1bits.CNIF = 0;
DataAvailable = 1;
}
void CN2_Init(void)
{
AD1PCFGL=0x000f;//奇怪,这里只能四个通道同时设置
IFS1bits.CNIF = 0;
ConfigCNPullups(IOPORT_BIT_2);
ConfigIntCN(CHANGE_INT_OFF & CHANGE_INT_PRI_4 &0x09000004);
EnableCN2;
}
int main(void)
{
mPORTDOutputConfig(IOPORT_BIT_0);
mPORTDSetBits(IOPORT_BIT_0);
osc_init();
CN2_Init();
while(1)
{
while(!DataAvailable); /*Wait for interrupt*/
{
DataAvailable = 0;
DisableCN2; /*Disable the interrupt*/
}
}
return 0;
}
文章评论(0条评论)
登录后参与讨论