From 911707a892d597181df498328bb422d7f30b8322 Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Thu, 17 Nov 2016 04:12:15 -0500 Subject: [PATCH] Reorganize project directory --- README.html => Documents/README.html | 0 README.md => Documents/README.md | 0 schematic.png => Documents/schematic.png | Bin adclight.c => Examples/adclight.c | 8 ++++ adcspeaker.c => Examples/adcspeaker.c | 0 Makefile | 2 +- a8.c | 48 +++++++++++++++++++++++ 7 files changed, 57 insertions(+), 1 deletion(-) rename README.html => Documents/README.html (100%) rename README.md => Documents/README.md (100%) rename schematic.png => Documents/schematic.png (100%) rename adclight.c => Examples/adclight.c (74%) rename adcspeaker.c => Examples/adcspeaker.c (100%) create mode 100644 a8.c 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 57194f3..3386684 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 364e6ef..55537d9 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 0000000..c6df2fd --- /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 +} + -- GitLab