PIC单片机控制AS3933接收和发送
IRQ_COUNT = 0;
// all I/O digital
AD1PCFG = 0xFFFF;
// set as output
TRISA = ~0x001C;
TRISB = ~0xE01F;
// turn on internal pull ups for switch
BUTTON_INTERNAL_PULL_UP = 1;
EXT_INT_VBUS_INTERNAL_PULL_UP = 0;
// set up spi interface
/* route SDI1 to pin RP5 (RA0) */
RPINR20bits.SDI1R = 5;
/* route pin RP4 (RB4) to SDO1 */
RPOR2bits.RP4R = 7;
/* route pin RP3 (RB3) to SCK1 */
RPOR1bits.RP3R = 8;
// /* route pin RP2 (RB2) to SS1 */
// RPOR1bits.RP2R = 9;
// enable external interrupt for wake pin
/* route INT1 to pin RP8 () */
RPINR0bits.INT1R = 8;
INTCON2bits.INT1EP = 0; // on positive edge
IPC5bits.INT1IP = 3; // middle priority
IFS1bits.INT1IF = 0; // clear pending interrupts
IEC1bits.INT1IE = 1; // enable interrupt
// enable capture for frequency measurement (CL_DAT, 32 kHz oscillator)
/* route IC1 to pin RP6 (RA1) */
RPINR7bits.IC1R = 6;
// IC1 gets set up every time we need it
//IPC0bits.IC1IP = 4; // middle priority
//IEC0bits.IC1IE = 1; // enable interrupt
// enable capture for frequency measurement (DAT, LFxP on LCO (125 kHz))
/* route IC2 to pin RP7 (RB7) */
RPINR7bits.IC2R = 7;
1