task_accelerometer.c
/******************************************************************************
* Initializes all hardware for the accelerometer
******************************************************************************/
Initializes all hardware for the accelerometer
Initializes all hardware for the accelerometer
void Task_Accelerometer_Init(void)
 {
     P4->SEL0 |= BIT0;
     P4->SEL1 |= BIT0;
     P4->SEL0 |= BIT2;
     P4->SEL1 |= BIT2;
     P6->SEL0 |= BIT1;
     P6->SEL1 |= BIT1;
     ADC14->CTL0 = ADC14_CTL0_SHT0_2 | ADC14_CTL0_SHP | ADC14_CTL0_CONSEQ_1;
     ADC14->CTL1 = ADC14_CTL1_RES_2;         
     ADC14->MCTL[0] |= ADC14_MCTLN_INCH_14;
     ADC14->MCTL[1] |= ADC14_MCTLN_INCH_13;
     ADC14->MCTL[2] |= ADC14_MCTLN_INCH_11 | ADC14_MCTLN_EOS;
     ADC14->IER0 |= ADC14_IER0_IE1 ;
     NVIC_EnableIRQ(ADC14_IRQn);
     NVIC_SetPriority(ADC14_IRQn,2);
     ADC14->CTL0 |= ADC14_CTL0_ON;
 }
void Task_Accelerometer_Init ( void ) { P4 -> SEL0 |= BIT0 ; P4 -> SEL1 |= BIT0 ; P4 -> SEL0 |= BIT2 ; P4 -> SEL1 |= BIT2 ; P6 -> SEL0 |= BIT1 ; P6 -> SEL1 |= BIT1 ; ADC14 -> CTL0 = ADC14_CTL0_SHT0_2 | ADC14_CTL0_SHP | ADC14_CTL0_CONSEQ_1 ; ADC14 -> CTL1 = ADC14_CTL1_RES_2 ; ADC14 -> MCTL [ 0 ] |= ADC14_MCTLN_INCH_14 ; ADC14 -> MCTL [ 1 ] |= ADC14_MCTLN_INCH_13 ; ADC14 -> MCTL [ 2 ] |= ADC14_MCTLN_INCH_11 | ADC14_MCTLN_EOS ; ADC14 -> IER0 |= ADC14_IER0_IE1 ; NVIC_EnableIRQ ( ADC14_IRQn ) ; NVIC_SetPriority ( ADC14_IRQn , 2 ) ; ADC14 -> CTL0 |= ADC14_CTL0_ON ; }
Initializes all hardware for the accelerometer
Initializes all hardware for the accelerometer
// Configure the Y direction as an analog input pin. // Configure the X direction as an analog input pin. // X Direction // Configure CTL0 to sample 16-times in pulsed sample mode. // NEW -- Indicate that this is a sequence of samples. // Configure CTL1 to return 12-bit values // Use sampling timer, 12-bit conversion results // Associate the X direction analog signal with MEM[0] // Associate the Y direction analog signal with MEM[1] // NEW -- Make sure to indicate this is the end of a sequence. // Enable interrupts AFTER a value is written into MEM[1]. // Enable ADC Interrupt // Interrupt priorities must NOT be set to 0.  It is preferred if they are set to a value that is > than 1 too. // Turn ADC ON