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.
Hello,
I want to use Timer B for a PWM. Later i need 4 different PWM in my program.
When I have a little program with Timer A it works fine, but when i will use Timer B with the same settings CCS5 shows me this error:
Description Resource Path Location Type
#20 identifier "TBCCR0" is undefined main.c /Up Timer Test line 16 C/C++ Problem
#20 identifier "TBCCR1" is undefined main.c /Up Timer Test line 17 C/C++ Problem
#20 identifier "TBCCTL0" is undefined main.c /Up Timer Test line 14 C/C++ Problem
#20 identifier "TBCCTL1" is undefined main.c /Up Timer Test line 15 C/C++ Problem
#20 identifier "TBCTL" is undefined main.c /Up Timer Test line 13 C/C++ Problem
#20 identifier "TBSSEL_2" is undefined main.c /Up Timer Test line 13 C/C++ Problem
This is the Code with Timer B,.. I have only changed the A to B(with A it works)
#include <msp430G2153.h> #define Periode 1000 #define DutyCycle 200 void main(void){ WDTCTL = WDTPW | WDTHOLD; P1DIR = BIT2; P1SEL = BIT2; while(1){ TBCTL = TBSSEL_2; TBCCTL0 = OUTMOD_4; TBCCTL1 = OUTMOD_7; TBCCR0 = Periode-1; TBCCR1 = DutyCycle; TBCTL |= MC_1; } }
There is a Timer B on MSP430G2153,.. or not?
Thank you und with best regards
Sascha,
There is no Timer B on the MSP430G2513. If you look at the part datasheet http://www.ti.com/lit/ds/symlink/msp430g2153.pdf you will see it only shows 2 x Timer A.
You should still be able to make 4 different PWM frequencies using these timers.
Cheers,
Darren
The data sheet says... no. Just two TimerA with three CCRs. (which is more than the other G series MSPs with only one TimerA with two CCRs)Sascha W. said:There is a Timer B on MSP430G2153,.. or not?
Ah okay, now i understand. Sure, without a timerB, there is no way to compile it.
Can anyone of you tell me,how i can initialize this 2 timers and the ports for 4 pwms.im very sry, but i am a beginner and i really have some problems to understand the familyguide and other datasheets. For one timer and one portpin i know, but not for the others. I mean it like:
Portpin 1.1 to timera0 ccr1.. Portbin 1.2 to timera1 ccr2...
If there is a manual in any pdf/datasheet, pls show me.
Thank you for the big help!!
Okay i got it :)
TA1CTL = TASSEL_2 + TACLR;
TA1CCR0 = 32000-1;
TA1CCTL1 = OUTMOD_7;
TA1CCR1 = 20000-1;
P2DIR |= BIT1;
P2SEL |= BIT1;
TA1CTL |= MC_2;
TA1CCTL2 = OUTMOD_7;
TA1CCR2 = 10000-1;
P2DIR |= BIT4;
P2SEL |= BIT4;
But there i one thing i dont understand at the moment..
Why can i not change the CCR0 value over 32000? (i just tried it)
You should be able to freely set CCR0 between 0 (makes no sense for PWM) and 65535. With the expected impact on PWM frequency (timer cycle time).Sascha W. said:Why can i not change the CCR0 value over 32000? (i just tried it)
However, for a PWM with CCR0-adjusted frequency, the tuimer needs to run in up mode (MC_1). Then the timer counts from 0 to CCR0. But CCR0 cannot be used to output a PWM signal itself (CCR1 and CCR2 do). CCR0 cna only be used to either generate a pulse of 1 clock cycle at the end of a PWM cycle (set/reset mdoe), or to output a signal with 1/2 of the PWM frequency and 50% DC (toggle mode).
**Attention** This is a public forum