Jump to content


  • Content Count

  • Joined

  • Last visited

  1. Ah nice, thanks for linking that to me. I got a better understanding now. Cheers.
  2. I took a look at that, but I don't really understand it. I am using C, not assembly. When I read that, the pdf only says that the comp_a is used for detecting the echo. From what I understand so far, the comp_a receives a signal from the rx transducer as 1 sample as well as the original signal. What I dont understand is how it works out that the rx signal is an echo. I am thinking its something to do with the time difference between the rising edge of the original signal and the echo. I think it uses the count stored in CCR0 to calculate the distance. But this is just guess work and I am not sure how I'd actually implement what i just typed.
  3. Is there any chance someone can explain how I am meant to use the comp_a to detect the echo used to calculate the distance? I am having trouble figuring out how it works, so I can't even attempt to code it.
  4. The comp_A as of yet doesn't make much sense to me. Instead I've been working on this: #include #define RLY1 BIT6; // Global Variables char i=0; void CAinit(void); // Function Definitions void main(void) { WDTCTL = WDTPW + WDTHOLD; // disable watchdog P1OUT = 0; //P1DIR = RLY1; // P1.6 out to relay (LED) P1DIR |= BIT6; P1SEL |= BIT6; P1DIR |= BIT0; BCSCTL1 = CALBC1_8MHZ; // Set DCO to calibrated 1 MHz. DCOCTL = CALDCO_8MHZ; TACCR0 = 198; // A period of 62,500 cycles is 0 to 62,499. TACCTL0 = CCIE; // Enable interrupts for CCR0. TACCTL1 = OUTMOD_7; TACCR1 = 50; TACTL = TASSEL_2 + MC_1 + TACLR; // SMCLK, up mode, // clear timer _enable_interrupt(); _BIS_SR(LPM0_bits); for(; { // Do nothing while waiting for interrupts. This would be an } // an ideal place to use low power modes! } // main // Interrupt Service Routines #pragma vector = TIMER0_A0_VECTOR __interrupt void CCR0_ISR(void) { if (++i == 12) { P1OUT ^= BIT0; P1DIR ^= BIT6; i=0; } Can anyone tell me if this is doing 12 cycle bursts of 40 kHz PWM? I created this bit so it wouldn't be transmitting the pwm signal constantly and I was hoping to work the comp_A component into this code. I don't have an oscilliscope at home so I can't test it over the weekend. If you could let me know if this is doing what I hope it is doing it'd be great. Also I am a little confused regarding the CCRx and CCTLx registers, can I omit the "TA", for example, of the TACCRx that was used in the demo code? edit: nvm I found out they are the same from the header file. Thanks guys
  5. Hey Bluehash/rick I managed to generate the 40 kHz signal. I am using the following code: WDTCTL = WDTPW + WDTHOLD; //P1DIR |= 0x01; //P1DIR |= 0x40; //P1OUT = 0x00; P1DIR |= BIT6; P1SEL |= BIT6; BCSCTL1 = CALBC1_8MHZ; // Set range DCOCTL = CALDCO_8MHZ; // Set DCO step + modulation */ CCR0 = 198; // for this, it gives me 40 kHz exactly CCTL1 = OUTMOD_7; CCR1 = 50; TACTL = TASSEL_2 +MC_1; _BIS_SR(LPM0_bits); How do I connect this to Comp_A? I had a look at the 3 examples but they only explain the function they are performing but I don't know how it performs them. I haven't found any good explanation on how to use comp_a, so I was wondering if anyone knows of a good guide or would care to explain its use. Cheers
  6. Hey guys, thanks for the replies. Well looking at NJC's blog page I did get it to work somewhat using the code on the page. I actually need to test it later. I was just wondering about CCR0 and CCR1. For CCR0 what exaclty is data type used for it? because CCSv4 was complaining that the number was large and it was being truncated and also is its function to divide the DCO frequency? so CCR0 = 1000 means 1MHz/1000 ? Alternatively using grace I did manage to set it to 40 kHz using one of the grace examples. Now my question is how would I proceed to use it with comp_A?
  7. Hi everyone, I literally just got the launchpad and I am hoping to use it to design an ultrasonic range finder. I've been doing some reading and I know that I need a MCU with Comp_A, so I've gotten myself some MSP430G2452 to start it all. Now the thing is I basically have no experience using microcontrollers and pretty light with coding in C, so when I read some of the documentation I am finding myself confused about alot of things. What I'm hoping to find out is how to generate a 40 kHz square wave with the DCO rather than the crystal and how to use the comp_A peripheral to calculate the distance using the echo. So far I have worked out how to set the inpu/output pins and use the p1.3 button on the launchpad. I am going through david's blog at mspsci.blogspot and now I am kinda struggling at configuring the DCO. All I have achieved at this point is to slow down the blinking LED by modifying the BCSCTL1 and DCOCTL values, though I'm probably doing it wrong. If you have read upto this point, let me say thanks and I hope you can help me out Cheers!
  8. Hello to everyone at 43oh! I just got the launchpad this week and I am looking forward to learning from you guys. Cheers, Elbert
  • Create New...