This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI C/C++ Compiler
MSP430f149 issue with pulse pack
Dear friends,
Please help me with this issue: I've tried to get pulse pack from 1.5 pin MSP430f149.
I need to generate pulse packs with frequency: 40 000 Hz from TA0. But I can't do it. I get only pulses.
How to make the delay of the timer? I need it for ultrasonic receiver/sender. Pulse pack need to excite the ultrasonic sensor and pause - to receive the signal input.
If I use only pin 1.5(TA0) may I use CCR1 to make the PWM?
How to make the PWM?
Please, anybody, help me with this issue.
void timerA_PWM()
{
TACCR0=18;
TACCR1=10;
TACCTL1=OUTMOD_7;
TACTL=TASSEL_2 +MC_1;
}
void timerA_pause()
{
TACCR0 = 12000-1;
TACCTL0 = CCIE;
TACTL = MC_1|ID_3|TASSEL_1|TACLR;
}
#pragma vector = TIMERA0_VECTOR
__interrupt void TIMERA0_VECTOR_ISR(void)
{
timerA_PWM();
_delay_cycles(1000);
timerA_pause();
}
I imagine the interrupt is entered once but you are having trouble with it afterwards. You should not be operating for so long while inside of the ISR. Below are some recommended changes (untested):
void timerA_pause() { TACCR0 = 36564; TACCTL0 = CCIE; TACCTL1&=~OUTMOD_7; TACTL = MC_1|TASSEL_2|TACLR; } void timerA_PWM() { TACCTL0&=~CCIE; TACCR0= 18; TACCR1=7; TACCTL1=OUTMOD_7; TACTL |=TACLR; } #pragma vector = TIMERA0_VECTOR __interrupt void TIMERA0_VECTOR_ISR(void) { _BIC_SR(LPM0_bits); } void main(void) { WDTCTL=WDTPW+WDTHOLD; P1DIR|=BIT6; P1SEL|=BIT6; while(1) { timerA_pause(); _BIS_SR(LPM0_bits+GIE); timerA_PWM(); _delay_cycles(5000); } }
Regards, Ryan
**Attention** This is a public forum