コード例 #1
0
ファイル: motors.c プロジェクト: mhahnenberg/zoidberg
void motorSetup(void){
  
  //Setup output compare
  CloseOC1();
  CloseOC2();

  //Configure output compare using Timer 3
  ConfigIntOC1(OC_INT_OFF & OC_INT_PRIOR_5);
  ConfigIntOC2(OC_INT_OFF & OC_INT_PRIOR_5);

  PR3 = MOTOR_PWM_PERIOD;
  T3CONbits.TON = 1;
  T3CONbits.TSIDL = 1;
  T3CONbits.TGATE = 0;
  T3CONbits.TCKPS = 0b10; //prescaling 1:64
  T3CONbits.TCS = 0;
 

  OpenOC1(OC_IDLE_CON & OC_TIMER3_SRC & OC_PWM_FAULT_PIN_DISABLE , 0x00,0x00 );
  OpenOC2(OC_IDLE_CON & OC_TIMER3_SRC & OC_PWM_FAULT_PIN_DISABLE , 0x00,0x00 );

  //Write decent values to the control values
   motorSet(0.0,0.0, MOTOR_MODE_COAST);

}
コード例 #2
0
ファイル: wiring_analog.c プロジェクト: rmd6502/chipKIT32-MAX
//************************************************************************
void turnOffPWM(uint8_t timer)
{
	switch(timer)
	{
	#ifdef _OCMP1
		case TIMER_OC1:	CloseOC1();	break;
	#endif

	#ifdef _OCMP2
		case TIMER_OC2:	CloseOC2();	break;
	#endif

	#ifdef _OCMP3
		case TIMER_OC3:	CloseOC3();	break;
	#endif

	#ifdef _OCMP4
		case TIMER_OC4:	CloseOC4();	break;
	#endif

	#ifdef _OCMP5
		case TIMER_OC5:	CloseOC5();	break;
	#endif

	}
}
コード例 #3
0
ファイル: PWM.c プロジェクト: sdajani/sdp
/****************************************************************************
 Function
     PWM_end

 Parameters
     None.

 Returns
     None

 Description
     Disables the PWM sub-system.

 Notes
     Simply releases the lines and disables the timer

 Author
    Max Dunne, 2011.11.14
 ****************************************************************************/
void PWM_end(void) {
    CloseTimer2();
    CloseOC1();
    CloseOC2();
    CloseOC3();
    CloseOC4();
    CloseOC5();
    usedChannels=0;

}
コード例 #4
0
ファイル: External.c プロジェクト: lopezjm2001/DuinoMite
void ClearExternalIO(void) {
	int i;

//	GS I2C Start
	i2c_disable();
	i2c_slave_disable();
//	GS I2C End

	if (SerialConsole != 1) SerialClose(1);
	if (SerialConsole != 2) SerialClose(2);
	if (SerialConsole != 3) SerialClose(3);
	if (SerialConsole != 4) SerialClose(4);

	// stop the sound
	SoundPlay = 0;
	CloseTimer2();
#ifdef OLIMEX
	CloseOC1();
#else
	CloseOC2();
#endif
	inttbl[NBRPINS + 2].intp = NULL;					// disable the tick interrupt
	for (i = 1; i < NBRPINS + 1; i++) {
		inttbl[i].intp = NULL;						// disable all interrupts
#ifdef OLIMEX
    #ifdef  OLIMEX_DUINOMITE_EMEGA
		if (ExtCurrentConfig[i] != EXT_CONSOLE_RESERVED && i != 35 ) {	// don't reset the serial console
    #else
		if (ExtCurrentConfig[i] != EXT_CONSOLE_RESERVED && i != 21 ) {	// don't reset the serial console
    #endif
#else
		if (ExtCurrentConfig[i] != EXT_CONSOLE_RESERVED) {              // don't reset the serial console
#endif
			ExtCfg(i, EXT_NOT_CONFIG);                              // all set to unconfigured
			ExtSet(i, 0);						// all outputs (when set) default to low
		}
	}
        InterruptReturn = NULL;
}


/****************************************************************************************************************************
Initialise the I/O pins
*****************************************************************************************************************************/
void initExtIO(void) {
	int i;

	for (i = 1; i < NBRPINS + 1; i++) {
		ExtCfg(i, EXT_NOT_CONFIG);                                      // all set to unconfigured
		ExtSet(i, 0);							// all outputs (when set) default to low
	}
#ifndef OLIMEX
 	CNCONbits.ON = 1;       						// turn on Change Notification module
 	CNPUEbits.CNPUE1 = 1;							// turn on the pullup for pin C13 also called CN1
#endif
	ExtCurrentConfig[0] = EXT_DIG_IN;                                       // and show that we can read from it
	P_LED_TRIS = P_OUTPUT; 							// make the LED pin an output
	ExtSet(0, 0);								// and turn it off
#ifdef OLIMEX
    #ifdef OLIMEX_DUINOMITE_EMEGA
	ExtCurrentConfig[35] = EXT_ANA_IN;
    #else
	ExtCurrentConfig[21] = EXT_ANA_IN;
    #endif
#endif

	// setup the analog (ADC) function
	AD1CON1 = 0x00E0;       						// automatic conversion after sampling
 	AD1CSSL = 0;       							// no scanning required
	AD1CON2 = 0;       							// use MUXA, use AVdd   &   AVss as Vref+/-
	AD1CON3 = 0x203; //0x1F3F;  							// Tsamp = 32 x Tad;
	AD1CON1bits.ADON = 1; 							// turn on the ADC

}


/****************************************************************************************************************************
Configure an I/O pin
Returns true if all is OK
*****************************************************************************************************************************/
int ExtCfg(int pin, int cfg) {
	int tris, ana, oc;

	if (pin < 0 || pin > NBRPINS) return false;						// initial sanity check

	// make sure that interrupts are disabled in case we are changing from an interrupt input
#ifdef OLIMEX
//	if (pin == 5) ConfigINT2(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_DISABLE);
//	if (pin == 6) ConfigINT3(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_DISABLE);
        #ifdef  OLIMEX_DUINOMITE_EMEGA
        #else
                if (pin == 7) ConfigINT4(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_DISABLE);
        #endif
#else
	if (pin == 11) ConfigINT1(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_DISABLE);
	if (pin == 12) ConfigINT2(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_DISABLE);
	if (pin == 13) ConfigINT3(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_DISABLE);
	if (pin == 14) ConfigINT4(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_DISABLE);
#endif

	inttbl[pin].intp = NULL;		// also disable a software interrupt on this pin

	switch (cfg) {
		case EXT_NOT_CONFIG:
//	#ifdef OLIMEX
//			if (pin == 5) {P_E5_TRIS = 1; P_E5_OC = 1;}
//			if (pin == 6) {P_E6_TRIS = 1; P_E6_OC = 1;}
//			if (pin == 11) {P_E11_TRIS = 1; P_E11_OC = 1;}
//			if (pin == 12) {P_E12_TRIS = 1; P_E12_OC = 1;}
//	#endif
			tris = 1; ana = 1; oc = 1;
			break;

		case EXT_ANA_IN:
//	#ifdef OLIMEX
			if (pin > 6 && pin < 19) return false;
//			if (pin == 5) {P_E5_TRIS = 1; P_E5_OC = 1;}
//			if (pin == 6) {P_E6_TRIS = 1; P_E6_OC = 1;}
//	#else
//			if (pin > 10) return false;
//	#endif
			tris = 1; ana = 0; oc = 1;
			break;

		case EXT_FREQ_IN:											// same as counting, so fall through
		case EXT_PER_IN:											// same as counting, so fall through
		case EXT_CNT_IN:
//	#ifdef OLIMEX
//	#else
//			if (pin == 11) {
//				INT1Count = INT1Value = 0;
//				ConfigINT1(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_ENABLE);
//				tris = 1; ana = 1; oc = 1;
//				break;
//			}
//	#endif
//	#ifdef OLIMEX
//			if (pin == 5) {
//				P_E5_TRIS = 1;
//				P_E5_OC = 1;
//	#else
//			if (pin == 12) {
//	#endif
//				INT2Count = INT2Value = 0;
//				ConfigINT2(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_ENABLE);
//				tris = 1; ana = 1; oc = 1;
//				break;
//			}
//	#ifdef OLIMEX
//			if (pin == 6) {
//				P_E6_TRIS = 1;
//				P_E6_OC = 1;
//	#else
//			if (pin == 13) {
//	#endif
//				INT3Count = INT3Value = 0;
//				ConfigINT3(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_ENABLE);
//				tris = 1; ana = 1; oc = 1;
//				break;
//			}
#ifdef  OLIMEX_DUINOMITE_EMEGA
                    break;
#else
	#ifdef OLIMEX
			if (pin == 7) {
	#else
			if (pin == 14) {
	#endif
				INT4Count = INT4Value = 0;
				ConfigINT4(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_ENABLE);
				tris = 1; ana = 1; oc = 1;
				break;
			}
			return false;							// not an interrupt enabled pin
#endif

		case EXT_INT_LO:											// same as digital input, so fall through
		case EXT_INT_HI:											// same as digital input, so fall through
		case EXT_DIG_IN:
	#ifdef OLIMEX
//                        if (pin == 5) {P_E5_TRIS = 1; P_E5_OC = 1;}
//			if (pin == 6) {P_E6_TRIS = 1; P_E6_OC = 1;}
//			if (pin == 11) {P_E11_TRIS = 1; P_E11_OC = 1;}
//			if (pin == 12) {P_E12_TRIS = 1; P_E12_OC = 1;}
	#endif
			tris = 1; ana = 1; oc = 1;
			break;

		case EXT_DIG_OUT:
	#ifdef OLIMEX
//			if (pin == 11) {P_E11_TRIS = 1; P_E11_OC = 1;} //return false;
//			if (pin == 5) {P_E5_TRIS = 1; P_E5_OC = 1;}
//			if (pin == 6) {P_E6_TRIS = 1; P_E6_OC = 1;}
//			if (pin == 12) {P_E12_TRIS = 1; P_E12_OC = 1;}
	#endif
			tris = 0; ana = 1; oc = 0;
			break;

		case EXT_OC_OUT:
	#ifdef OLIMEX
//			if (pin == 11) {P_E11_TRIS = 1; P_E11_OC = 1;} //return false;
//			if (pin == 5) {P_E5_TRIS = 1; P_E5_OC = 1;}
//			if (pin == 6) {P_E6_TRIS = 1; P_E6_OC = 1;}
//			if (pin == 12) {P_E12_TRIS = 1; P_E12_OC = 1;}
	#else
			if (pin < 11) return false;
	#endif
			tris = 0; ana = 1; oc = 1;
			break;

		case EXT_COM_RESERVED:
		case EXT_CONSOLE_RESERVED:
			ExtCurrentConfig[pin] = cfg;		// don't do anything except set the config type
		#ifdef OLIMEX
//			if (pin == 5) {P_E5_TRIS = 1; P_E5_OC = 1; P_E5_ANALOG = 1;}
//			if (pin == 6) {P_E6_TRIS = 1; P_E6_OC = 1; P_E6_ANALOG = 1;}
//			if (pin == 11) {P_E11_TRIS = 1; P_E11_OC = 1;}
//			if (pin == 12) {P_E12_TRIS = 1; P_E12_OC = 1;}
		#endif
			return true;

		default:
			return false;
	}

	ExtCurrentConfig[pin] = cfg;

	// set the TRIS and analog characteristics
	switch (pin) {
		case 1:  P_E1_TRIS = tris;   P_E1_OC = oc;   P_E1_ANALOG = ana;		break;
		case 2:  P_E2_TRIS = tris;   P_E2_OC = oc;   P_E2_ANALOG = ana;		break;
		case 3:  P_E3_TRIS = tris;   P_E3_OC = oc;   P_E3_ANALOG = ana;		break;
		case 4:  P_E4_TRIS = tris;   P_E4_OC = oc;   P_E4_ANALOG = ana;		break;
		case 5:  P_E5_TRIS = tris;   P_E5_OC = oc;   P_E5_ANALOG = ana;		break;
		case 6:  P_E6_TRIS = tris;   P_E6_OC = oc;   P_E6_ANALOG = ana;		break;
	#ifdef OLIMEX
            #ifdef  OLIMEX_DUINOMITE_EMEGA
		case 7:  P_E7_TRIS = tris;   P_E7_OC = oc;   P_E7_ANALOG = ana;		break;
		case 8:  P_E8_TRIS = tris;   P_E8_OC = oc;   break;
		case 9:  P_E9_TRIS = tris;   P_E9_OC = oc;   break;
		case 10: P_E10_TRIS = tris;  P_E10_OC = oc;  break;
            #else
		case 7:  P_E7_TRIS = tris;   P_E7_OC = oc;	              break;
 		case 8:  if (!S.SDEnable) { P_E8_TRIS = tris; P_E8_OC = oc;}  break;
		case 9:  if (!S.SDEnable) { P_E9_TRIS = tris; P_E9_OC = oc;}  break;
		case 10: if (!S.SDEnable) { P_E10_TRIS = tris; P_E10_OC = oc;} break;
            #endif
	#else
		case 7:  P_E7_TRIS = tris;   P_E7_OC = oc;   P_E7_ANALOG = ana;		break;
		case 8:  P_E8_TRIS = tris;   P_E8_OC = oc;   P_E8_ANALOG = ana;		break;
		case 9:  P_E9_TRIS = tris;   P_E9_OC = oc;   P_E9_ANALOG = ana;		break;
		case 10: P_E10_TRIS = tris;  P_E10_OC = oc;  P_E10_ANALOG = ana;	break;
	#endif
		case 11: P_E11_TRIS = tris;  P_E11_OC = oc;			break;
		case 12: P_E12_TRIS = tris;  P_E12_OC = oc;			break;
		case 13: P_E13_TRIS = tris;  P_E13_OC = oc;			break;
		case 14: P_E14_TRIS = tris;  P_E14_OC = oc;			break;
		case 15: P_E15_TRIS = tris;  P_E15_OC = oc;			break;
		case 16: P_E16_TRIS = tris;  P_E16_OC = oc;			break;
		case 17: P_E17_TRIS = tris;  P_E17_OC = oc;			break;
		case 18: P_E18_TRIS = tris;  P_E18_OC = oc;			break;
	#ifdef OLIMEX
            // SPP +
            #ifdef	OLIMEX_DUINOMITE_EMEGA		// edit for DuinoMite eMega
		case 19: P_E19_TRIS = tris;  P_E19_OC = oc;			break;
		case 20: P_E20_TRIS = tris;  P_E20_OC = oc;                     break;
                case 21: P_E21_TRIS = tris;  P_E21_OC = oc;			break;
		case 22: P_E22_TRIS = tris;  P_E22_OC = oc;			break;
		case 23: P_E23_TRIS = tris;  P_E23_OC = oc;			break;
		case 24: P_E24_TRIS = tris;  P_E24_OC = oc;			break;
		case 25: P_E25_TRIS = tris;  P_E25_OC = oc;			break;
		case 26: P_E26_TRIS = tris;  P_E26_OC = oc;			break;
		case 27: P_E27_TRIS = tris;  P_E27_OC = oc;			break;
		case 28: P_E28_TRIS = tris;  P_E28_OC = oc;			break;
		case 29: P_E29_TRIS = tris;  P_E29_OC = oc;			break;
		case 30: P_E30_TRIS = tris;  P_E30_OC = oc;			break;
		case 31: P_E31_TRIS = tris;  P_E31_OC = oc; P_E31_ANALOG = ana;	break;
		case 32: P_E32_TRIS = tris;  P_E32_OC = oc; P_E31_ANALOG = ana;	break;
		case 33: P_E33_TRIS = tris;  P_E33_OC = oc;			break;
		case 34: P_E34_TRIS = tris;  P_E34_OC = oc;			break;
		case 35: P_E35_TRIS = tris;  P_E35_OC = oc; P_E31_ANALOG = ana; break;
		case 36: P_E36_TRIS = tris;  P_E36_OC = oc;			break;
		case 37: P_E37_TRIS = tris;  P_E37_OC = oc;			break;
		case 38: P_E38_TRIS = tris;  P_E38_OC = oc;			break;
		case 39: P_E39_TRIS = tris;  P_E39_OC = oc;			break;
            #else	// original by Geoff Graham for DuinoMite Mega
		case 19: //if (!S.VideoMode) {
                    P_E19_TRIS = tris; P_E19_OC = oc; P_E19_ANALOG = ana;//}
                break;
		case 20: if (!S.VideoMode || P_VGA_COMP) {P_E20_TRIS = tris; P_E20_OC = oc; P_E20_ANALOG = ana;} break;
		case 21: P_E21_TRIS = tris;  P_E21_OC = oc;  P_E21_ANALOG = ana;		break;
                case 22: P_E22_TRIS = tris;  P_E22_OC = oc; break;
                case 23: P_E23_TRIS = tris;  P_E23_OC = oc; break;
            #endif
            // SPP -
	#else
		case 19: P_E19_TRIS = tris;  P_E19_OC = oc;			break;
		case 20: P_E20_TRIS = tris;  P_E20_OC = oc;			break;
	#endif
	#ifdef UBW32
                case 21: P_E21_TRIS = tris;  P_E21_OC = oc;			break;
		case 22: P_E22_TRIS = tris;  P_E22_OC = oc;			break;
		case 23: P_E23_TRIS = tris;  P_E23_OC = oc;			break;
		case 24: P_E24_TRIS = tris;  P_E24_OC = oc;			break;
		case 25: P_E25_TRIS = tris;  P_E25_OC = oc;			break;
		case 26: P_E26_TRIS = tris;  P_E26_OC = oc;			break;
		case 27: P_E27_TRIS = tris;  P_E27_OC = oc;			break;
		case 28: P_E28_TRIS = tris;  P_E28_OC = oc;			break;
		case 29: P_E29_TRIS = tris;  P_E29_OC = oc;			break;
		case 30: P_E30_TRIS = tris;  P_E30_OC = oc;			break;
		case 31: P_E31_TRIS = tris;  P_E31_OC = oc;			break;
		case 32: P_E32_TRIS = tris;  P_E32_OC = oc;			break;
		case 33: P_E33_TRIS = tris;  P_E33_OC = oc;			break;
		case 34: P_E34_TRIS = tris;  P_E34_OC = oc;			break;
		case 35: P_E35_TRIS = tris;  P_E35_OC = oc;			break;
		case 36: P_E36_TRIS = tris;  P_E36_OC = oc;			break;
		case 37: P_E37_TRIS = tris;  P_E37_OC = oc;			break;
		case 38: P_E38_TRIS = tris;  P_E38_OC = oc;			break;
		case 39: P_E39_TRIS = tris;  P_E39_OC = oc;			break;
		case 40: P_E40_TRIS = tris;  P_E40_OC = oc;			break;
		case 41: P_E41_TRIS = tris;  P_E41_OC = oc;			break;
		case 42: P_E42_TRIS = tris;  P_E42_OC = oc;			break;
		case 43: P_E43_TRIS = tris;  P_E43_OC = oc;			break;
		case 44: P_E44_TRIS = tris;  P_E44_OC = oc;			break;
		case 45: P_E45_TRIS = tris;  P_E45_OC = oc;			break;
		case 46: P_E46_TRIS = tris;  P_E46_OC = oc;			break;
		case 47: P_E47_TRIS = tris;  P_E47_OC = oc;			break;
		case 48: P_E48_TRIS = tris;  P_E48_OC = oc;			break;
		case 49: P_E49_TRIS = tris;  P_E49_OC = oc;			break;
		case 50: P_E50_TRIS = tris;  P_E50_OC = oc;			break;
	#endif
	}

	if (cfg == EXT_NOT_CONFIG) ExtSet(pin, 0);						// set the default output to low
	return true;
}


/****************************************************************************************************************************
Set the output of a digital I/O pin
Returns true if all is OK
*****************************************************************************************************************************/
int ExtSet(int pin, int val){
	val = (val != 0);							// non zero is on
	INTDisableInterrupts();				// setting an output bit is NOT atomic and a bit set operation
																// in an interrupt could result in this set corrupting the output
	switch (pin) {
	#ifdef UBW32
		case 0:  P_LED_OUT = !val;  break;		// this is the LED - the UBW32 wired them upside down !!
	#else
		case 0:  P_LED_OUT = val;  break;			// this is the LED
	#endif
		case 1:  P_E1_OUT = val;   break;
		case 2:  P_E2_OUT = val;   break;
		case 3:  P_E3_OUT = val;   break;
		case 4:	 P_E4_OUT = val;   break;
		case 5:	 P_E5_OUT = val;   break;
		case 6:	 P_E6_OUT = val;   break;
		case 7:	 P_E7_OUT = val;   break;
	#ifdef OLIMEX
            #ifdef  OLIMEX_DUINOMITE_EMEGA
		case 8:	 P_E8_OUT = val;   break;
		case 9:	 P_E9_OUT = val;   break;
		case 10: P_E10_OUT = val;  break;
            #else
		case 8:	 if (!S.SDEnable) P_E8_OUT = val;   break;
		case 9:	 if (!S.SDEnable) P_E9_OUT = val;   break;
		case 10: if (!S.SDEnable) P_E10_OUT = val;  break;
            #endif
	#else
		case 8:	 P_E8_OUT = val;   break;
		case 9:	 P_E9_OUT = val;   break;
		case 10: P_E10_OUT = val;  break;
	#endif
		case 11: P_E11_OUT = val;  break;
		case 12: P_E12_OUT = val;  break;
		case 13: P_E13_OUT = val;  break;
		case 14: P_E14_OUT = val;  break;
		case 15: P_E15_OUT = val;  break;
		case 16: P_E16_OUT = val;  break;
		case 17: P_E17_OUT = val;  break;
		case 18: P_E18_OUT = val;  break;
	#ifdef OLIMEX
            #ifdef  OLIMEX_DUINOMITE_EMEGA
                case 19: P_E19_OUT = val; break;
                case 20: P_E20_OUT = val; break;
            #else
		case 19: P_E19_OUT = val;  break;
		case 20: if (!S.VideoMode || P_VGA_COMP) P_E20_OUT = val;  break;
                case 22: P_E22_OUT = val ; break;
                case 23: P_E23_OUT = val ; break;
            #endif
        #else
		case 19: P_E19_OUT = val;  break;
		case 20: P_E20_OUT = val;  break;
	#endif
        #if defined UBW32 || defined OLIMEX_DUINOMITE_EMEGA
		case 21: P_E21_OUT = val;	break;
		case 22: P_E22_OUT = val;	break;
		case 23: P_E23_OUT = val;	break;
		case 24: P_E24_OUT = val;	break;
		case 25: P_E25_OUT = val;	break;
		case 26: P_E26_OUT = val;	break;
		case 27: P_E27_OUT = val;	break;
		case 28: P_E28_OUT = val;	break;
		case 29: P_E29_OUT = val;	break;
		case 30: P_E30_OUT = val;	break;
		case 31: P_E31_OUT = val;	break;
		case 32: P_E32_OUT = val;	break;
		case 33: P_E33_OUT = val;	break;
		case 34: P_E34_OUT = val;	break;
		case 35: P_E35_OUT = val;	break;
		case 36: P_E36_OUT = val;	break;
		case 37: P_E37_OUT = val;	break;
		case 38: P_E38_OUT = val;	break;
		case 39: P_E39_OUT = val;	break;
        #endif
        #ifdef UBW32
		case 40: P_E40_OUT = val;	break;
		case 41: P_E41_OUT = val;	break;
		case 42: P_E42_OUT = val;	break;
		case 43: P_E43_OUT = val;	break;
		case 44: P_E44_OUT = val;	break;
		case 45: P_E45_OUT = val;	break;
		case 46: P_E46_OUT = val;	break;
		case 47: P_E47_OUT = val;	break;
		case 48: P_E48_OUT = val;	break;
		case 49: P_E49_OUT = val;	break;
		case 50: P_E50_OUT = val;	break;
	#endif
		default:
			INTEnableInterrupts();
			return false;
	}
	INTEnableInterrupts();
	return true;
}
コード例 #5
0
ファイル: pwm.c プロジェクト: ChakChel/Ix
/**
 * @fn      void pwmClose( void );
 * @brief   Fermeture de l'Output Compare 1
 */
void pwmClose( void ) {
    
    CloseOC1();
}
コード例 #6
0
*****************************************************************************************************************/void __ISR( _TIMER_4_VECTOR, ipl1) T4Interrupt(void) {

	/////////////////////////// count up timers /////////////////////////////////////
	//if(ExtCurrentConfig[11] == EXT_PER_IN) INT1Count++;			// if we are measuring period increment the count
	if(ExtCurrentConfig[5] == EXT_PER_IN) INT2Count++;
	if(ExtCurrentConfig[6] == EXT_PER_IN) INT3Count++;
	if(ExtCurrentConfig[7] == EXT_PER_IN) INT4Count++;
	mSecTimer++;                                                            // used by the TIMER function
	TickTimer++;								// used in the interrupt tick
	PauseTimer++;								// used by the PAUSE command
	IntPauseTimer++;							// used by the PAUSE command inside an interrupt
	InkeyTimer++;								// used to delay on an escape character
	if(++CursorTimer > CURSOR_OFF + CURSOR_ON) CursorTimer = 0;		// used to control cursor blink rate
//	GS I2C Start
	if (I2C_Timer) {
		if (--I2C_Timer == 0) {
			I2C_Status |= I2C_Status_Timeout;
			mI2C1MSetIntFlag();
		}
	}
	if (I2C_Status & I2C_Status_MasterCmd) {
		if (!(I2C1STAT & _I2C1STAT_S_MASK)) {
			I2C_Status &= ~I2C_Status_MasterCmd;
			I2C_State = I2C_State_Start;
			I2C1CONSET =_I2C1CON_SEN_MASK;
		}
	}
//	GS I2C End
#ifdef MAXIMITE
	if(SDActivityLED) {
		P_SD_LED_SET_HI;
		SDActivityLED--;
	} else
		P_SD_LED_SET_LO;
#endif
	
	if(SD_CD) SDCardRemoved = true;

	// check if the sound has expired
	if(SoundPlay > 0) {												// if we are still playing the sound
		SoundPlay--;
		if(SoundPlay == 0) {
			CloseTimer2();
#ifdef MAXIMITE
        CloseOC2();
#endif
#ifdef OLIMEX
        CloseOC1();
#endif
		}
	}		


	//////////////////////////////// keep track of the date and time ////////////////////////////////
	////////////////////////////////// this code runs once a second /////////////////////////////////
	if(++SecondsTimer >= 1000) {
		SecondsTimer = 0;											// reset every second
                if(S.ScreenSave){           //if screen saver is enabled count it down
                if(ScreenSaveTime >0)
                    ScreenSaveTime--;
                else
                mT3IntEnable(0);        // turn off video int
                }
                //if(ExtCurrentConfig[11] == EXT_FREQ_IN) { INT1Value = INT1Count; INT1Count = 0; }
		if(ExtCurrentConfig[5] == EXT_FREQ_IN) { INT2Value = INT2Count; INT2Count = 0; }
		if(ExtCurrentConfig[6] == EXT_FREQ_IN) { INT3Value = INT3Count; INT3Count = 0; }
		if(ExtCurrentConfig[7] == EXT_FREQ_IN) { INT4Value = INT4Count; INT4Count = 0; }
#ifdef MAXMITE
                if(++second >= 60) {										// keep track of the time and date
			second = 0 ;
			if(++minute >= 60) {
				minute = 0;
				if(++hour >= 24) {
					hour = 0;
					if(++day > DaysInMonth[month + ((month == 2 && (year % 4) == 0)?1:0)]) {
						day = 1;
						if(++month > 12) {
							month = 1;
							year++;
						}
					}
				}
			}
		}
#endif
        }

    // Clear the interrupt flag
    mT4ClearIntFlag();
    //return;
}