Altered range to send values from 110 Hz (A below low C) to 621 Hz (D above high C). The python script will have to convert these frequencies into note keys and note names.

This commit is contained in:
Jonathan Chan 2018-03-08 16:04:45 -08:00
parent adf1512ca7
commit a9899a4485
1 changed files with 5 additions and 9 deletions

View File

@ -2,6 +2,7 @@
#define TXD BIT2
#define RXD BIT1
#define LED BIT0
#define US 1000000
@ -22,26 +23,21 @@ void main(void) {
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // Initialize USCI state machine
P1DIR |= TXD;
P1DIR |= TXD | LED;
P1OUT |= TXD;
P1DIR |= BIT0;
TACTL = TACLR; // reset clock
TACTL = TASSEL_2 | MC_2; // set SMCLK timer to count up at 1 MHz
TACCTL0 = CM1 | SCS | CAP | CCIE; // set capture mode to rising edge and enable interrupts
while (1) {
TAR = 0;
P1OUT ^= BIT0;
P1OUT ^= LED;
__enable_interrupt();
__bis_SR_register(LPM0_bits + GIE);
TXByte = US/TACCR0; // frequency in Hz
TXByte /= 2; // frequency won't fit in a byte
TXByte = US/TACCR0; // frequency in Hertz
while (!(IFG2 & UCA0TXIFG)); // wait for TX buffer to be ready for new data
UCA0TXBUF = TXByte;
UCA0TXBUF = (TXByte - 110)/2; // send range of 110 Hz (A below low C) to 621 Hz (D above high C)
__delay_cycles(100000); // wait >10 ms before measuring again
}
}