diff --git a/README.html b/Documents/README.html similarity index 100% rename from README.html rename to Documents/README.html diff --git a/README.md b/Documents/README.md similarity index 100% rename from README.md rename to Documents/README.md diff --git a/schematic.png b/Documents/schematic.png similarity index 100% rename from schematic.png rename to Documents/schematic.png diff --git a/adclight.c b/Examples/adclight.c similarity index 74% rename from adclight.c rename to Examples/adclight.c index 57194f328f5c9988f23f7e0bea96b7f9b0deac03..33866846f361157310ffcf2556b46463b2459dbd 100644 --- a/adclight.c +++ b/Examples/adclight.c @@ -25,7 +25,14 @@ int main(void) { __delay_cycles(10000); // wait for ADC ref to settle ADC10CTL0 |= ENC + ADC10SC; // sampling and conversion start + // Turns cpu register off and waits for interupts. __bis_SR_register(CPUOFF | GIE); // go to sleep with interrupts enabled + + + // Can change this line to do the color interupt routines (regarding a8)? Everything else can mostly stay the same?? + // Set a variable which determines what color to change. Then if, to select other statements similar to this one? + // ADC10MEM is a 10 bit number. &-ing with 0x3F8 somehow just throws away the bottom 3 bits? + // As they might vary too much to provide useful data, or something. TA0CCR1 = ADC10MEM & 0x3F8; // assigns the value held in ADC10MEM to the TA0CCR1 register } @@ -36,6 +43,7 @@ int main(void) #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR (void) { + // Turns cpu register back on. __bic_SR_register_on_exit(CPUOFF); // wake up } diff --git a/adcspeaker.c b/Examples/adcspeaker.c similarity index 100% rename from adcspeaker.c rename to Examples/adcspeaker.c diff --git a/Makefile b/Makefile index 364e6ef0b33bcf27700d4241439ecd366d52b2fc..55537d91a37ea3db05ac875aeedcc3157a4be1d4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Project name -SOURCE = adclight.c +SOURCE = a8.c ADDITIONAL = # Get base name so we can create .elf file NAME = $(basename $(SOURCE)) diff --git a/a8.c b/a8.c new file mode 100644 index 0000000000000000000000000000000000000000..c6df2fd259dace9919dd3759126ecba09cc2b6ba --- /dev/null +++ b/a8.c @@ -0,0 +1,48 @@ +#include <msp430.h> + +int main(void) +{ + WDTCTL = WDTPW | WDTHOLD; // Watchdog timer setup. + BCSCTL1 = CALBC1_1MHZ; // Set cpu clock thingy. + DCOCTL = CALDCO_1MHZ; // More of above. + + P1DIR = BIT6; // BIT6 alternate output + P1SEL = BIT6|BIT4; // BIT4 analog input (channel 4) + + TA0CTL = TASSEL_2 | MC_1 | ID_3; // use TA0.1 for PWM on P1.6 + TA0CCR0 = 0x3FF; // 10-bit maximum value + TA0CCR1 = 0; // start off + TA0CCTL1 = OUTMOD_7; // reset/set output mode + + ADC10CTL1 = INCH_4 | ADC10DIV_3; // ADC10 channel 4, clock divider 3 + ADC10CTL0 = SREF_0 | ADC10SHT_3 | // VCC/VSS ref, 64 x ADC10CLKs + ADC10ON | ADC10IE; // ADC10 enable, ADC10 interrupt enable + ADC10AE0 = BIT4; // analog enable channel 4 + + // __enable_interrupt(); // interrupts enabled + while(1) + { + __delay_cycles(10000); // wait for ADC ref to settle + ADC10CTL0 |= ENC + ADC10SC; // sampling and conversion start + // Turns cpu register off and waits for interupts. + __bis_SR_register(CPUOFF | GIE); // go to sleep with interrupts enabled + + + // Can change this line to do the color interupt routines (regarding a8)? Everything else can mostly stay the same?? + // Set a variable which determines what color to change. Then if, to select other statements similar to this one? + // ADC10MEM is a 10 bit number. &-ing with 0x3F8 somehow just throws away the bottom 3 bits? + // As they might vary too much to provide useful data, or something. + TA0CCR1 = ADC10MEM & 0x3F8; // assigns the value held in ADC10MEM to the TA0CCR1 register + } + + return 0; +} + +// ADC10 interrupt service routine +#pragma vector=ADC10_VECTOR +__interrupt void ADC10_ISR (void) +{ + // Turns cpu register back on. + __bic_SR_register_on_exit(CPUOFF); // wake up +} +