Esempio n. 1
0
int main()
{
	uint16_t t1RawADC = 0;
	uint16_t t2RawADC = 0;
	float temp1 = 0;
	float temp2 = 0;

	initADC();
	lcd_init();
	while(1)
	{
		t1RawADC = readADC(TEMP1_ADC_CHANNEL);
		t2RawADC = readADC(TEMP2_ADC_CHANNEL);

		temp1 = convertRawADCToTemp(t1RawADC);
		temp2 = convertRawADCToTemp(t2RawADC);

		printTemperatures(temp1, temp2);
//		LCD_clear();
//		LCD_int(temp1);

		_delay_ms(100);
	}

}
Esempio n. 2
0
int main(void) {
	volatile int i = 0;
	volatile uint32_t resultat = 0;
  
  	initModesAndClock(); 				/* Initialize mode entries and system clock */
	initPeriClkGen();  					/* Initialize peripheral clock generation for DSPIs */
	disableWatchdog(); 					/* Disable watchdog */
	
    initPads();             			/* Initialize pads used in example */
  	initADC();              			/* Init. ADC for normal conversions but don't start yet*/
  	initCTU();              			/* Configure desired CTU event(s) */
  	initEMIOS_0();          			/* Initialize eMIOS channels as counter, SAIC, OPWM */
  	initEMIOS_0ch3();					/* Initialize eMIOS 0 channel 3 as OPWM and channel 2 as SAIC*/ 
  	
  	initEMIOS_0ch0(); 					/* Initialize eMIOS 0 channel 0 as modulus counter*/
	initEMIOS_0ch23(); 					/* Initialize eMIOS 0 channel 23 as modulus counter*/
	initEMIOS_0ch4(); 					/* Initialize eMIOS 0 channel 0 as OPWM, ch 4 as time base */
	initEMIOS_0ch6(); 					/* Initialize eMIOS 0 channel 0 as OPWM, ch 6 as time base */
	initEMIOS_0ch7(); 					/* Initialize eMIOS 0 channel 1 as OPWM, ch 7 as time base */
	
	init_LinFLEX_0_UART();
  
  
	SIU.PCR[16].R = 0x0100;				/* Potentiomètre en Input"

	/* Loop forever */
	for (;;) {
		reglerPotentio();
		// boutonLed();
		// SERVO();
	}
}
Esempio n. 3
0
void InitApp(void)
{
	/* Setup analog functionality and port direction */
	(PPSUnLock);

	TRISFbits.TRISF3 = 0;
	PORTFbits.RF3 = 1;
	PPSOutput(PPS_RP9, PPS_SCK1OUT);
	PPSOutput(PPS_RP8, PPS_SDO1);

	AD1PCFG = 0xFFFF; // Default all pins to digital

	AD1PCFGLbits.PCFG11 = 0; //Disable digital input on AN11

	/* Initialize peripherals */
	InitMatrixDisplay();

	spi1Init(PRI_PRESCAL_1_1);

	initHD44780LCD();

	initPWM();

	initADC();
}
Esempio n. 4
0
/**
 * Initialize all modules
 */
void initAll() {
    // initialize ADC
    initADC();
    
    // initialize system timer
    initTimer0();
    
    // initialize serial com
    uart_init();
    // redirect printf output to serial port
    stdout = &uart_stdout;
    
    // motor.c: initialize motor PWM, pins, encoders and PID
    initPWM1();
    initMotorPins();
    initEncoders();
    initTachoVariables();
    resetPID();
    
    // clear motor speed and direction just in case
    setDirection(LMOTOR, FORWARD);
    setDirection(RMOTOR, FORWARD);
    setPower100(LMOTOR, 0);
    setPower100(RMOTOR, 0);
    
    // odometer.c set initial position and position correction
    setOdometerTo(0, 0);
    updateRelativePos();
    resetPosCorrection();
}
Esempio n. 5
0
File: ex11.c Progetto: pbmartins/AC2
void configureAll(void) {
    initADC(nConvertions);                                  // Configure ADC with nConvertions = 8
    IFS1bits.AD1IF = 0;                                     // Rest AD1IF
    IPC6bits.AD1IP = 6;                                     // Configure interrupt priority
    IEC1bits.AD1IE = 1;                                     // Enable AD1 Interrupt

    // Configure Timer T1 (4 Hz, interrupts disabled)
    T1CONbits.TCKPS = 7;                                    // 1:256 prescaler (i.e fin = 78125 Hz)
    PR1 = 19530;                                            // Fout = 20MHz / (256 * (19530 + 1)) = 4 Hz
    TMR1 = 0;                                               // Reset timer T1 count register
    T1CONbits.TON = 1;                                      // Enable timer T1 (must be the last command of the timer configuration sequence)

    IFS0bits.T1IF = 0;                                      // Reset timer T1 interrupt flag
    IPC1bits.T1IP = 2;                                      // Interrupt priority (must be in range [1..6])
    IEC0bits.T1IE = 1;                                      // Enable timer T1 interrupts

    // Configure Timer T3 (100 Hz, interrupts disabled)
    T3CONbits.TCKPS = 5;                                    // 1:32 prescaler (i.e fin = 625000 Hz)
    PR3 = 6250;                                             // Fout = 20MHz / (32 * (6250 + 1)) = 100 Hz
    TMR3 = 0;                                               // Reset timer T1 count register
    T3CONbits.TON = 1;                                      // Enable timer T1 (must be the last command of the timer configuration sequence)

    IFS0bits.T3IF = 0;                                      // Reset timer T3 interrupt flag
    IPC3bits.T3IP = 2;                                      // Interrupt priority (must be in range [1..6])
    IEC0bits.T3IE = 1;                                      // Enable timer T3 interrupts

    // Configure UART1
    configUART(115200, 'N', 1);
    enableUARTInterrupts(0);

    TRISE = TRISE | 0x0F0;                                  // Configure RE4-RE7 as inputs
}
Esempio n. 6
0
// Functions
int initDevice() {
	int status=0;
	// Setup UART
	initUSART0STDIO(UBRR_MACRO);
	// Setup ADC
	initADC();
	// Setup BT
	initBT();
	// Wait for BT Connection
	#ifndef SIM
	while(!status)
		status = PING  & (1 << PING0);
	#endif
	// Enable Timer
	 initTimer();
	// Enable I2C
	initI2C();
	// Init wifi
	_delay_ms(310);
	DDRE |= (0x10|0x80|0x20) ; // PE4 = ~RST; PE7= ~WP; PE5=HIB;
	PORTE &= ~(0x80); // assert reset and WP
	PORTE |= (0x10 | 0x80); // deassert reset and WP
	PORTE &= ~(0x20); // De assert HIB
	// Enable ZG2100 Interrupt (use INT6)
	// Init wifi
	zg_init();
	ZG2100_ISR_ENABLE();
	// Enable Interrupts
	sei();
	return 0;
}
Esempio n. 7
0
void Setup(void) {

    PinSetMode();
    // setup internal clock for 72MHz/36MIPS
    // 12 /2 = 6  *24 = 144 / 2=72
    CLKDIVbits.PLLPRE = 0; // PLLPRE (N2) 0=/2c
    CLKDIVbits.DOZE = 0;
    PLLFBD = 22; // pll multiplier (M) = +2
    CLKDIVbits.PLLPOST = 0; // PLLPOST (N1) 0=/2   
    // Initiate Clock Switch to Primary Oscillator with PLL (NOSC = 0b011)
    __builtin_write_OSCCONH(0x03);
    __builtin_write_OSCCONL(OSCCON | 0x01);
    // Wait for Clock switch to occur
    while (OSCCONbits.COSC != 0b011);
    while (!OSCCONbits.LOCK); // wait for PLL ready


    INTCON1bits.NSTDIS = 1; //no nesting of interrupts
    timerOne();
    initADC();
    //timerTwo();
    begin(receiveArray, sizeof (receiveArray), SAS_ADDRESS, false, Send_put, Receive_get, Receive_available, Receive_peek);
    UART_init();
    //UART1_init();
    //begin(receiveArray1, sizeof (receiveArray1), SAS_ADDRESS, false, Send_put1, Receive_get1, Receive_available1, Receive_peek1);

}
int main(void) {

  float voltage;

  // -------- Inits --------- //
  initUSART();
  printString("\r\nDigital Voltmeter\r\n\r\n");
  initADC();
  setupADCSleepmode();

  // ------ Event loop ------ //

  while (1) {

    voltage = oversample16x() * VOLTAGE_DIV_FACTOR * REF_VCC / 4096;
    printFloat(voltage);
    /*  alternatively, just print it out:
     *  printWord(voltage*100);
     *  but then you have to remember the decimal place
     */
    _delay_ms(500);

  }                                                  /* End event loop */
  return 0;                            /* This line is never reached */
}
Esempio n. 9
0
int main ( void ) {
    // Initalize the a2d converter and the servo controller
    initADC();
    init_timer1_servos();

    // Forever run the servos
    while (1) {
        unsigned short dist = calcgp2d12(getADC(0));
        if(dist > 15) {
            // If the distance is greater than 15 centimeters, move forward
            set_servo_1a(1000);
            set_servo_1b(2000);
        } else {
            // If not, we have found an obstical!  Reverse and turn....
            set_servo_1a(2000);
            set_servo_1b(1000);
            _delay_ms(1500);

            // Spin for 1 second
            set_servo_1a(2000);
            set_servo_1b(2000);
            _delay_ms(750);
        }
    }
    return 0;
}
Esempio n. 10
0
File: ex04.c Progetto: pbmartins/AC2
int main(void) {
    unsigned int i = 0, speedCounter = 0;

    initADC();
    EnableInterrupts();
    // Configure displays as outputs
    TRISB = TRISB & 0xFC00;

    while (1) {
        delay(5);
        if (i++ == 4) {
            AD1CON1bits.ASAM = 1;
            i = 0;
        }
        
        if (speedCounter++ >= speedValues[speed]) {
            if (++c >= 12)
                c = 0;
            speedCounter = 0;
        }
        send2displays(c);

    }
    return 0;
}
Esempio n. 11
0
/* Main Initfunction --------------------------------------------------------*/
void initSystem()
{
    /* Configure the system clocks */
    RCC_Configuration();
    /* Configure TIMs */
    TIM_Configuration();
    /* Configure the GPIO ports UART */
    GPIO_Configuration();
    /* UART Interrupt */
    NVIC_Configuration();
    initUART1();
    initUART2();
    initUART3();
    //initUART4();
    /* initDMA for Sensors */
    initDMA();
    /* initADC for Sensros */
    initADC();
    /* inti System Ticker */
    /* does not work in Interrupt */
    /* Pause(ms) function */
    initSysTick();
    /* init I2C1 for Compas */
    initI2C();
}
Esempio n. 12
0
void vTaskADC(void *parameters){
	
	int i;

	for(i = 0;i < 16; i++){
		devices[i].port = -1;
	}

	initADC();

	vSemaphoreCreateBinary(adcSemaphore);
	
	ADCinitialized = 1;
	while(devices[0].port == -1){
		vTaskDelay(10);
	}
	
	while(1){
		ADCStart(&devices[currDevice]);
		currDevice++;
		if(currDevice >= 16 || devices[currDevice].port == -1){
			currDevice = 0;
		}
		xSemaphoreTake(adcSemaphore,portMAX_DELAY);
	}
}
Esempio n. 13
0
/*
 * main.c
 */
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    P1DIR |= BIT0;                            // Set P1.0 to output direction
    P1DIR |= BIT6;                            // Set P1.6 to output direction

    P1OUT &= ~BIT0;
    P1OUT &= ~BIT6;

    initADC();
    int output;
    while(1){
    	output = readLeftSensor();
    	if (output>0x0340){
    		P1OUT |= BIT0;                        // Set P1.0 LED on
    	}else{
    		P1OUT &= ~BIT0;
    	}

    	_delay_cycles(1000);

    	output = readRightSensor();
    	if (output>0x0340){
    		P1OUT |= BIT6;                        // Set P1.0 LED on
    	}else{
    		P1OUT &= ~BIT6;
    	}
    	_delay_cycles(1000);
    }
    return 0;
}
//this loop services user input and passes it to be processed on <enter>
int main(void){

   CLKDIVbits.RCDIV0=0; //clock divider to 0
   AD1PCFG = 0xFFFF;    // Default all pins to digital
   OSCCONbits.SOSCEN=0; //Oscilator setup, registar-OSCON bits-SOSCEN
   MODE_LED_DIR = 0;    //Mode LED set as output
   VREG_DIR =0;       //VREG is set as output
   VREG_EN = 1;       //Sets the VREG pin to 1, turns on the Voltage regulators.
   MODE_LED = 1;    //Turns the MOD LED 0N

   InitializeUART1(); //Initialize UART1
   initADC();         //Initialise ADC  

   unsigned int voltage;

   /////FOREVER///LOOP//////////
   while(1)
   {
      if(UART1RX() == 'a')  //Checks if the recived byte is 'a' if so it sends the two RAW bytes form ADC
      {
         voltage = getADC(); //reads the ADC pin
         UART1TX(voltage>>8); //seds the top byte of ADC to UART
         UART1TX(voltage);    //sends the bottom byte of ADC to UART
      }   
   }
Esempio n. 15
0
int main(void) {
	initLCD(display_cmd_buffer, 32);
	sendLCDCmd(LCD_CMD_CLEAR);
	serviceLCD(); // Clear the LCD just to make sure we know where we are.
	_delay_ms(2); // This takes a long time
	sendLCDCmd(LCD_CMD_DSP_ON);

	// Configure the ADC
	initADC();
	sei();
	sendCommand(CMD_STOP);
	sendCommand(CMD_SDATAC);
	uint8_t registers[] = {0x10, 0x10, 0x10, 0x10, 0x90, 0x90, 0x90, 0x90};
	writeRegisters(0x05, registers, 8);

	// Configure data ready interrupt
	DDRB &= ~(1<<4);
	PCMSK0 = 1<<4;

	sendCommand(CMD_START);
	sendCommand(CMD_RDATAC);
	PCICR |= 1;
	char buf[6];
	while (1) {
		itoa(inputBuffer[0], buf, 10);
		LCD_MOVE_TO_CHAR(0,0);
		writeString(buf, 6);
		for (int i = 0; i < 10; i++) {
			serviceLCD();
			_delay_us(60);
		}
		_delay_ms(100);
	}
}
Esempio n. 16
0
int main()
{

  uint8_t dir = CW;
  
  initPorts();
  initADC();

// accel section
  halfStep(dir);
  _delay_us(10000);
  halfStep(dir);
  _delay_us(6000);
  halfStep(dir);
  _delay_us(4667);
  halfStep(dir);
  _delay_us(3949);

  while (1)
  {
    stepperVal = MOTORPORT;
    switch (stepperVal)
    {
      case 1:
	ADMUX = (ADMUX & 0b1110000) | 0x1;
	adctested = 1;
	break;
      case 2:
	ADMUX = (ADMUX & 0b1110000) | 0x2;
	adctested = 1;
	break;
      case 4:
	ADMUX = (ADMUX & 0b1110000) | 0x3;
	adctested = 1;
	break;
      case 8:
	ADMUX = (ADMUX & 0b1110000) | 0x0;
	adctested = 1;
	break;
      default:
	ADMUX = (ADMUX & 0b1110000) | 0x31; // GND
	adctested = 0;
    }


    if (adctested)
    {
      // trigger ADC sample
      ADCSRA |= _BV(ADSC);
      // poll delay until sample done
      loop_until_bit_is_clear( ADCSRA, ADSC );
      DEBUGPORT = ADCH;
    }
    halfStep(dir);
    _delay_us(3500);

  } // main loop
  
}
Esempio n. 17
0
////////////////////////////////////////////////////////////
//                    MAIN
////////////////////////////////////////////////////////////
void main(void) {
    // Configura el Oscilador interno a 8Mhz
     OSCCONbits.IRCF = 0b111;

     
     // InitAllLEDs
    PORTA = 0x00;
    TRISAbits.TRISA0 = 1; // 1 input	
    TRISAbits.TRISA1 = 1; // 1 input
    TRISAbits.TRISA2 = 1; // 1 input	
    TRISAbits.TRISA3 = 1; // 1 input	// FOR ADC
    TRISAbits.TRISA4 = 1; // 1 input
    TRISAbits.TRISA5 = 1; // 1 input	// ICSP VPP
    TRISAbits.TRISA6 = 1; // 1 input	// OSCILATOR
    TRISAbits.TRISA7 = 1; // 1 input	// OSCILATOR

    PORTB = 0x00;
    //TRISB = 0x00; // 0x00 all as output
	TRISBbits.TRISB0 = 0; // 0 output	
    TRISBbits.TRISB1 = 0; // 0 output	
    TRISBbits.TRISB2 = 0; // 0 output 	// FOR LCD_D4
    TRISBbits.TRISB3 = 0; // 0 output	// FOR LCD_D5
    TRISBbits.TRISB4 = 0; // 0 output	// FOR LCD_D6
    TRISBbits.TRISB5 = 0; // 0 output	// FOR LCD_D7
    TRISBbits.TRISB6 = 0; // 0 output	// PGD (1 is value on POR) & LCD_RS
    TRISBbits.TRISB7 = 0; // 0 output	// PGC (1 is value on POR) & LCD_E
    //PORTB = 0x00;
    
    initADC();
	Lcd_Init();

	//CMCON = 0x07;

    while(1) {
        // INIT ADC CONVERSION
        initADCConversion();
        while(isADCConversionReady() == 0) {
            ;
        }
        int result = getADC10bitResult(); // result = 0-1023


        float minValue = 0.0;
        float maxValue = 5.0;
        float unitValue = (maxValue-minValue)/1024; // 5.0 / 1024

        // Si el voltaje alcanza el máximo valor (Vref+) currentValue=5 y si se queda en el mínimo valor (Vref-) currentValue=0.
        float currentValue = result * unitValue;

        //setBCDsText(ftoa(currentValue, (int *) 0));
		//setBCDCharacterNumber(integ);


		Lcd_Clear();
	    Lcd_Set_Cursor(1,1);
	    Lcd_Write_String(ftoa(currentValue, (int *) 0));
    }

 }
Esempio n. 18
0
int main( void )
{
	uint16_t leftLightSensor = 0;
	uint16_t rightLightSensor = 0;
	char buffer0[5];
	char buffer1[5];

	initUSART();

	initADC();

	initPWM();

	while ( 1 )
	{
		/* Start ADC7 conversion */
		leftLightSensor = readADC( 7 );

		/* Convert 10-bit uint16_t adcValue to ASCII and store in buffer */
		itoa( leftLightSensor, buffer0, 10 );

		/* Print out leftLightSensor ADC Value */
		printString( "ADC Channel 6 (Left CD Sensor): " );
		printString( buffer0 );
		printString( "\n\n" );

		/* Start ADC6 conversion */
		rightLightSensor = readADC( 6 );

		/* Convert 10-bit uint16_t adcValue to ASCII and store in buffer */
		itoa( rightLightSensor, buffer1, 10 );

		/* Print out rightLightSensor ADC Value */
		printString( "ADC Channel 7 (Right CD Sensor): " );
		printString( buffer1 );
		printString( "\n\n" );

		/* Arch right if rightLightSensor reading is greater than leftLightSensor */
		if ( ( rightLightSensor - 100 ) > leftLightSensor )
		{
			leftwheel( 55, 1 );
			rightwheel( 35 , 1 );
		}
		/* Arch left if leftLightSensor reading is greater than rightLightSensor */
		else if ( ( leftLightSensor - 100 ) > rightLightSensor )
		{
			leftwheel( 35 , 1 );
			rightwheel( 45, 1 );
		}
		/* Go forward if both light sensors have the same reading */
		else
		{
			leftwheel( 35 , 1 );
			rightwheel( 35 , 1 );
		}
		_delay_ms( 500 );
	}
}
Esempio n. 19
0
// Reading PIR status using ADC on channel AN1
void readPIR(void)
{
    initADC(1);
    readADC();
    resPIR = resADC; 
    if(resPIR > 500)
        resPIR = 1;
    else
        resPIR = 0;
}
Esempio n. 20
0
int main()
{
  initADC();
  initUART();
  DDRC|=(1<<PC5);
  while(1)
  {
  
  }
}
Esempio n. 21
0
interrupt void ADC_isr(void){
	EALLOW;
	unsigned int value;
	initADC();
	value = ADC_get();
	DAC_set(value);


	CpuTimer1.InterruptCount++;
	EALLOW;
}
int main(void)
{
	unsigned int i;
	int sum = 0;
	int current = 0;
	int hgt_percent = 0;
	int degrees = 0;

	STATE = IDLE;


	initClock();
	initADC();
	initYaw();
	initMotorPin();
	initDisplay();
	intButton();
	initConsole();
	initPWMchan();
	initCircBuf (&g_inBuffer, BUF_SIZE);


	// Enable interrupts to the processor.
	IntMasterEnable();

	while (1)
	{
		//double dt = SysCtlClockGet() / SYSTICK_RATE_HZ;
		degrees = yawToDeg();


		// Background task: calculate the (approximate) mean of the values in the
		// circular buffer and display it.
		sum = 0;
		for (i = 0; i < BUF_SIZE; i++) {
			current = readCircBuf (&g_inBuffer);
			sum = sum + current;

		}
		int newHght = ADC_TO_MILLIS(sum/BUF_SIZE);
		if(initialRead != 0)
		{
			hgt_percent = calcHeight(initialRead, newHght);

		}
		if (STATE == FLYING || STATE == LANDING){
			PIDControl(hgt_percent, SysCtlClockGet() / SYSTICK_RATE_HZ);
			PWMPulseWidthSet (PWM_BASE, PWM_OUT_1, period * main_duty / 100);
			PWMPulseWidthSet (PWM_BASE, PWM_OUT_4, period * tail_duty / 100);
		}

		displayInfo((int)initialRead, hgt_percent, degrees);
	}
}
Esempio n. 23
0
/* Configures the board hardware and chip peripherals for the project's functionality. */
void configHardware(void){
	USB_ConfigureClock();
	PORTR.DIRSET = 1 << 1;
	PORTR.OUTSET = 1 << 1;
	_delay_ms(50);
	PORTR.OUTCLR = 1 << 1;
	DAC_init();
	initADC();
	initChannels();
	USB_Init();
}
Esempio n. 24
0
File: ex02.c Progetto: pbmartins/AC2
int main(void) {
    initADC(1);                                             // Configure ADC with nConvertions = 1
    while (1) {
        AD1CON1bits.ASAM = 1;                               // Start conversion
        while (IFS1bits.AD1IF == 0);                        // Wait while conversion not done (AD1IF == 0)
        printInt(ADC1BUF0, 0x00030010);
        putChar('\n');
        IFS1bits.AD1IF = 0;                                 // Rest AD1IF
    }

    return 0;
}
Esempio n. 25
0
///////////////??????????????///////////////////////////////
int main(void)									// borde heta initADC() sen kanske?
{
	initADC();
	sei(); 										// Enable Global Interrupts
	for (int i=0; i<5; i++)
	{									
	analogRead(0);
	}
	while(1);
	{											//Wait for button
	}
} 
Esempio n. 26
0
int main(void) {

	float voltage1;
	float voltage2;
	float res1;
	float res2;
	// -------- Inits --------- //
	initUSART();
	setupADCSleepmode();
	printString("\r\nDigital Voltmeter\r\n\r\n");
	

	// ------ Event loop ------ //
  
	while (1) {

		initADC(0);
		voltage1 = oversample16x();
		printString("Thermistor 1:\r\n");
		printFloat(voltage1);
		//printVoltage(voltage1);
		res1 = printThermRes(voltage1);
		printTemp(res1);
		printString("\r\n");
		
		_delay_ms(100);

		initADC(1);
		voltage2 = oversample16x();
		printString("Thermistor 2:\r\n");
		printFloat(voltage2);
		//printVoltage(voltage2);
		res2 = printThermRes(voltage2);
		printTemp(res2);
		printString("\r\n");
		_delay_ms(2500);
		
	}                                                  /* End event loop */
	return (0);                            /* This line is never reached */
}
Esempio n. 27
0
int main(void){
	DisableDog();
	EALLOW;
	int test = 0;
	int laggingValue = 0xFF;

	unsigned int value = 0;
	EALLOW;
	CPUinit();
	EALLOW;
	DINT;

	outputEnable();

	initADC();
	EALLOW;
	outputEnable(); //having issues when not enabling twice
	SRAMwrite(0);
	SRAMaddress = 0x260000;


	//DAC_init();
	DAC_init();
	timerINIT();

	EALLOW;


	int oldvalue = 0;
	while(1){
//		SRAMaddress = 0x2FFFFF;
//		*SRAMaddress = 0x77;
		if(a == 1){ //cross your fingers folks
			value = keypadScan();
			*outputPORT = value;
			if(value < 0xF && value != 1 && oldvalue != value){
				FreqSet(value); //setting the frequency based upon keypad input
				oldvalue = value;
			}
		}
	}


	EALLOW;






	return 0;
}
Esempio n. 28
0
int main (void) {
	initClock(); // clock.h
	initSerial(); // serial.h
	initTimer(); // timer.h
	initADC(); // adc.h
	initInterrupt(); // interrupt.h
	initJtagShift(); // jtagshift.h
	initTdbShell(); // tdbshell.h

	tdbShellStart();

	return 0;
}
Esempio n. 29
0
// Functions
int initDevice() {
	// Setup UART
	initUSART0STDIO(UBRR_MACRO);
	// Setup ADC
	initADC();
	// Setup BT
	initBT();
	// Enable Timer
	initTimer();
	// Enable Interrupts
	sei();
	return 0;
}
Esempio n. 30
0
int main ( void ) {
	init_stdusart0(51, DB8 | P_N | SB1);  //init stdio uart at 19.2k baud 8N1 (51 is ubrr value for 19.2k at 16 MHz)
	initADC();                            //initalize the A2D converter
	uint16_t channelnum;                  //create 2 16 bit variables
	uint16_t value;
	printf("AVR ADC Test Program\r:");    //print a welcome message
	while (1) {                           //repeat forever
		scanf("%d", &channelnum);         //get the requested channel number
		value = getADC((uint8_t)(channelnum & 0x07)); //get the value of that channel  channel num is 16 bits, we need the lower three.  mask the non required bits
	    printf("Channel: %d = %d\r:", channelnum, value); //print the result
	}
	return 0;
}