I am building an ultrasonic measuring device based on MSP430F413 (Link at the end of post, it's SLAA136A - October 2001). I am using the development board MSP430F5529LP, and wanted advice on how to do this. Here is some pseudo code that I have, I was thinking of changing the 32.768kHz crystal on Q2 to a 40kHz crystal because my sender and receiver ultrasonics operate at 40kHz. Is there a problem with switching this crystal out?
#include <msp430f5529.h>
/*
* main.c
* I am using the MSP430F5529 launchpad to try an set up ultrasonic measurements
* I switched the Q2 to a 40kHz crystal oscillator because I am using 40kHz
* ultrasonic transmitter and recievers.
*/
void init_device();
void measurement_cycle();
unsigned long int i = 0;
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
init_device();
for(;;){
//update the serial out value with the value measured and then put the MSP430, initially it should be 000.
//to LPM3 sleep mode. The MSP430 remains in sleep mode until a BasicTimer1_ISR interrupt occurs
//and BasicTimer1_ISR returns it to active mode and initialized a measurement.
//stay in low power mode until we hit a basictimer1 interrupt
//after we get out of low power mode we have already done a measurement
//send out the value we measured to display
}//stay in loop forever here, maybe change it later
return 0;
}
/***********************Functions********************************/
void init_device(){
//I switched the crystal from 32.7kHz to a 40kHz crystal on the xin and xout (on MSP430F5529 the Q2)
//set P1.0 (ACLK) to output the 40kHz wave
//P1.2 (AT0.1) is for our receiver circuit to connect to, set up the opamp if needed
//set up basictimer1 to interrupt the CPU every 205 ms? and initialize a measurement cycle
}
void measurement_cycle(){
//get the free running counter right before we send off our signal
//send our signal for 12 clock cycles
//wait until we get an input from P1.2
//from our input pin our P1.2 (AT0.1), capture our signal and get the free running counter when we get it back
//now we do math on the free running counter, convert the clock cycles to time
//change the time to distance
}
interrupt BasicTimer1_ISR(){
//take out of low power mode
//initialize a measurement cycle
measurement_cycle();
}
http://www.ti.com/lit/an/slaa136a/slaa136a.pdf


