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