Hey guys,
My issue is this. I am trying to input an audio signal from the stylus of a record player into the MSP430. I want to convert this signal to digital using the ADC12, then I want to read these values and send them out serially to Hyperterminal. My problem is I want to send every conversion out serially without missing one. My plan right now is to start conversions in my main routine then every time a conversion is completed I want to jump to an ISR and store the incoming conversion into a buffer. While my main routine continues to send out the values from my buffer serially to a Hyperterminal or Putty application. However, I am not sure how to setup the buffer. In addition, I want to convert the values coming into the Hyperterminal into hex values rather than the random characters that appear. Below is the code I have so far, and I know that it does not do what I need.
# include <msp430xG46x.h> volatile unsigned int ADCSample; void main(void) { WDTCTL = WDTPW+WDTHOLD; // Stop watchdog // Initialization of ADC12// P6SEL |= 0x01; // Enable A/D channel A0 ADC12CTL0 &= ~ENC; // Disable Conversions ADC12CTL0 = ADC12ON + SHT0_2 + REFON + REF2_5V + MSC; // turn on ADC12, set samp time ADC12CTL1 = SHP+CONSEQ_2; // Use sampling timer ADC12MCTL0 = SREF_5+INCH_0; // Vr+=VeREF+ (external) ADC12IE = 0x02; //ADC12IFG.1 ADC12CTL0 |= ENC; // Enable conversions __enable_interrupt(); // Enable interrupts // Initialization of Rs-232// FLL_CTL0 |= XCAP14PF; // Configure load caps do { IFG1 &= ~OFIFG; // Clear OSCFault flag _delay_cycles(50000); // Time for flag to set } while ((IFG1 & OFIFG)); // OSCFault flag still set? P2SEL |= 0x30; // P2.4,5 = USCI_A0 RXD/TXD UCA0CTL1 |= UCSSEL_1; // CLK = ACLK UCA0BR0 = 0x03; // 32k/9600 - 13.65 UCA0BR1 = 0x00; // UCA0MCTL = 0x06; // Modulation UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** IE2 |= UCA0TXIE + UCA0RXIE; // enable RXD and TXD interrupt; //Serial Loop while (1) { ADC12CTL0 |= ADC12SC; // Start conversions while (!(ADC12IFG & 0x0001)); // Conversion done? __bis_SR_register(LPM0_bits + GIE); UCA0TXBUF = ADCSample; // send lower part __no_operation(); _delay_cycles(1000); // wait for first transmit UCA0TXBUF = ADCSample >> 8; // send upper part } } //ADC12 ISR #pragma vector=ADC12_VECTOR __interrupt void ADC12ISR (void) { ADC12CTL0 &= ~ENC; //Disable Conversions ADCSample = ADC12MEM0; //Move ADC value to Buffer ADC12CTL0 |= ENC; //Enable Conversions ADC12CTL0 |= ADC12SC; //Start Conversions __no_operation(); // SET BREAKPOINT HERE __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 }
Eugene SmithI have a MAJOR project due in less than a week. I understand this forum is about learning and not for providing code verbatim, but having said that I am in a jam. I am willing to PAY 100 USD to the person that can get this code running properly via paypal.
Hi Eugene, strange behaviour, your code and problem is very close to the one of Preston, see here:
http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/181042.aspx
If this can solve your problem I am ready for payment but I cannot run code by paypal too ;)
Regards
Roberto
Please login & click Verify Answer if this post answered your question.
Eugene Smith My issue is this. I am trying to input an audio signal from the stylus of a record player into the MSP430. I want to convert this signal to digital using the ADC12, then I want to read these values and send them out serially to Hyperterminal.
No question more but IHMO this is not the good way to do this, a better approach can be to use a CODEC with more dynamic and S/N too.
The codec is too fast to be processed by MSP but also audio stream can be too fast to be sent serially to a PC, better approach as I was saying can be a codec development connected to a Stellaris LAN series, IE the lm3s9xxx has I2S USB, SD and LAN interfaces, this isolate stylus and preamplifier from pc noise, no fan and no EMF generation so converter can be left close to turntable or record player also as a stand alone SD or pen drive recorder.
A byte consists of 8 bits. Is the bit pattern 01000001 a decimal number, hex number, or an ASCII?
Using c can make life easier for a programmer. But it only helps you to do the tedious dirty work. It does not help you understand the basics. In fact, I think c might even confuse you if you do not understand the basics. A lot of beginners are burned badly by "learning" c.
old_cow_yellowA lot of beginners are burned badly by "learning" c.
Hi OCW, right and not only c related question burn out, suggestion on how to handle a tons of basic missing background questions?
A small sanity check:
Spoken voice has a frequency range of 3.5kHz. So you need to sample with 7kHz. One ADC12 sample is 12 bit. If you transfer it as 2 bytes, you'll have to send 14kB/s, which is a baudrate of 140kBd. Now an old vinyl record has ~14kHz. So when sampling it, you'll get 56kB/s or 560kBd (assuming an uninterrupted data stream, requiring tight hand-crafted code)However, most PC COM ports won't go above 115200Bd, some go up 230400Bd.
CD quality produces ~82kB/s This would require 820kBd transfer rate. For MONO only. STEREO doubles the data.
And then there is the maximum CPU speed, only 8MHz on the FG46x1 (I don't have the FG46x datasheet at hand).
Now back to the drawing board...
What are the exact parameters of the project? Frequency? Required quality (maybe 8 bit per sample are enough). Maybe some sort of compression is required? What are the outlines for the power consumption (and therefore the maximum MSP operating speed?).And well, sending binary data to HyperTerm will show only garbage on the screen. But convertign it to readable values first will significantly increase the amount of data. So a dedicated backend software is required on the PC side. Well, take a look at this nice LaunchPad project.
_____________________________________Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.