static void startAudioHiFi() { backupPreMozziTimer1(); // pwm on timer 1 pinMode(AUDIO_CHANNEL_1_highByte_PIN, OUTPUT); // set pin to output for audio, use 3.9k resistor pinMode(AUDIO_CHANNEL_1_lowByte_PIN, OUTPUT); // set pin to output for audio, use 499k resistor Timer1.initializeCPUCycles(16000000UL/125000, FAST); // set period for 125000 Hz fast pwm carrier frequency = 14 bits Timer1.pwm(AUDIO_CHANNEL_1_highByte_PIN, 0); // pwm pin, 0% duty cycle, ie. 0 signal Timer1.pwm(AUDIO_CHANNEL_1_lowByte_PIN, 0); // pwm pin, 0% duty cycle, ie. 0 signal backupMozziTimer1(); // audio output interrupt on timer 2, sets the pwm levels of timer 1 setupTimer2(); }
void setupCNModuleAnd_IR_PIR_Input() { //T2 used to sample IR Input signals setupTimer2(); //IR INPUT mPORTDSetPinsDigitalIn(BIT_7); //D5 IR Input (CN16 module, RD7) //PIR input mPORTBSetPinsDigitalIn(BIT_2); //A1 PIR Input (CN4 module, RB2) // setup the change notice options //(ensure that CN continues working in sleep mode) mCNOpen(CN_OFF | CN_IDLE_CON, CN16_ENABLE | CN4_ENABLE, CN16_PULLUP_ENABLE | CN4_PULLUP_ENABLE); // read port(s) to clear mismatch mPORTDReadBits(BIT_7); mPORTBReadBits(BIT_2); mPORTBReadBits(BIT_4); // configure interrupts and clear change notice interrupt flag ConfigIntCN(CHANGE_INT_ON | CHANGE_INT_PRI_3); mCNClearIntFlag(); // Clear interrupt flag }