The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.
PWM using TimerB in Continuous mode - ti2tt - Sep 2 10:58:24 2009
Hello Friends/Members,
I am using MSP430F2418 device and want to generate the PWM on pin TB5 using continuous
mode of TimerB. I am using this timer - module 4 and module 6 - for two different timeout
values. I want to generate a PWM of 50% duty cycle and a period of 150Hz using module 5
which in turn will output a PWM on TB5. I am using ACLK=1MHz. Below is the code, I have
written to configure TimerB and corresponding modules:
void Init_TimerB (void)
{
TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB / Stop TimerB
TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 / Stop
TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by 2 /
Continuous
}
void ConfigTimerB4_Timeout (UINT tout)
{
TBCCTL4 &= ~CCIE; //Disable interrupt
TBCCTL4 &= ~CAP; //Compare mode
//CM_0 = No Capture
//CCIS_1 = Capture/Compare input is TB4
//SCS = Synchronous capture
//CLLD_0 = Load compare latch (TBCLx) when TBCCRx is
written
//OUTMOD_0 = output value of OUT on pin
//CCIE = Enable interrupt
//OUT = Output high on pin
TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
TBCCR4 = (TBR + tout);
}
void ConfigTimerB6_Timeout (UINT tout)
{
TBCCTL6 &= ~CCIE; //Disable interrupt
TBCCTL6 &= ~CAP; //Compare mode
//CM_0 = No Capture
//CCIS_1 = Capture/Compare input is TB6
//SCS = Synchronous capture
//CLLD_0 = Load compare latch (TBCLx) when TBCCRx is
written
//OUTMOD_4 = Toggle TB6
//CCIE = Enable interrupt
//OUT = Output high on pin if OUTMOD_0
TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
TBCCR6 = (TBR + tout);
}
void ConfigTimerB5_PWM (void)
{
P4SEL &= ~0xA0;
P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
P4DIR |= 0x20; // P4.5 - Select compare as output
TBCCR0 = 0;
TBCCTL5 &= ~CCIE; //Disable interrupt
TBCCTL5 &= ~CAP; //Compare mode
//CM_0 = No Capture
//CCIS_1 = Capture/Compare input is TB4
//SCS = Synchronous capture
//CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
//OUTMOD_0 = output value of OUT on pin
//CCIE = Enable interrupt
//OUT = Output high on pin
TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
TBCCR5 = (1660);
}
I am not sure of module 5 configuration. Please guide me to get the PWM in continuous
mode. If I use UP mode for timer, then I am able to generate the PWM properly but failing
to get required timeouts. Is it possible to use timer either in Up or Continuous mode to
generate both PWM as well as timeouts? Please help me for this. Your earliest help in this
regard will be highly appreciated. Thanks in advance.
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )
Re: PWM using TimerB in Continuous mode - Bart Oegema - Sep 2 12:08:42 2009
Read and think about what is happening in the different timer modes
(up and continuous, in this case). What happens in UP mode when the
timer register counts to the value specified in TBCCR0? What happens
in continuous mode when the same happens?
- Bart
On Wed, Sep 2, 2009 at 7:57 AM, ti2tt
wrote:
> Hello Friends/Members,
>
> I am using MSP430F2418 device and want to generate the PWM on pin TB5 using
> continuous mode of TimerB. I am using this timer - module 4 and module 6 -
> for two different timeout values. I want to generate a PWM of 50% duty cycle
> and a period of 150Hz using module 5 which in turn will output a PWM on TB5.
> I am using ACLK=1MHz. Below is the code, I have written to configure TimerB
> and corresponding modules:
>
> void Init_TimerB (void)
> {
> TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB / Stop
> TimerB
> TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 / Stop
> TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
>
> TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by 2 /
> Continuous
> }
>
> void ConfigTimerB4_Timeout (UINT tout)
> {
> TBCCTL4 &= ~CCIE; //Disable interrupt
> TBCCTL4 &= ~CAP; //Compare mode
> //CM_0 = No Capture
> //CCIS_1 = Capture/Compare input is TB4
> //SCS = Synchronous capture
> //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> //OUTMOD_0 = output value of OUT on pin
> //CCIE = Enable interrupt
> //OUT = Output high on pin
> TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> TBCCR4 = (TBR + tout);
> }
>
> void ConfigTimerB6_Timeout (UINT tout)
> {
> TBCCTL6 &= ~CCIE; //Disable interrupt
> TBCCTL6 &= ~CAP; //Compare mode
> //CM_0 = No Capture
> //CCIS_1 = Capture/Compare input is TB6
> //SCS = Synchronous capture
> //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> //OUTMOD_4 = Toggle TB6
> //CCIE = Enable interrupt
> //OUT = Output high on pin if OUTMOD_0
> TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> TBCCR6 = (TBR + tout);
> }
>
> void ConfigTimerB5_PWM (void)
> {
> P4SEL &= ~0xA0;
> P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> P4DIR |= 0x20; // P4.5 - Select compare as output
>
> TBCCR0 = 0;
> TBCCTL5 &= ~CCIE; //Disable interrupt
> TBCCTL5 &= ~CAP; //Compare mode
> //CM_0 = No Capture
> //CCIS_1 = Capture/Compare input is TB4
> //SCS = Synchronous capture
> //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> //OUTMOD_0 = output value of OUT on pin
> //CCIE = Enable interrupt
> //OUT = Output high on pin
> TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> TBCCR5 = (1660);
> }
>
> I am not sure of module 5 configuration. Please guide me to get the PWM in
> continuous mode. If I use UP mode for timer, then I am able to generate the
> PWM properly but failing to get required timeouts. Is it possible to use
> timer either in Up or Continuous mode to generate both PWM as well as
> timeouts? Please help me for this. Your earliest help in this regard will be
> highly appreciated. Thanks in advance.
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Sep 5 2:34:54 2009
Thanks Bart for your reply.!! I tried to look for the different mode configurations but
alas.
Does anyone have solution for this? I really need the same very much as project work is
held up. I request all forum members for the same. Thanks in advance.
--- In m...@yahoogroups.com, Bart Oegema
wrote:
>
> Read and think about what is happening in the different timer modes
> (up and continuous, in this case). What happens in UP mode when the
> timer register counts to the value specified in TBCCR0? What happens
> in continuous mode when the same happens?
>
> - Bart
>
> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> >
> >
> > Hello Friends/Members,
> >
> > I am using MSP430F2418 device and want to generate the PWM on pin TB5 using
> > continuous mode of TimerB. I am using this timer - module 4 and module 6 -
> > for two different timeout values. I want to generate a PWM of 50% duty cycle
> > and a period of 150Hz using module 5 which in turn will output a PWM on TB5.
> > I am using ACLK=1MHz. Below is the code, I have written to configure TimerB
> > and corresponding modules:
> >
> > void Init_TimerB (void)
> > {
> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB / Stop
> > TimerB
> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 / Stop
> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> >
> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by 2 /
> > Continuous
> > }
> >
> > void ConfigTimerB4_Timeout (UINT tout)
> > {
> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > TBCCTL4 &= ~CAP; //Compare mode
> > //CM_0 = No Capture
> > //CCIS_1 = Capture/Compare input is TB4
> > //SCS = Synchronous capture
> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > //OUTMOD_0 = output value of OUT on pin
> > //CCIE = Enable interrupt
> > //OUT = Output high on pin
> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> > TBCCR4 = (TBR + tout);
> > }
> >
> > void ConfigTimerB6_Timeout (UINT tout)
> > {
> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > TBCCTL6 &= ~CAP; //Compare mode
> > //CM_0 = No Capture
> > //CCIS_1 = Capture/Compare input is TB6
> > //SCS = Synchronous capture
> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > //OUTMOD_4 = Toggle TB6
> > //CCIE = Enable interrupt
> > //OUT = Output high on pin if OUTMOD_0
> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> > TBCCR6 = (TBR + tout);
> > }
> >
> > void ConfigTimerB5_PWM (void)
> > {
> > P4SEL &= ~0xA0;
> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > P4DIR |= 0x20; // P4.5 - Select compare as output
> >
> > TBCCR0 = 0;
> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > TBCCTL5 &= ~CAP; //Compare mode
> > //CM_0 = No Capture
> > //CCIS_1 = Capture/Compare input is TB4
> > //SCS = Synchronous capture
> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > //OUTMOD_0 = output value of OUT on pin
> > //CCIE = Enable interrupt
> > //OUT = Output high on pin
> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > TBCCR5 = (1660);
> > }
> >
> > I am not sure of module 5 configuration. Please guide me to get the PWM in
> > continuous mode. If I use UP mode for timer, then I am able to generate the
> > PWM properly but failing to get required timeouts. Is it possible to use
> > timer either in Up or Continuous mode to generate both PWM as well as
> > timeouts? Please help me for this. Your earliest help in this regard will be
> > highly appreciated. Thanks in advance.
> >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: Re: PWM using TimerB in Continuous mode - Bart Oegema - Sep 5 14:19:22 2009
You'll find it in the MSP430x2xx Family User Guide, specifically chapter 12.
http://www.ti.com/litv/pdf/slau144e
- Bart
On Fri, Sep 4, 2009 at 11:34 PM, ti2tt
wrote:
> Thanks Bart for your reply.!! I tried to look for the different mode
> configurations but alas.
>
> Does anyone have solution for this? I really need the same very much as
> project work is held up. I request all forum members for the same. Thanks in
> advance.
>
> --- In m...@yahoogroups.com, Bart Oegema wrote:
>>
>> Read and think about what is happening in the different timer modes
>> (up and continuous, in this case). What happens in UP mode when the
>> timer register counts to the value specified in TBCCR0? What happens
>> in continuous mode when the same happens?
>>
>> - Bart
>>
>> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
>> >
>> >
>> > Hello Friends/Members,
>> >
>> > I am using MSP430F2418 device and want to generate the PWM on pin TB5
>> > using
>> > continuous mode of TimerB. I am using this timer - module 4 and module 6
>> > -
>> > for two different timeout values. I want to generate a PWM of 50% duty
>> > cycle
>> > and a period of 150Hz using module 5 which in turn will output a PWM on
>> > TB5.
>> > I am using ACLK=1MHz. Below is the code, I have written to configure
>> > TimerB
>> > and corresponding modules:
>> >
>> > void Init_TimerB (void)
>> > {
>> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB / Stop
>> > TimerB
>> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 / Stop
>> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
>> >
>> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by 2
>> > /
>> > Continuous
>> > }
>> >
>> > void ConfigTimerB4_Timeout (UINT tout)
>> > {
>> > TBCCTL4 &= ~CCIE; //Disable interrupt
>> > TBCCTL4 &= ~CAP; //Compare mode
>> > //CM_0 = No Capture
>> > //CCIS_1 = Capture/Compare input is TB4
>> > //SCS = Synchronous capture
>> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
>> > //OUTMOD_0 = output value of OUT on pin
>> > //CCIE = Enable interrupt
>> > //OUT = Output high on pin
>> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
>> > TBCCR4 = (TBR + tout);
>> > }
>> >
>> > void ConfigTimerB6_Timeout (UINT tout)
>> > {
>> > TBCCTL6 &= ~CCIE; //Disable interrupt
>> > TBCCTL6 &= ~CAP; //Compare mode
>> > //CM_0 = No Capture
>> > //CCIS_1 = Capture/Compare input is TB6
>> > //SCS = Synchronous capture
>> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
>> > //OUTMOD_4 = Toggle TB6
>> > //CCIE = Enable interrupt
>> > //OUT = Output high on pin if OUTMOD_0
>> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
>> > TBCCR6 = (TBR + tout);
>> > }
>> >
>> > void ConfigTimerB5_PWM (void)
>> > {
>> > P4SEL &= ~0xA0;
>> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
>> > P4DIR |= 0x20; // P4.5 - Select compare as output
>> >
>> > TBCCR0 = 0;
>> > TBCCTL5 &= ~CCIE; //Disable interrupt
>> > TBCCTL5 &= ~CAP; //Compare mode
>> > //CM_0 = No Capture
>> > //CCIS_1 = Capture/Compare input is TB4
>> > //SCS = Synchronous capture
>> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
>> > //OUTMOD_0 = output value of OUT on pin
>> > //CCIE = Enable interrupt
>> > //OUT = Output high on pin
>> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
>> > TBCCR5 = (1660);
>> > }
>> >
>> > I am not sure of module 5 configuration. Please guide me to get the PWM
>> > in
>> > continuous mode. If I use UP mode for timer, then I am able to generate
>> > the
>> > PWM properly but failing to get required timeouts. Is it possible to use
>> > timer either in Up or Continuous mode to generate both PWM as well as
>> > timeouts? Please help me for this. Your earliest help in this regard
>> > will be
>> > highly appreciated. Thanks in advance.
>> >
>> >
>>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Sep 7 1:25:40 2009
Hello Bart,
I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I was unable to find
why the continuous mode is not generating the PWM. The PWM generation is possible in
continuos mode even. Please let me know what exactly is going wrong with my code.
Thanks in advance.
--- In m...@yahoogroups.com, Bart Oegema
wrote:
>
> You'll find it in the MSP430x2xx Family User Guide, specifically chapter 12.
>
> http://www.ti.com/litv/pdf/slau144e
>
> - Bart
>
> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> >
> >
> > Thanks Bart for your reply.!! I tried to look for the different mode
> > configurations but alas.
> >
> > Does anyone have solution for this? I really need the same very much as
> > project work is held up. I request all forum members for the same. Thanks in
> > advance.
> >
> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> >>
> >> Read and think about what is happening in the different timer modes
> >> (up and continuous, in this case). What happens in UP mode when the
> >> timer register counts to the value specified in TBCCR0? What happens
> >> in continuous mode when the same happens?
> >>
> >> - Bart
> >>
> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> >> >
> >> >
> >> > Hello Friends/Members,
> >> >
> >> > I am using MSP430F2418 device and want to generate the PWM on pin TB5
> >> > using
> >> > continuous mode of TimerB. I am using this timer - module 4 and module 6
> >> > -
> >> > for two different timeout values. I want to generate a PWM of 50% duty
> >> > cycle
> >> > and a period of 150Hz using module 5 which in turn will output a PWM on
> >> > TB5.
> >> > I am using ACLK=1MHz. Below is the code, I have written to configure
> >> > TimerB
> >> > and corresponding modules:
> >> >
> >> > void Init_TimerB (void)
> >> > {
> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB / Stop
> >> > TimerB
> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 / Stop
> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> >> >
> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by 2
> >> > /
> >> > Continuous
> >> > }
> >> >
> >> > void ConfigTimerB4_Timeout (UINT tout)
> >> > {
> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> >> > TBCCTL4 &= ~CAP; //Compare mode
> >> > //CM_0 = No Capture
> >> > //CCIS_1 = Capture/Compare input is TB4
> >> > //SCS = Synchronous capture
> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> >> > //OUTMOD_0 = output value of OUT on pin
> >> > //CCIE = Enable interrupt
> >> > //OUT = Output high on pin
> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> >> > TBCCR4 = (TBR + tout);
> >> > }
> >> >
> >> > void ConfigTimerB6_Timeout (UINT tout)
> >> > {
> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> >> > TBCCTL6 &= ~CAP; //Compare mode
> >> > //CM_0 = No Capture
> >> > //CCIS_1 = Capture/Compare input is TB6
> >> > //SCS = Synchronous capture
> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> >> > //OUTMOD_4 = Toggle TB6
> >> > //CCIE = Enable interrupt
> >> > //OUT = Output high on pin if OUTMOD_0
> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> >> > TBCCR6 = (TBR + tout);
> >> > }
> >> >
> >> > void ConfigTimerB5_PWM (void)
> >> > {
> >> > P4SEL &= ~0xA0;
> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> >> >
> >> > TBCCR0 = 0;
> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> >> > TBCCTL5 &= ~CAP; //Compare mode
> >> > //CM_0 = No Capture
> >> > //CCIS_1 = Capture/Compare input is TB4
> >> > //SCS = Synchronous capture
> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> >> > //OUTMOD_0 = output value of OUT on pin
> >> > //CCIE = Enable interrupt
> >> > //OUT = Output high on pin
> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> >> > TBCCR5 = (1660);
> >> > }
> >> >
> >> > I am not sure of module 5 configuration. Please guide me to get the PWM
> >> > in
> >> > continuous mode. If I use UP mode for timer, then I am able to generate
> >> > the
> >> > PWM properly but failing to get required timeouts. Is it possible to use
> >> > timer either in Up or Continuous mode to generate both PWM as well as
> >> > timeouts? Please help me for this. Your earliest help in this regard
> >> > will be
> >> > highly appreciated. Thanks in advance.
> >> >
> >> >
> >>
> >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: Re: PWM using TimerB in Continuous mode - Bart Oegema - Sep 8 11:55:06 2009
To basically repeat my question from earlier, what happens in each of
the timer modes? Back off from trying to create a PWM output for the
moment, and think about how the module functions.
To give you part of the solution to get you started a bit further in
the direction I'm thinking, in UP mode the timer counts up to the
value set in TBCCTL0, after which it rolls over to zero and starts
counting up again.
What happens (and what are you depending on in your timeout routines)
in continuous mode? When you're producing PWM outputs in UP mode as
expected, what is happening? When the timeouts are working in
continuous mode, what is happening?
- Bart
On Sun, Sep 6, 2009 at 10:25 PM, ti2tt
wrote:
> Hello Bart,
>
> I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I was
> unable to find why the continuous mode is not generating the PWM. The PWM
> generation is possible in continuos mode even. Please let me know what
> exactly is going wrong with my code.
>
> Thanks in advance.
> --- In m...@yahoogroups.com, Bart Oegema wrote:
>>
>> You'll find it in the MSP430x2xx Family User Guide, specifically chapter
>> 12.
>>
>> http://www.ti.com/litv/pdf/slau144e
>>
>> - Bart
>>
>> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
>> >
>> >
>> > Thanks Bart for your reply.!! I tried to look for the different mode
>> > configurations but alas.
>> >
>> > Does anyone have solution for this? I really need the same very much as
>> > project work is held up. I request all forum members for the same.
>> > Thanks in
>> > advance.
>> >
>> > --- In m...@yahoogroups.com, Bart Oegema wrote:
>> >>
>> >> Read and think about what is happening in the different timer modes
>> >> (up and continuous, in this case). What happens in UP mode when the
>> >> timer register counts to the value specified in TBCCR0? What happens
>> >> in continuous mode when the same happens?
>> >>
>> >> - Bart
>> >>
>> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
>> >> >
>> >> >
>> >> > Hello Friends/Members,
>> >> >
>> >> > I am using MSP430F2418 device and want to generate the PWM on pin TB5
>> >> > using
>> >> > continuous mode of TimerB. I am using this timer - module 4 and
>> >> > module 6
>> >> > -
>> >> > for two different timeout values. I want to generate a PWM of 50%
>> >> > duty
>> >> > cycle
>> >> > and a period of 150Hz using module 5 which in turn will output a PWM
>> >> > on
>> >> > TB5.
>> >> > I am using ACLK=1MHz. Below is the code, I have written to configure
>> >> > TimerB
>> >> > and corresponding modules:
>> >> >
>> >> > void Init_TimerB (void)
>> >> > {
>> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB /
>> >> > Stop
>> >> > TimerB
>> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 /
>> >> > Stop
>> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
>> >> >
>> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by
>> >> > 2
>> >> > /
>> >> > Continuous
>> >> > }
>> >> >
>> >> > void ConfigTimerB4_Timeout (UINT tout)
>> >> > {
>> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
>> >> > TBCCTL4 &= ~CAP; //Compare mode
>> >> > //CM_0 = No Capture
>> >> > //CCIS_1 = Capture/Compare input is TB4
>> >> > //SCS = Synchronous capture
>> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
>> >> > //OUTMOD_0 = output value of OUT on pin
>> >> > //CCIE = Enable interrupt
>> >> > //OUT = Output high on pin
>> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
>> >> > TBCCR4 = (TBR + tout);
>> >> > }
>> >> >
>> >> > void ConfigTimerB6_Timeout (UINT tout)
>> >> > {
>> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
>> >> > TBCCTL6 &= ~CAP; //Compare mode
>> >> > //CM_0 = No Capture
>> >> > //CCIS_1 = Capture/Compare input is TB6
>> >> > //SCS = Synchronous capture
>> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
>> >> > //OUTMOD_4 = Toggle TB6
>> >> > //CCIE = Enable interrupt
>> >> > //OUT = Output high on pin if OUTMOD_0
>> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
>> >> > TBCCR6 = (TBR + tout);
>> >> > }
>> >> >
>> >> > void ConfigTimerB5_PWM (void)
>> >> > {
>> >> > P4SEL &= ~0xA0;
>> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
>> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
>> >> >
>> >> > TBCCR0 = 0;
>> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
>> >> > TBCCTL5 &= ~CAP; //Compare mode
>> >> > //CM_0 = No Capture
>> >> > //CCIS_1 = Capture/Compare input is TB4
>> >> > //SCS = Synchronous capture
>> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
>> >> > //OUTMOD_0 = output value of OUT on pin
>> >> > //CCIE = Enable interrupt
>> >> > //OUT = Output high on pin
>> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
>> >> > TBCCR5 = (1660);
>> >> > }
>> >> >
>> >> > I am not sure of module 5 configuration. Please guide me to get the
>> >> > PWM
>> >> > in
>> >> > continuous mode. If I use UP mode for timer, then I am able to
>> >> > generate
>> >> > the
>> >> > PWM properly but failing to get required timeouts. Is it possible to
>> >> > use
>> >> > timer either in Up or Continuous mode to generate both PWM as well as
>> >> > timeouts? Please help me for this. Your earliest help in this regard
>> >> > will be
>> >> > highly appreciated. Thanks in advance.
>> >> >
>> >> >
>> >>
>> >
>> >
>>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Sep 15 10:55:36 2009
Hello Bart / Forum members,
Thank you for your guidance to understant the UP/Continuous mode.
I am now able to generate the PWM in continuous mode and can vary the PWM duty cycle from
0% to 100%. Here I have observed that the PWM duty cycle deviates to 100% at lower values
i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have solution for the
same? This happens at some regular interval. This interval instance could be the TBR
overflow, but I am not sure. Does anyone has similar observation? Please provide me
solution for this.
Thanks in advance.
--- In m...@yahoogroups.com, Bart Oegema
wrote:
>
> To basically repeat my question from earlier, what happens in each of
> the timer modes? Back off from trying to create a PWM output for the
> moment, and think about how the module functions.
>
> To give you part of the solution to get you started a bit further in
> the direction I'm thinking, in UP mode the timer counts up to the
> value set in TBCCTL0, after which it rolls over to zero and starts
> counting up again.
>
> What happens (and what are you depending on in your timeout routines)
> in continuous mode? When you're producing PWM outputs in UP mode as
> expected, what is happening? When the timeouts are working in
> continuous mode, what is happening?
>
> - Bart
>
> On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> >
> >
> > Hello Bart,
> >
> > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I was
> > unable to find why the continuous mode is not generating the PWM. The PWM
> > generation is possible in continuos mode even. Please let me know what
> > exactly is going wrong with my code.
> >
> > Thanks in advance.
> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> >>
> >> You'll find it in the MSP430x2xx Family User Guide, specifically chapter
> >> 12.
> >>
> >> http://www.ti.com/litv/pdf/slau144e
> >>
> >> - Bart
> >>
> >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> >> >
> >> >
> >> > Thanks Bart for your reply.!! I tried to look for the different mode
> >> > configurations but alas.
> >> >
> >> > Does anyone have solution for this? I really need the same very much as
> >> > project work is held up. I request all forum members for the same.
> >> > Thanks in
> >> > advance.
> >> >
> >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> >> >>
> >> >> Read and think about what is happening in the different timer modes
> >> >> (up and continuous, in this case). What happens in UP mode when the
> >> >> timer register counts to the value specified in TBCCR0? What happens
> >> >> in continuous mode when the same happens?
> >> >>
> >> >> - Bart
> >> >>
> >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> >> >> >
> >> >> >
> >> >> > Hello Friends/Members,
> >> >> >
> >> >> > I am using MSP430F2418 device and want to generate the PWM on pin TB5
> >> >> > using
> >> >> > continuous mode of TimerB. I am using this timer - module 4 and
> >> >> > module 6
> >> >> > -
> >> >> > for two different timeout values. I want to generate a PWM of 50%
> >> >> > duty
> >> >> > cycle
> >> >> > and a period of 150Hz using module 5 which in turn will output a PWM
> >> >> > on
> >> >> > TB5.
> >> >> > I am using ACLK=1MHz. Below is the code, I have written to configure
> >> >> > TimerB
> >> >> > and corresponding modules:
> >> >> >
> >> >> > void Init_TimerB (void)
> >> >> > {
> >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB /
> >> >> > Stop
> >> >> > TimerB
> >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 /
> >> >> > Stop
> >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> >> >> >
> >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by
> >> >> > 2
> >> >> > /
> >> >> > Continuous
> >> >> > }
> >> >> >
> >> >> > void ConfigTimerB4_Timeout (UINT tout)
> >> >> > {
> >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> >> >> > TBCCTL4 &= ~CAP; //Compare mode
> >> >> > //CM_0 = No Capture
> >> >> > //CCIS_1 = Capture/Compare input is TB4
> >> >> > //SCS = Synchronous capture
> >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> >> >> > //OUTMOD_0 = output value of OUT on pin
> >> >> > //CCIE = Enable interrupt
> >> >> > //OUT = Output high on pin
> >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> >> >> > TBCCR4 = (TBR + tout);
> >> >> > }
> >> >> >
> >> >> > void ConfigTimerB6_Timeout (UINT tout)
> >> >> > {
> >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> >> >> > TBCCTL6 &= ~CAP; //Compare mode
> >> >> > //CM_0 = No Capture
> >> >> > //CCIS_1 = Capture/Compare input is TB6
> >> >> > //SCS = Synchronous capture
> >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> >> >> > //OUTMOD_4 = Toggle TB6
> >> >> > //CCIE = Enable interrupt
> >> >> > //OUT = Output high on pin if OUTMOD_0
> >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> >> >> > TBCCR6 = (TBR + tout);
> >> >> > }
> >> >> >
> >> >> > void ConfigTimerB5_PWM (void)
> >> >> > {
> >> >> > P4SEL &= ~0xA0;
> >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> >> >> >
> >> >> > TBCCR0 = 0;
> >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> >> >> > TBCCTL5 &= ~CAP; //Compare mode
> >> >> > //CM_0 = No Capture
> >> >> > //CCIS_1 = Capture/Compare input is TB4
> >> >> > //SCS = Synchronous capture
> >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> >> >> > //OUTMOD_0 = output value of OUT on pin
> >> >> > //CCIE = Enable interrupt
> >> >> > //OUT = Output high on pin
> >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> >> >> > TBCCR5 = (1660);
> >> >> > }
> >> >> >
> >> >> > I am not sure of module 5 configuration. Please guide me to get the
> >> >> > PWM
> >> >> > in
> >> >> > continuous mode. If I use UP mode for timer, then I am able to
> >> >> > generate
> >> >> > the
> >> >> > PWM properly but failing to get required timeouts. Is it possible to
> >> >> > use
> >> >> > timer either in Up or Continuous mode to generate both PWM as well as
> >> >> > timeouts? Please help me for this. Your earliest help in this regard
> >> >> > will be
> >> >> > highly appreciated. Thanks in advance.
> >> >> >
> >> >> >
> >> >>
> >> >
> >> >
> >>
> >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - tintronic - Sep 15 15:53:15 2009
Let me guess, it only happens when you are lowering the DC but not when you're increasing
it? Classic mistake, think about it.
Hint: What happens when TAR is nearing TACCRx and you write a new value to TACCRx that is
lower than the actual count of TAR.
TACCRx is 1000 and TAR is 900.
You write TACCRx = 800.
What happens next?
Regards,
Michael K.
--- In m...@yahoogroups.com, "ti2tt"
wrote:
>
> Hello Bart / Forum members,
>
> Thank you for your guidance to understant the UP/Continuous mode.
>
> I am now able to generate the PWM in continuous mode and can vary the PWM duty cycle
from 0% to 100%. Here I have observed that the PWM duty cycle deviates to 100% at lower
values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have solution for
the same? This happens at some regular interval. This interval instance could be the TBR
overflow, but I am not sure. Does anyone has similar observation? Please provide me
solution for this.
>
> Thanks in advance.
> --- In m...@yahoogroups.com, Bart Oegema wrote:
> >
> > To basically repeat my question from earlier, what happens in each of
> > the timer modes? Back off from trying to create a PWM output for the
> > moment, and think about how the module functions.
> >
> > To give you part of the solution to get you started a bit further in
> > the direction I'm thinking, in UP mode the timer counts up to the
> > value set in TBCCTL0, after which it rolls over to zero and starts
> > counting up again.
> >
> > What happens (and what are you depending on in your timeout routines)
> > in continuous mode? When you're producing PWM outputs in UP mode as
> > expected, what is happening? When the timeouts are working in
> > continuous mode, what is happening?
> >
> > - Bart
> >
> > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > >
> > >
> > > Hello Bart,
> > >
> > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I was
> > > unable to find why the continuous mode is not generating the PWM. The PWM
> > > generation is possible in continuos mode even. Please let me know what
> > > exactly is going wrong with my code.
> > >
> > > Thanks in advance.
> > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > >>
> > >> You'll find it in the MSP430x2xx Family User Guide, specifically chapter
> > >> 12.
> > >>
> > >> http://www.ti.com/litv/pdf/slau144e
> > >>
> > >> - Bart
> > >>
> > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > >> >
> > >> >
> > >> > Thanks Bart for your reply.!! I tried to look for the different mode
> > >> > configurations but alas.
> > >> >
> > >> > Does anyone have solution for this? I really need the same very much as
> > >> > project work is held up. I request all forum members for the same.
> > >> > Thanks in
> > >> > advance.
> > >> >
> > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > >> >>
> > >> >> Read and think about what is happening in the different timer modes
> > >> >> (up and continuous, in this case). What happens in UP mode when the
> > >> >> timer register counts to the value specified in TBCCR0? What happens
> > >> >> in continuous mode when the same happens?
> > >> >>
> > >> >> - Bart
> > >> >>
> > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > >> >> >
> > >> >> >
> > >> >> > Hello Friends/Members,
> > >> >> >
> > >> >> > I am using MSP430F2418 device and want to generate the PWM on pin TB5
> > >> >> > using
> > >> >> > continuous mode of TimerB. I am using this timer - module 4 and
> > >> >> > module 6
> > >> >> > -
> > >> >> > for two different timeout values. I want to generate a PWM of 50%
> > >> >> > duty
> > >> >> > cycle
> > >> >> > and a period of 150Hz using module 5 which in turn will output a PWM
> > >> >> > on
> > >> >> > TB5.
> > >> >> > I am using ACLK=1MHz. Below is the code, I have written to configure
> > >> >> > TimerB
> > >> >> > and corresponding modules:
> > >> >> >
> > >> >> > void Init_TimerB (void)
> > >> >> > {
> > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB /
> > >> >> > Stop
> > >> >> > TimerB
> > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 /
> > >> >> > Stop
> > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > >> >> >
> > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by
> > >> >> > 2
> > >> >> > /
> > >> >> > Continuous
> > >> >> > }
> > >> >> >
> > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > >> >> > {
> > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > >> >> > //CM_0 = No Capture
> > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > >> >> > //SCS = Synchronous capture
> > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > >> >> > //OUTMOD_0 = output value of OUT on pin
> > >> >> > //CCIE = Enable interrupt
> > >> >> > //OUT = Output high on pin
> > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> > >> >> > TBCCR4 = (TBR + tout);
> > >> >> > }
> > >> >> >
> > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > >> >> > {
> > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > >> >> > //CM_0 = No Capture
> > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > >> >> > //SCS = Synchronous capture
> > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > >> >> > //OUTMOD_4 = Toggle TB6
> > >> >> > //CCIE = Enable interrupt
> > >> >> > //OUT = Output high on pin if OUTMOD_0
> > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> > >> >> > TBCCR6 = (TBR + tout);
> > >> >> > }
> > >> >> >
> > >> >> > void ConfigTimerB5_PWM (void)
> > >> >> > {
> > >> >> > P4SEL &= ~0xA0;
> > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > >> >> >
> > >> >> > TBCCR0 = 0;
> > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > >> >> > //CM_0 = No Capture
> > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > >> >> > //SCS = Synchronous capture
> > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > >> >> > //OUTMOD_0 = output value of OUT on pin
> > >> >> > //CCIE = Enable interrupt
> > >> >> > //OUT = Output high on pin
> > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > >> >> > TBCCR5 = (1660);
> > >> >> > }
> > >> >> >
> > >> >> > I am not sure of module 5 configuration. Please guide me to get the
> > >> >> > PWM
> > >> >> > in
> > >> >> > continuous mode. If I use UP mode for timer, then I am able to
> > >> >> > generate
> > >> >> > the
> > >> >> > PWM properly but failing to get required timeouts. Is it possible to
> > >> >> > use
> > >> >> > timer either in Up or Continuous mode to generate both PWM as well as
> > >> >> > timeouts? Please help me for this. Your earliest help in this regard
> > >> >> > will be
> > >> >> > highly appreciated. Thanks in advance.
> > >> >> >
> > >> >> >
> > >> >>
> > >> >
> > >> >
> > >>
> > >
> > >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Sep 16 1:40:41 2009
Hello,
Thanks Michael.
I am trying to locate the "Classic mistake". What is the way out to avoid this mistake?
Your example clears the point where the mistake is occurring.
Thanks in advance.
--- In m...@yahoogroups.com, "tintronic"
wrote:
>
> Let me guess, it only happens when you are lowering the DC but not when you're
increasing it? Classic mistake, think about it.
>
> Hint: What happens when TAR is nearing TACCRx and you write a new value to TACCRx that
is lower than the actual count of TAR.
>
> TACCRx is 1000 and TAR is 900.
> You write TACCRx = 800.
> What happens next?
>
> Regards,
> Michael K.
>
> --- In m...@yahoogroups.com, "ti2tt" wrote:
> >
> > Hello Bart / Forum members,
> >
> > Thank you for your guidance to understant the UP/Continuous mode.
> >
> > I am now able to generate the PWM in continuous mode and can vary the PWM duty cycle
from 0% to 100%. Here I have observed that the PWM duty cycle deviates to 100% at lower
values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have solution for
the same? This happens at some regular interval. This interval instance could be the TBR
overflow, but I am not sure. Does anyone has similar observation? Please provide me
solution for this.
> >
> > Thanks in advance.
> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > >
> > > To basically repeat my question from earlier, what happens in each of
> > > the timer modes? Back off from trying to create a PWM output for the
> > > moment, and think about how the module functions.
> > >
> > > To give you part of the solution to get you started a bit further in
> > > the direction I'm thinking, in UP mode the timer counts up to the
> > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > counting up again.
> > >
> > > What happens (and what are you depending on in your timeout routines)
> > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > expected, what is happening? When the timeouts are working in
> > > continuous mode, what is happening?
> > >
> > > - Bart
> > >
> > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > >
> > > >
> > > > Hello Bart,
> > > >
> > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I was
> > > > unable to find why the continuous mode is not generating the PWM. The PWM
> > > > generation is possible in continuos mode even. Please let me know what
> > > > exactly is going wrong with my code.
> > > >
> > > > Thanks in advance.
> > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > >>
> > > >> You'll find it in the MSP430x2xx Family User Guide, specifically chapter
> > > >> 12.
> > > >>
> > > >> http://www.ti.com/litv/pdf/slau144e
> > > >>
> > > >> - Bart
> > > >>
> > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > >> >
> > > >> >
> > > >> > Thanks Bart for your reply.!! I tried to look for the different mode
> > > >> > configurations but alas.
> > > >> >
> > > >> > Does anyone have solution for this? I really need the same very much as
> > > >> > project work is held up. I request all forum members for the same.
> > > >> > Thanks in
> > > >> > advance.
> > > >> >
> > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > >> >>
> > > >> >> Read and think about what is happening in the different timer modes
> > > >> >> (up and continuous, in this case). What happens in UP mode when the
> > > >> >> timer register counts to the value specified in TBCCR0? What happens
> > > >> >> in continuous mode when the same happens?
> > > >> >>
> > > >> >> - Bart
> > > >> >>
> > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > >> >> >
> > > >> >> >
> > > >> >> > Hello Friends/Members,
> > > >> >> >
> > > >> >> > I am using MSP430F2418 device and want to generate the PWM on pin TB5
> > > >> >> > using
> > > >> >> > continuous mode of TimerB. I am using this timer - module 4 and
> > > >> >> > module 6
> > > >> >> > -
> > > >> >> > for two different timeout values. I want to generate a PWM of 50%
> > > >> >> > duty
> > > >> >> > cycle
> > > >> >> > and a period of 150Hz using module 5 which in turn will output a PWM
> > > >> >> > on
> > > >> >> > TB5.
> > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to configure
> > > >> >> > TimerB
> > > >> >> > and corresponding modules:
> > > >> >> >
> > > >> >> > void Init_TimerB (void)
> > > >> >> > {
> > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB /
> > > >> >> > Stop
> > > >> >> > TimerB
> > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 /
> > > >> >> > Stop
> > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > >> >> >
> > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by
> > > >> >> > 2
> > > >> >> > /
> > > >> >> > Continuous
> > > >> >> > }
> > > >> >> >
> > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > >> >> > {
> > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > >> >> > //CM_0 = No Capture
> > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > >> >> > //SCS = Synchronous capture
> > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > >> >> > //CCIE = Enable interrupt
> > > >> >> > //OUT = Output high on pin
> > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> > > >> >> > TBCCR4 = (TBR + tout);
> > > >> >> > }
> > > >> >> >
> > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > >> >> > {
> > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > >> >> > //CM_0 = No Capture
> > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > >> >> > //SCS = Synchronous capture
> > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > >> >> > //OUTMOD_4 = Toggle TB6
> > > >> >> > //CCIE = Enable interrupt
> > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> > > >> >> > TBCCR6 = (TBR + tout);
> > > >> >> > }
> > > >> >> >
> > > >> >> > void ConfigTimerB5_PWM (void)
> > > >> >> > {
> > > >> >> > P4SEL &= ~0xA0;
> > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > >> >> >
> > > >> >> > TBCCR0 = 0;
> > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > >> >> > //CM_0 = No Capture
> > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > >> >> > //SCS = Synchronous capture
> > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > >> >> > //CCIE = Enable interrupt
> > > >> >> > //OUT = Output high on pin
> > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > > >> >> > TBCCR5 = (1660);
> > > >> >> > }
> > > >> >> >
> > > >> >> > I am not sure of module 5 configuration. Please guide me to get the
> > > >> >> > PWM
> > > >> >> > in
> > > >> >> > continuous mode. If I use UP mode for timer, then I am able to
> > > >> >> > generate
> > > >> >> > the
> > > >> >> > PWM properly but failing to get required timeouts. Is it possible to
> > > >> >> > use
> > > >> >> > timer either in Up or Continuous mode to generate both PWM as well as
> > > >> >> > timeouts? Please help me for this. Your earliest help in this regard
> > > >> >> > will be
> > > >> >> > highly appreciated. Thanks in advance.
> > > >> >> >
> > > >> >> >
> > > >> >>
> > > >> >
> > > >> >
> > > >>
> > > >
> > > >
> > >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Sep 16 3:29:12 2009
Hello Michael,
With ref to your example, the ON or OFF time will change and in turn the duty cycle of PWM
will change. But how to avoid it? What could be the remedy for classic mistake?
Thanks in advance.
--- In m...@yahoogroups.com, "ti2tt"
wrote:
>
> Hello,
>
> Thanks Michael.
>
> I am trying to locate the "Classic mistake". What is the way out to avoid this mistake?
Your example clears the point where the mistake is occurring.
>
> Thanks in advance.
> --- In m...@yahoogroups.com, "tintronic" wrote:
> >
> > Let me guess, it only happens when you are lowering the DC but not when you're
increasing it? Classic mistake, think about it.
> >
> > Hint: What happens when TAR is nearing TACCRx and you write a new value to TACCRx that
is lower than the actual count of TAR.
> >
> > TACCRx is 1000 and TAR is 900.
> > You write TACCRx = 800.
> > What happens next?
> >
> > Regards,
> > Michael K.
> >
> > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > >
> > > Hello Bart / Forum members,
> > >
> > > Thank you for your guidance to understant the UP/Continuous mode.
> > >
> > > I am now able to generate the PWM in continuous mode and can vary the PWM duty cycle
from 0% to 100%. Here I have observed that the PWM duty cycle deviates to 100% at lower
values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have solution for
the same? This happens at some regular interval. This interval instance could be the TBR
overflow, but I am not sure. Does anyone has similar observation? Please provide me
solution for this.
> > >
> > > Thanks in advance.
> > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > >
> > > > To basically repeat my question from earlier, what happens in each of
> > > > the timer modes? Back off from trying to create a PWM output for the
> > > > moment, and think about how the module functions.
> > > >
> > > > To give you part of the solution to get you started a bit further in
> > > > the direction I'm thinking, in UP mode the timer counts up to the
> > > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > > counting up again.
> > > >
> > > > What happens (and what are you depending on in your timeout routines)
> > > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > > expected, what is happening? When the timeouts are working in
> > > > continuous mode, what is happening?
> > > >
> > > > - Bart
> > > >
> > > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > > >
> > > > >
> > > > > Hello Bart,
> > > > >
> > > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I was
> > > > > unable to find why the continuous mode is not generating the PWM. The PWM
> > > > > generation is possible in continuos mode even. Please let me know what
> > > > > exactly is going wrong with my code.
> > > > >
> > > > > Thanks in advance.
> > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > >>
> > > > >> You'll find it in the MSP430x2xx Family User Guide, specifically chapter
> > > > >> 12.
> > > > >>
> > > > >> http://www.ti.com/litv/pdf/slau144e
> > > > >>
> > > > >> - Bart
> > > > >>
> > > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > > >> >
> > > > >> >
> > > > >> > Thanks Bart for your reply.!! I tried to look for the different mode
> > > > >> > configurations but alas.
> > > > >> >
> > > > >> > Does anyone have solution for this? I really need the same very much as
> > > > >> > project work is held up. I request all forum members for the same.
> > > > >> > Thanks in
> > > > >> > advance.
> > > > >> >
> > > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > >> >>
> > > > >> >> Read and think about what is happening in the different timer modes
> > > > >> >> (up and continuous, in this case). What happens in UP mode when the
> > > > >> >> timer register counts to the value specified in TBCCR0? What happens
> > > > >> >> in continuous mode when the same happens?
> > > > >> >>
> > > > >> >> - Bart
> > > > >> >>
> > > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > > >> >> >
> > > > >> >> >
> > > > >> >> > Hello Friends/Members,
> > > > >> >> >
> > > > >> >> > I am using MSP430F2418 device and want to generate the PWM on pin TB5
> > > > >> >> > using
> > > > >> >> > continuous mode of TimerB. I am using this timer - module 4 and
> > > > >> >> > module 6
> > > > >> >> > -
> > > > >> >> > for two different timeout values. I want to generate a PWM of 50%
> > > > >> >> > duty
> > > > >> >> > cycle
> > > > >> >> > and a period of 150Hz using module 5 which in turn will output a PWM
> > > > >> >> > on
> > > > >> >> > TB5.
> > > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to configure
> > > > >> >> > TimerB
> > > > >> >> > and corresponding modules:
> > > > >> >> >
> > > > >> >> > void Init_TimerB (void)
> > > > >> >> > {
> > > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB /
> > > > >> >> > Stop
> > > > >> >> > TimerB
> > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 /
> > > > >> >> > Stop
> > > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > > >> >> >
> > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by
> > > > >> >> > 2
> > > > >> >> > /
> > > > >> >> > Continuous
> > > > >> >> > }
> > > > >> >> >
> > > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > > >> >> > {
> > > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > > >> >> > //CM_0 = No Capture
> > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > >> >> > //SCS = Synchronous capture
> > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > >> >> > //CCIE = Enable interrupt
> > > > >> >> > //OUT = Output high on pin
> > > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> > > > >> >> > TBCCR4 = (TBR + tout);
> > > > >> >> > }
> > > > >> >> >
> > > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > > >> >> > {
> > > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > > >> >> > //CM_0 = No Capture
> > > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > > >> >> > //SCS = Synchronous capture
> > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > >> >> > //OUTMOD_4 = Toggle TB6
> > > > >> >> > //CCIE = Enable interrupt
> > > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> > > > >> >> > TBCCR6 = (TBR + tout);
> > > > >> >> > }
> > > > >> >> >
> > > > >> >> > void ConfigTimerB5_PWM (void)
> > > > >> >> > {
> > > > >> >> > P4SEL &= ~0xA0;
> > > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > > >> >> >
> > > > >> >> > TBCCR0 = 0;
> > > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > > >> >> > //CM_0 = No Capture
> > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > >> >> > //SCS = Synchronous capture
> > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > >> >> > //CCIE = Enable interrupt
> > > > >> >> > //OUT = Output high on pin
> > > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > > > >> >> > TBCCR5 = (1660);
> > > > >> >> > }
> > > > >> >> >
> > > > >> >> > I am not sure of module 5 configuration. Please guide me to get the
> > > > >> >> > PWM
> > > > >> >> > in
> > > > >> >> > continuous mode. If I use UP mode for timer, then I am able to
> > > > >> >> > generate
> > > > >> >> > the
> > > > >> >> > PWM properly but failing to get required timeouts. Is it possible to
> > > > >> >> > use
> > > > >> >> > timer either in Up or Continuous mode to generate both PWM as well as
> > > > >> >> > timeouts? Please help me for this. Your earliest help in this regard
> > > > >> >> > will be
> > > > >> >> > highly appreciated. Thanks in advance.
> > > > >> >> >
> > > > >> >> >
> > > > >> >>
> > > > >> >
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > >
> > >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: Re: PWM using TimerB in Continuous mode - Bart Oegema - Sep 16 11:43:41 2009
I think you're still missing it. You're both lengthening and
shortening the duty cycle in your application, but this only happens
when you're making the duty cycle shorter. Look closely at Michael's
example and hint.
- Bart
On Wed, Sep 16, 2009 at 12:28 AM, ti2tt
wrote:
>
> Hello Michael,
>
> With ref to your example, the ON or OFF time will change and in turn the duty cycle of
PWM will change. But how to avoid it? What could be the remedy for classic mistake?
>
> Thanks in advance.
>
> --- In m...@yahoogroups.com, "ti2tt" wrote:
> >
> > Hello,
> >
> > Thanks Michael.
> >
> > I am trying to locate the "Classic mistake". What is the way out to avoid this
mistake? Your example clears the point where the mistake is occurring.
> >
> > Thanks in advance.
> > --- In m...@yahoogroups.com, "tintronic" wrote:
> > >
> > > Let me guess, it only happens when you are lowering the DC but not when you're
increasing it? Classic mistake, think about it.
> > >
> > > Hint: What happens when TAR is nearing TACCRx and you write a new value to TACCRx
that is lower than the actual count of TAR.
> > >
> > > TACCRx is 1000 and TAR is 900.
> > > You write TACCRx = 800.
> > > What happens next?
> > >
> > > Regards,
> > > Michael K.
> > >
> > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > >
> > > > Hello Bart / Forum members,
> > > >
> > > > Thank you for your guidance to understant the UP/Continuous mode.
> > > >
> > > > I am now able to generate the PWM in continuous mode and can vary the PWM duty
cycle from 0% to 100%. Here I have observed that the PWM duty cycle deviates to 100% at
lower values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have
solution for the same? This happens at some regular interval. This interval instance could
be the TBR overflow, but I am not sure. Does anyone has similar observation? Please
provide me solution for this.
> > > >
> > > > Thanks in advance.
> > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > >
> > > > > To basically repeat my question from earlier, what happens in each of
> > > > > the timer modes? Back off from trying to create a PWM output for the
> > > > > moment, and think about how the module functions.
> > > > >
> > > > > To give you part of the solution to get you started a bit further in
> > > > > the direction I'm thinking, in UP mode the timer counts up to the
> > > > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > > > counting up again.
> > > > >
> > > > > What happens (and what are you depending on in your timeout routines)
> > > > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > > > expected, what is happening? When the timeouts are working in
> > > > > continuous mode, what is happening?
> > > > >
> > > > > - Bart
> > > > >
> > > > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > > > >
> > > > > >
> > > > > > Hello Bart,
> > > > > >
> > > > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I was
> > > > > > unable to find why the continuous mode is not generating the PWM. The PWM
> > > > > > generation is possible in continuos mode even. Please let me know what
> > > > > > exactly is going wrong with my code.
> > > > > >
> > > > > > Thanks in advance.
> > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > >>
> > > > > >> You'll find it in the MSP430x2xx Family User Guide, specifically chapter
> > > > > >> 12.
> > > > > >>
> > > > > >> http://www.ti.com/litv/pdf/slau144e
> > > > > >>
> > > > > >> - Bart
> > > > > >>
> > > > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > > > >> >
> > > > > >> >
> > > > > >> > Thanks Bart for your reply.!! I tried to look for the different mode
> > > > > >> > configurations but alas.
> > > > > >> >
> > > > > >> > Does anyone have solution for this? I really need the same very much as
> > > > > >> > project work is held up. I request all forum members for the same.
> > > > > >> > Thanks in
> > > > > >> > advance.
> > > > > >> >
> > > > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > >> >>
> > > > > >> >> Read and think about what is happening in the different timer modes
> > > > > >> >> (up and continuous, in this case). What happens in UP mode when the
> > > > > >> >> timer register counts to the value specified in TBCCR0? What happens
> > > > > >> >> in continuous mode when the same happens?
> > > > > >> >>
> > > > > >> >> - Bart
> > > > > >> >>
> > > > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > > > >> >> >
> > > > > >> >> >
> > > > > >> >> > Hello Friends/Members,
> > > > > >> >> >
> > > > > >> >> > I am using MSP430F2418 device and want to generate the PWM on pin TB5
> > > > > >> >> > using
> > > > > >> >> > continuous mode of TimerB. I am using this timer - module 4 and
> > > > > >> >> > module 6
> > > > > >> >> > -
> > > > > >> >> > for two different timeout values. I want to generate a PWM of 50%
> > > > > >> >> > duty
> > > > > >> >> > cycle
> > > > > >> >> > and a period of 150Hz using module 5 which in turn will output a PWM
> > > > > >> >> > on
> > > > > >> >> > TB5.
> > > > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to configure
> > > > > >> >> > TimerB
> > > > > >> >> > and corresponding modules:
> > > > > >> >> >
> > > > > >> >> > void Init_TimerB (void)
> > > > > >> >> > {
> > > > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB /
> > > > > >> >> > Stop
> > > > > >> >> > TimerB
> > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 /
> > > > > >> >> > Stop
> > > > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > > > >> >> >
> > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by
> > > > > >> >> > 2
> > > > > >> >> > /
> > > > > >> >> > Continuous
> > > > > >> >> > }
> > > > > >> >> >
> > > > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > > > >> >> > {
> > > > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > > > >> >> > //CM_0 = No Capture
> > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > >> >> > //SCS = Synchronous capture
> > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > >> >> > //CCIE = Enable interrupt
> > > > > >> >> > //OUT = Output high on pin
> > > > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> > > > > >> >> > TBCCR4 = (TBR + tout);
> > > > > >> >> > }
> > > > > >> >> >
> > > > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > > > >> >> > {
> > > > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > > > >> >> > //CM_0 = No Capture
> > > > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > > > >> >> > //SCS = Synchronous capture
> > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > >> >> > //OUTMOD_4 = Toggle TB6
> > > > > >> >> > //CCIE = Enable interrupt
> > > > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> > > > > >> >> > TBCCR6 = (TBR + tout);
> > > > > >> >> > }
> > > > > >> >> >
> > > > > >> >> > void ConfigTimerB5_PWM (void)
> > > > > >> >> > {
> > > > > >> >> > P4SEL &= ~0xA0;
> > > > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > > > >> >> >
> > > > > >> >> > TBCCR0 = 0;
> > > > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > > > >> >> > //CM_0 = No Capture
> > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > >> >> > //SCS = Synchronous capture
> > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > >> >> > //CCIE = Enable interrupt
> > > > > >> >> > //OUT = Output high on pin
> > > > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > > > > >> >> > TBCCR5 = (1660);
> > > > > >> >> > }
> > > > > >> >> >
> > > > > >> >> > I am not sure of module 5 configuration. Please guide me to get the
> > > > > >> >> > PWM
> > > > > >> >> > in
> > > > > >> >> > continuous mode. If I use UP mode for timer, then I am able to
> > > > > >> >> > generate
> > > > > >> >> > the
> > > > > >> >> > PWM properly but failing to get required timeouts. Is it possible to
> > > > > >> >> > use
> > > > > >> >> > timer either in Up or Continuous mode to generate both PWM as well as
> > > > > >> >> > timeouts? Please help me for this. Your earliest help in this regard
> > > > > >> >> > will be
> > > > > >> >> > highly appreciated. Thanks in advance.
> > > > > >> >> >
> > > > > >> >> >
> > > > > >> >>
> > > > > >> >
> > > > > >> >
> > > > > >>
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Sep 16 14:11:26 2009
Hello Bart / Michael,
The user guide slau144e.pdf - pg no 13-8 states, "When the sum of the previous TBCLx value
plus tx is greater than the TBCL0 data, TBCL0+1 must be subtracted to obtain the correct
time interval". Are you both pointing to same? I think this is what the code is missing.
Please guide me in detail.
Thanks in advance.
--- In m...@yahoogroups.com, Bart Oegema
wrote:
>
> I think you're still missing it. You're both lengthening and
> shortening the duty cycle in your application, but this only happens
> when you're making the duty cycle shorter. Look closely at Michael's
> example and hint.
>
> - Bart
>
> On Wed, Sep 16, 2009 at 12:28 AM, ti2tt wrote:
> >
> >
> >
> > Hello Michael,
> >
> > With ref to your example, the ON or OFF time will change and in turn the duty cycle of
PWM will change. But how to avoid it? What could be the remedy for classic mistake?
> >
> > Thanks in advance.
> >
> > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > >
> > > Hello,
> > >
> > > Thanks Michael.
> > >
> > > I am trying to locate the "Classic mistake". What is the way out to avoid this
mistake? Your example clears the point where the mistake is occurring.
> > >
> > > Thanks in advance.
> > > --- In m...@yahoogroups.com, "tintronic" wrote:
> > > >
> > > > Let me guess, it only happens when you are lowering the DC but not when you're
increasing it? Classic mistake, think about it.
> > > >
> > > > Hint: What happens when TAR is nearing TACCRx and you write a new value to TACCRx
that is lower than the actual count of TAR.
> > > >
> > > > TACCRx is 1000 and TAR is 900.
> > > > You write TACCRx = 800.
> > > > What happens next?
> > > >
> > > > Regards,
> > > > Michael K.
> > > >
> > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > >
> > > > > Hello Bart / Forum members,
> > > > >
> > > > > Thank you for your guidance to understant the UP/Continuous mode.
> > > > >
> > > > > I am now able to generate the PWM in continuous mode and can vary the PWM duty
cycle from 0% to 100%. Here I have observed that the PWM duty cycle deviates to 100% at
lower values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have
solution for the same? This happens at some regular interval. This interval instance could
be the TBR overflow, but I am not sure. Does anyone has similar observation? Please
provide me solution for this.
> > > > >
> > > > > Thanks in advance.
> > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > >
> > > > > > To basically repeat my question from earlier, what happens in each of
> > > > > > the timer modes? Back off from trying to create a PWM output for the
> > > > > > moment, and think about how the module functions.
> > > > > >
> > > > > > To give you part of the solution to get you started a bit further in
> > > > > > the direction I'm thinking, in UP mode the timer counts up to the
> > > > > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > > > > counting up again.
> > > > > >
> > > > > > What happens (and what are you depending on in your timeout routines)
> > > > > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > > > > expected, what is happening? When the timeouts are working in
> > > > > > continuous mode, what is happening?
> > > > > >
> > > > > > - Bart
> > > > > >
> > > > > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > > > > >
> > > > > > >
> > > > > > > Hello Bart,
> > > > > > >
> > > > > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I was
> > > > > > > unable to find why the continuous mode is not generating the PWM. The PWM
> > > > > > > generation is possible in continuos mode even. Please let me know what
> > > > > > > exactly is going wrong with my code.
> > > > > > >
> > > > > > > Thanks in advance.
> > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > >>
> > > > > > >> You'll find it in the MSP430x2xx Family User Guide, specifically chapter
> > > > > > >> 12.
> > > > > > >>
> > > > > > >> http://www.ti.com/litv/pdf/slau144e
> > > > > > >>
> > > > > > >> - Bart
> > > > > > >>
> > > > > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > > > > >> >
> > > > > > >> >
> > > > > > >> > Thanks Bart for your reply.!! I tried to look for the different mode
> > > > > > >> > configurations but alas.
> > > > > > >> >
> > > > > > >> > Does anyone have solution for this? I really need the same very much
as
> > > > > > >> > project work is held up. I request all forum members for the same.
> > > > > > >> > Thanks in
> > > > > > >> > advance.
> > > > > > >> >
> > > > > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > >> >>
> > > > > > >> >> Read and think about what is happening in the different timer modes
> > > > > > >> >> (up and continuous, in this case). What happens in UP mode when the
> > > > > > >> >> timer register counts to the value specified in TBCCR0? What happens
> > > > > > >> >> in continuous mode when the same happens?
> > > > > > >> >>
> > > > > > >> >> - Bart
> > > > > > >> >>
> > > > > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > > > > >> >> >
> > > > > > >> >> >
> > > > > > >> >> > Hello Friends/Members,
> > > > > > >> >> >
> > > > > > >> >> > I am using MSP430F2418 device and want to generate the PWM on pin
TB5
> > > > > > >> >> > using
> > > > > > >> >> > continuous mode of TimerB. I am using this timer - module 4 and
> > > > > > >> >> > module 6
> > > > > > >> >> > -
> > > > > > >> >> > for two different timeout values. I want to generate a PWM of 50%
> > > > > > >> >> > duty
> > > > > > >> >> > cycle
> > > > > > >> >> > and a period of 150Hz using module 5 which in turn will output a
PWM
> > > > > > >> >> > on
> > > > > > >> >> > TB5.
> > > > > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to
configure
> > > > > > >> >> > TimerB
> > > > > > >> >> > and corresponding modules:
> > > > > > >> >> >
> > > > > > >> >> > void Init_TimerB (void)
> > > > > > >> >> > {
> > > > > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB /
> > > > > > >> >> > Stop
> > > > > > >> >> > TimerB
> > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 /
> > > > > > >> >> > Stop
> > > > > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > > > > >> >> >
> > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide
by
> > > > > > >> >> > 2
> > > > > > >> >> > /
> > > > > > >> >> > Continuous
> > > > > > >> >> > }
> > > > > > >> >> >
> > > > > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > > > > >> >> > {
> > > > > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > > > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > > > > >> >> > //CM_0 = No Capture
> > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > >> >> > //SCS = Synchronous capture
> > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > >> >> > //OUT = Output high on pin
> > > > > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> > > > > > >> >> > TBCCR4 = (TBR + tout);
> > > > > > >> >> > }
> > > > > > >> >> >
> > > > > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > > > > >> >> > {
> > > > > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > > > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > > > > >> >> > //CM_0 = No Capture
> > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > > > > >> >> > //SCS = Synchronous capture
> > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > >> >> > //OUTMOD_4 = Toggle TB6
> > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > > > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> > > > > > >> >> > TBCCR6 = (TBR + tout);
> > > > > > >> >> > }
> > > > > > >> >> >
> > > > > > >> >> > void ConfigTimerB5_PWM (void)
> > > > > > >> >> > {
> > > > > > >> >> > P4SEL &= ~0xA0;
> > > > > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > > > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > > > > >> >> >
> > > > > > >> >> > TBCCR0 = 0;
> > > > > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > > > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > > > > >> >> > //CM_0 = No Capture
> > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > >> >> > //SCS = Synchronous capture
> > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > >> >> > //OUT = Output high on pin
> > > > > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > > > > > >> >> > TBCCR5 = (1660);
> > > > > > >> >> > }
> > > > > > >> >> >
> > > > > > >> >> > I am not sure of module 5 configuration. Please guide me to get the
> > > > > > >> >> > PWM
> > > > > > >> >> > in
> > > > > > >> >> > continuous mode. If I use UP mode for timer, then I am able to
> > > > > > >> >> > generate
> > > > > > >> >> > the
> > > > > > >> >> > PWM properly but failing to get required timeouts. Is it possible
to
> > > > > > >> >> > use
> > > > > > >> >> > timer either in Up or Continuous mode to generate both PWM as well
as
> > > > > > >> >> > timeouts? Please help me for this. Your earliest help in this
regard
> > > > > > >> >> > will be
> > > > > > >> >> > highly appreciated. Thanks in advance.
> > > > > > >> >> >
> > > > > > >> >> >
> > > > > > >> >>
> > > > > > >> >
> > > > > > >> >
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - Michael - Sep 16 16:11:46 2009
At this point you really should have enought data to arrive at the right conclusion and be
able to solve your problem. But to not be cruel and spare you the suffering (althought
Onestone may say the contrary ;-) ):
Your problem is that by changing TACCRx to a lower value than the present count of TAR,
you are missing that periods EQUx event, thus only after TAR rolles over will the EQUx
event (TACCRx = TAR) occur and change the pin state. Remember the Compare Module only
looks for the event in which TACCRx is equal to TAR, setting the EQUx internal signal,
which in turn affects the OUTPUTx unit. EQUx sets only while TACCRx = TAR, not while
TACCRx >= TAR. Understanding this is the center of your issue.
It will be helpful for you to read the timerB chapter. Timer B has additional options to
solve this problem on the hardware level, automatically choosing when to load the real
(and hidden) compare register TBCLx with the value in TBCCRx.
Short answer, you need to check if TAR is still lower than the new value of TACCRx you
want to write:
while (value > (TAR-20) // Check if new value is too close or past TAR.
; //Wait until TAR rolles over
TACCR = value;
Better yet, don't change TACCRx directly. Instead use a global variable, for example
PERIOD, and use TACCRx interrupt to write that value into TACCRx. As long as you aren't
using a bit toggle mode, but reset/set or set/reset, all should work fine.
__interrupt void TimerA1 (void)
{
switch (TAIV)
{
case TACC_x:
TACCRx = Period;
break;
}
}
I hope I was not too condescending in giving you the answer instead of leading you to it
as I first intended and tried.
Best Regards,
Michael
--- In m...@yahoogroups.com, Bart Oegema
wrote:
>
> I think you're still missing it. You're both lengthening and
> shortening the duty cycle in your application, but this only happens
> when you're making the duty cycle shorter. Look closely at Michael's
> example and hint.
>
> - Bart
>
> On Wed, Sep 16, 2009 at 12:28 AM, ti2tt wrote:
> >
> >
> >
> > Hello Michael,
> >
> > With ref to your example, the ON or OFF time will change and in turn the duty cycle of
PWM will change. But how to avoid it? What could be the remedy for classic mistake?
> >
> > Thanks in advance.
> >
> > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > >
> > > Hello,
> > >
> > > Thanks Michael.
> > >
> > > I am trying to locate the "Classic mistake". What is the way out to avoid this
mistake? Your example clears the point where the mistake is occurring.
> > >
> > > Thanks in advance.
> > > --- In m...@yahoogroups.com, "tintronic" wrote:
> > > >
> > > > Let me guess, it only happens when you are lowering the DC but not when you're
increasing it? Classic mistake, think about it.
> > > >
> > > > Hint: What happens when TAR is nearing TACCRx and you write a new value to TACCRx
that is lower than the actual count of TAR.
> > > >
> > > > TACCRx is 1000 and TAR is 900.
> > > > You write TACCRx = 800.
> > > > What happens next?
> > > >
> > > > Regards,
> > > > Michael K.
> > > >
> > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > >
> > > > > Hello Bart / Forum members,
> > > > >
> > > > > Thank you for your guidance to understant the UP/Continuous mode.
> > > > >
> > > > > I am now able to generate the PWM in continuous mode and can vary the PWM duty
cycle from 0% to 100%. Here I have observed that the PWM duty cycle deviates to 100% at
lower values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have
solution for the same? This happens at some regular interval. This interval instance could
be the TBR overflow, but I am not sure. Does anyone has similar observation? Please
provide me solution for this.
> > > > >
> > > > > Thanks in advance.
> > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > >
> > > > > > To basically repeat my question from earlier, what happens in each of
> > > > > > the timer modes? Back off from trying to create a PWM output for the
> > > > > > moment, and think about how the module functions.
> > > > > >
> > > > > > To give you part of the solution to get you started a bit further in
> > > > > > the direction I'm thinking, in UP mode the timer counts up to the
> > > > > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > > > > counting up again.
> > > > > >
> > > > > > What happens (and what are you depending on in your timeout routines)
> > > > > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > > > > expected, what is happening? When the timeouts are working in
> > > > > > continuous mode, what is happening?
> > > > > >
> > > > > > - Bart
> > > > > >
> > > > > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > > > > >
> > > > > > >
> > > > > > > Hello Bart,
> > > > > > >
> > > > > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I was
> > > > > > > unable to find why the continuous mode is not generating the PWM. The PWM
> > > > > > > generation is possible in continuos mode even. Please let me know what
> > > > > > > exactly is going wrong with my code.
> > > > > > >
> > > > > > > Thanks in advance.
> > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > >>
> > > > > > >> You'll find it in the MSP430x2xx Family User Guide, specifically chapter
> > > > > > >> 12.
> > > > > > >>
> > > > > > >> http://www.ti.com/litv/pdf/slau144e
> > > > > > >>
> > > > > > >> - Bart
> > > > > > >>
> > > > > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > > > > >> >
> > > > > > >> >
> > > > > > >> > Thanks Bart for your reply.!! I tried to look for the different mode
> > > > > > >> > configurations but alas.
> > > > > > >> >
> > > > > > >> > Does anyone have solution for this? I really need the same very much
as
> > > > > > >> > project work is held up. I request all forum members for the same.
> > > > > > >> > Thanks in
> > > > > > >> > advance.
> > > > > > >> >
> > > > > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > >> >>
> > > > > > >> >> Read and think about what is happening in the different timer modes
> > > > > > >> >> (up and continuous, in this case). What happens in UP mode when the
> > > > > > >> >> timer register counts to the value specified in TBCCR0? What happens
> > > > > > >> >> in continuous mode when the same happens?
> > > > > > >> >>
> > > > > > >> >> - Bart
> > > > > > >> >>
> > > > > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > > > > >> >> >
> > > > > > >> >> >
> > > > > > >> >> > Hello Friends/Members,
> > > > > > >> >> >
> > > > > > >> >> > I am using MSP430F2418 device and want to generate the PWM on pin
TB5
> > > > > > >> >> > using
> > > > > > >> >> > continuous mode of TimerB. I am using this timer - module 4 and
> > > > > > >> >> > module 6
> > > > > > >> >> > -
> > > > > > >> >> > for two different timeout values. I want to generate a PWM of 50%
> > > > > > >> >> > duty
> > > > > > >> >> > cycle
> > > > > > >> >> > and a period of 150Hz using module 5 which in turn will output a
PWM
> > > > > > >> >> > on
> > > > > > >> >> > TB5.
> > > > > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to
configure
> > > > > > >> >> > TimerB
> > > > > > >> >> > and corresponding modules:
> > > > > > >> >> >
> > > > > > >> >> > void Init_TimerB (void)
> > > > > > >> >> > {
> > > > > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB /
> > > > > > >> >> > Stop
> > > > > > >> >> > TimerB
> > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 /
> > > > > > >> >> > Stop
> > > > > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > > > > >> >> >
> > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide
by
> > > > > > >> >> > 2
> > > > > > >> >> > /
> > > > > > >> >> > Continuous
> > > > > > >> >> > }
> > > > > > >> >> >
> > > > > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > > > > >> >> > {
> > > > > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > > > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > > > > >> >> > //CM_0 = No Capture
> > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > >> >> > //SCS = Synchronous capture
> > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > >> >> > //OUT = Output high on pin
> > > > > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> > > > > > >> >> > TBCCR4 = (TBR + tout);
> > > > > > >> >> > }
> > > > > > >> >> >
> > > > > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > > > > >> >> > {
> > > > > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > > > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > > > > >> >> > //CM_0 = No Capture
> > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > > > > >> >> > //SCS = Synchronous capture
> > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > >> >> > //OUTMOD_4 = Toggle TB6
> > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > > > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> > > > > > >> >> > TBCCR6 = (TBR + tout);
> > > > > > >> >> > }
> > > > > > >> >> >
> > > > > > >> >> > void ConfigTimerB5_PWM (void)
> > > > > > >> >> > {
> > > > > > >> >> > P4SEL &= ~0xA0;
> > > > > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > > > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > > > > >> >> >
> > > > > > >> >> > TBCCR0 = 0;
> > > > > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > > > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > > > > >> >> > //CM_0 = No Capture
> > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > >> >> > //SCS = Synchronous capture
> > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > >> >> > //OUT = Output high on pin
> > > > > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > > > > > >> >> > TBCCR5 = (1660);
> > > > > > >> >> > }
> > > > > > >> >> >
> > > > > > >> >> > I am not sure of module 5 configuration. Please guide me to get the
> > > > > > >> >> > PWM
> > > > > > >> >> > in
> > > > > > >> >> > continuous mode. If I use UP mode for timer, then I am able to
> > > > > > >> >> > generate
> > > > > > >> >> > the
> > > > > > >> >> > PWM properly but failing to get required timeouts. Is it possible
to
> > > > > > >> >> > use
> > > > > > >> >> > timer either in Up or Continuous mode to generate both PWM as well
as
> > > > > > >> >> > timeouts? Please help me for this. Your earliest help in this
regard
> > > > > > >> >> > will be
> > > > > > >> >> > highly appreciated. Thanks in advance.
> > > > > > >> >> >
> > > > > > >> >> >
> > > > > > >> >>
> > > > > > >> >
> > > > > > >> >
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Sep 22 10:38:32 2009
Hello Michael,
Thanks for your kind help. I am still to get the classic mistake cleared. I hope you will
be kind enough to give me the right solution. Your earliest help will be highly
appreciated. Thanks in advance.
--- In m...@yahoogroups.com, "Michael"
wrote:
>
> At this point you really should have enought data to arrive at the right conclusion and
be able to solve your problem. But to not be cruel and spare you the suffering (althought
Onestone may say the contrary ;-) ):
>
> Your problem is that by changing TACCRx to a lower value than the present count of TAR,
you are missing that periods EQUx event, thus only after TAR rolles over will the EQUx
event (TACCRx = TAR) occur and change the pin state. Remember the Compare Module only
looks for the event in which TACCRx is equal to TAR, setting the EQUx internal signal,
which in turn affects the OUTPUTx unit. EQUx sets only while TACCRx = TAR, not while
TACCRx >= TAR. Understanding this is the center of your issue.
>
> It will be helpful for you to read the timerB chapter. Timer B has additional options to
solve this problem on the hardware level, automatically choosing when to load the real
(and hidden) compare register TBCLx with the value in TBCCRx.
>
> Short answer, you need to check if TAR is still lower than the new value of TACCRx you
want to write:
> while (value > (TAR-20) // Check if new value is too close or past TAR.
> ; //Wait until TAR rolles over
> TACCR = value;
>
> Better yet, don't change TACCRx directly. Instead use a global variable, for example
PERIOD, and use TACCRx interrupt to write that value into TACCRx. As long as you aren't
using a bit toggle mode, but reset/set or set/reset, all should work fine.
>
> __interrupt void TimerA1 (void)
> {
> switch (TAIV)
> {
> case TACC_x:
> TACCRx = Period;
> break;
> }
> }
>
> I hope I was not too condescending in giving you the answer instead of leading you to it
as I first intended and tried.
>
> Best Regards,
> Michael
> --- In m...@yahoogroups.com, Bart Oegema wrote:
> >
> > I think you're still missing it. You're both lengthening and
> > shortening the duty cycle in your application, but this only happens
> > when you're making the duty cycle shorter. Look closely at Michael's
> > example and hint.
> >
> > - Bart
> >
> > On Wed, Sep 16, 2009 at 12:28 AM, ti2tt wrote:
> > >
> > >
> > >
> > > Hello Michael,
> > >
> > > With ref to your example, the ON or OFF time will change and in turn the duty cycle
of PWM will change. But how to avoid it? What could be the remedy for classic mistake?
> > >
> > > Thanks in advance.
> > >
> > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > >
> > > > Hello,
> > > >
> > > > Thanks Michael.
> > > >
> > > > I am trying to locate the "Classic mistake". What is the way out to avoid this
mistake? Your example clears the point where the mistake is occurring.
> > > >
> > > > Thanks in advance.
> > > > --- In m...@yahoogroups.com, "tintronic" wrote:
> > > > >
> > > > > Let me guess, it only happens when you are lowering the DC but not when you're
increasing it? Classic mistake, think about it.
> > > > >
> > > > > Hint: What happens when TAR is nearing TACCRx and you write a new value to
TACCRx that is lower than the actual count of TAR.
> > > > >
> > > > > TACCRx is 1000 and TAR is 900.
> > > > > You write TACCRx = 800.
> > > > > What happens next?
> > > > >
> > > > > Regards,
> > > > > Michael K.
> > > > >
> > > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > > >
> > > > > > Hello Bart / Forum members,
> > > > > >
> > > > > > Thank you for your guidance to understant the UP/Continuous mode.
> > > > > >
> > > > > > I am now able to generate the PWM in continuous mode and can vary the PWM duty
cycle from 0% to 100%. Here I have observed that the PWM duty cycle deviates to 100% at
lower values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have
solution for the same? This happens at some regular interval. This interval instance could
be the TBR overflow, but I am not sure. Does anyone has similar observation? Please
provide me solution for this.
> > > > > >
> > > > > > Thanks in advance.
> > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > >
> > > > > > > To basically repeat my question from earlier, what happens in each of
> > > > > > > the timer modes? Back off from trying to create a PWM output for the
> > > > > > > moment, and think about how the module functions.
> > > > > > >
> > > > > > > To give you part of the solution to get you started a bit further in
> > > > > > > the direction I'm thinking, in UP mode the timer counts up to the
> > > > > > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > > > > > counting up again.
> > > > > > >
> > > > > > > What happens (and what are you depending on in your timeout routines)
> > > > > > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > > > > > expected, what is happening? When the timeouts are working in
> > > > > > > continuous mode, what is happening?
> > > > > > >
> > > > > > > - Bart
> > > > > > >
> > > > > > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > Hello Bart,
> > > > > > > >
> > > > > > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I
was
> > > > > > > > unable to find why the continuous mode is not generating the PWM. The
PWM
> > > > > > > > generation is possible in continuos mode even. Please let me know what
> > > > > > > > exactly is going wrong with my code.
> > > > > > > >
> > > > > > > > Thanks in advance.
> > > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > >>
> > > > > > > >> You'll find it in the MSP430x2xx Family User Guide, specifically
chapter
> > > > > > > >> 12.
> > > > > > > >>
> > > > > > > >> http://www.ti.com/litv/pdf/slau144e
> > > > > > > >>
> > > > > > > >> - Bart
> > > > > > > >>
> > > > > > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > > > > > >> >
> > > > > > > >> >
> > > > > > > >> > Thanks Bart for your reply.!! I tried to look for the different mode
> > > > > > > >> > configurations but alas.
> > > > > > > >> >
> > > > > > > >> > Does anyone have solution for this? I really need the same very much
as
> > > > > > > >> > project work is held up. I request all forum members for the same.
> > > > > > > >> > Thanks in
> > > > > > > >> > advance.
> > > > > > > >> >
> > > > > > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > >> >>
> > > > > > > >> >> Read and think about what is happening in the different timer modes
> > > > > > > >> >> (up and continuous, in this case). What happens in UP mode when the
> > > > > > > >> >> timer register counts to the value specified in TBCCR0? What
happens
> > > > > > > >> >> in continuous mode when the same happens?
> > > > > > > >> >>
> > > > > > > >> >> - Bart
> > > > > > > >> >>
> > > > > > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > > > > > >> >> >
> > > > > > > >> >> >
> > > > > > > >> >> > Hello Friends/Members,
> > > > > > > >> >> >
> > > > > > > >> >> > I am using MSP430F2418 device and want to generate the PWM on pin
TB5
> > > > > > > >> >> > using
> > > > > > > >> >> > continuous mode of TimerB. I am using this timer - module 4 and
> > > > > > > >> >> > module 6
> > > > > > > >> >> > -
> > > > > > > >> >> > for two different timeout values. I want to generate a PWM of 50%
> > > > > > > >> >> > duty
> > > > > > > >> >> > cycle
> > > > > > > >> >> > and a period of 150Hz using module 5 which in turn will output a
PWM
> > > > > > > >> >> > on
> > > > > > > >> >> > TB5.
> > > > > > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to
configure
> > > > > > > >> >> > TimerB
> > > > > > > >> >> > and corresponding modules:
> > > > > > > >> >> >
> > > > > > > >> >> > void Init_TimerB (void)
> > > > > > > >> >> > {
> > > > > > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB
/
> > > > > > > >> >> > Stop
> > > > > > > >> >> > TimerB
> > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2
/
> > > > > > > >> >> > Stop
> > > > > > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > > > > > >> >> >
> > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide
by
> > > > > > > >> >> > 2
> > > > > > > >> >> > /
> > > > > > > >> >> > Continuous
> > > > > > > >> >> > }
> > > > > > > >> >> >
> > > > > > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > > > > > >> >> > {
> > > > > > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > > > > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE | OUT);
> > > > > > > >> >> > TBCCR4 = (TBR + tout);
> > > > > > > >> >> > }
> > > > > > > >> >> >
> > > > > > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > > > > > >> >> > {
> > > > > > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > > > > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > >> >> > //OUTMOD_4 = Toggle TB6
> > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > > > > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE | OUT);
> > > > > > > >> >> > TBCCR6 = (TBR + tout);
> > > > > > > >> >> > }
> > > > > > > >> >> >
> > > > > > > >> >> > void ConfigTimerB5_PWM (void)
> > > > > > > >> >> > {
> > > > > > > >> >> > P4SEL &= ~0xA0;
> > > > > > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > > > > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > > > > > >> >> >
> > > > > > > >> >> > TBCCR0 = 0;
> > > > > > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > > > > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > > > > > > >> >> > TBCCR5 = (1660);
> > > > > > > >> >> > }
> > > > > > > >> >> >
> > > > > > > >> >> > I am not sure of module 5 configuration. Please guide me to get
the
> > > > > > > >> >> > PWM
> > > > > > > >> >> > in
> > > > > > > >> >> > continuous mode. If I use UP mode for timer, then I am able to
> > > > > > > >> >> > generate
> > > > > > > >> >> > the
> > > > > > > >> >> > PWM properly but failing to get required timeouts. Is it possible
to
> > > > > > > >> >> > use
> > > > > > > >> >> > timer either in Up or Continuous mode to generate both PWM as well
as
> > > > > > > >> >> > timeouts? Please help me for this. Your earliest help in this
regard
> > > > > > > >> >> > will be
> > > > > > > >> >> > highly appreciated. Thanks in advance.
> > > > > > > >> >> >
> > > > > > > >> >> >
> > > > > > > >> >>
> > > > > > > >> >
> > > > > > > >> >
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Sep 25 2:21:38 2009
Hello Forum members,
Has anyone experienced similar issues with PWM? Please share your views. I am in desperate
need for the solution. Request you all for the help.
Thanks in advance.
--- In m...@yahoogroups.com, "ti2tt"
wrote:
>
> Hello Michael,
>
> Thanks for your kind help. I am still to get the classic mistake cleared. I hope you
will be kind enough to give me the right solution. Your earliest help will be highly
appreciated. Thanks in advance.
> --- In m...@yahoogroups.com, "Michael" wrote:
> >
> > At this point you really should have enought data to arrive at the right conclusion
and be able to solve your problem. But to not be cruel and spare you the suffering
(althought Onestone may say the contrary ;-) ):
> >
> > Your problem is that by changing TACCRx to a lower value than the present count of
TAR, you are missing that periods EQUx event, thus only after TAR rolles over will the
EQUx event (TACCRx = TAR) occur and change the pin state. Remember the Compare Module only
looks for the event in which TACCRx is equal to TAR, setting the EQUx internal signal,
which in turn affects the OUTPUTx unit. EQUx sets only while TACCRx = TAR, not while
TACCRx >= TAR. Understanding this is the center of your issue.
> >
> > It will be helpful for you to read the timerB chapter. Timer B has additional options
to solve this problem on the hardware level, automatically choosing when to load the real
(and hidden) compare register TBCLx with the value in TBCCRx.
> >
> > Short answer, you need to check if TAR is still lower than the new value of TACCRx you
want to write:
> > while (value > (TAR-20) // Check if new value is too close or past TAR.
> > ; //Wait until TAR rolles over
> > TACCR = value;
> >
> > Better yet, don't change TACCRx directly. Instead use a global variable, for example
PERIOD, and use TACCRx interrupt to write that value into TACCRx. As long as you aren't
using a bit toggle mode, but reset/set or set/reset, all should work fine.
> >
> > __interrupt void TimerA1 (void)
> > {
> > switch (TAIV)
> > {
> > case TACC_x:
> > TACCRx = Period;
> > break;
> > }
> > }
> >
> > I hope I was not too condescending in giving you the answer instead of leading you to
it as I first intended and tried.
> >
> > Best Regards,
> > Michael
> >
> >
> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > >
> > > I think you're still missing it. You're both lengthening and
> > > shortening the duty cycle in your application, but this only happens
> > > when you're making the duty cycle shorter. Look closely at Michael's
> > > example and hint.
> > >
> > > - Bart
> > >
> > > On Wed, Sep 16, 2009 at 12:28 AM, ti2tt wrote:
> > > >
> > > >
> > > >
> > > > Hello Michael,
> > > >
> > > > With ref to your example, the ON or OFF time will change and in turn the duty
cycle of PWM will change. But how to avoid it? What could be the remedy for classic
mistake?
> > > >
> > > > Thanks in advance.
> > > >
> > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > >
> > > > > Hello,
> > > > >
> > > > > Thanks Michael.
> > > > >
> > > > > I am trying to locate the "Classic mistake". What is the way out to avoid this
mistake? Your example clears the point where the mistake is occurring.
> > > > >
> > > > > Thanks in advance.
> > > > > --- In m...@yahoogroups.com, "tintronic" wrote:
> > > > > >
> > > > > > Let me guess, it only happens when you are lowering the DC but not when you're
increasing it? Classic mistake, think about it.
> > > > > >
> > > > > > Hint: What happens when TAR is nearing TACCRx and you write a new value to
TACCRx that is lower than the actual count of TAR.
> > > > > >
> > > > > > TACCRx is 1000 and TAR is 900.
> > > > > > You write TACCRx = 800.
> > > > > > What happens next?
> > > > > >
> > > > > > Regards,
> > > > > > Michael K.
> > > > > >
> > > > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > > > >
> > > > > > > Hello Bart / Forum members,
> > > > > > >
> > > > > > > Thank you for your guidance to understant the UP/Continuous mode.
> > > > > > >
> > > > > > > I am now able to generate the PWM in continuous mode and can vary the PWM
duty cycle from 0% to 100%. Here I have observed that the PWM duty cycle deviates to 100%
at lower values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have
solution for the same? This happens at some regular interval. This interval instance could
be the TBR overflow, but I am not sure. Does anyone has similar observation? Please
provide me solution for this.
> > > > > > >
> > > > > > > Thanks in advance.
> > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > >
> > > > > > > > To basically repeat my question from earlier, what happens in each of
> > > > > > > > the timer modes? Back off from trying to create a PWM output for the
> > > > > > > > moment, and think about how the module functions.
> > > > > > > >
> > > > > > > > To give you part of the solution to get you started a bit further in
> > > > > > > > the direction I'm thinking, in UP mode the timer counts up to the
> > > > > > > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > > > > > > counting up again.
> > > > > > > >
> > > > > > > > What happens (and what are you depending on in your timeout routines)
> > > > > > > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > > > > > > expected, what is happening? When the timeouts are working in
> > > > > > > > continuous mode, what is happening?
> > > > > > > >
> > > > > > > > - Bart
> > > > > > > >
> > > > > > > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Hello Bart,
> > > > > > > > >
> > > > > > > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I
was
> > > > > > > > > unable to find why the continuous mode is not generating the PWM. The
PWM
> > > > > > > > > generation is possible in continuos mode even. Please let me know
what
> > > > > > > > > exactly is going wrong with my code.
> > > > > > > > >
> > > > > > > > > Thanks in advance.
> > > > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > >>
> > > > > > > > >> You'll find it in the MSP430x2xx Family User Guide, specifically
chapter
> > > > > > > > >> 12.
> > > > > > > > >>
> > > > > > > > >> http://www.ti.com/litv/pdf/slau144e
> > > > > > > > >>
> > > > > > > > >> - Bart
> > > > > > > > >>
> > > > > > > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > > > > > > >> >
> > > > > > > > >> >
> > > > > > > > >> > Thanks Bart for your reply.!! I tried to look for the different
mode
> > > > > > > > >> > configurations but alas.
> > > > > > > > >> >
> > > > > > > > >> > Does anyone have solution for this? I really need the same very much
as
> > > > > > > > >> > project work is held up. I request all forum members for the same.
> > > > > > > > >> > Thanks in
> > > > > > > > >> > advance.
> > > > > > > > >> >
> > > > > > > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > >> >>
> > > > > > > > >> >> Read and think about what is happening in the different timer
modes
> > > > > > > > >> >> (up and continuous, in this case). What happens in UP mode when
the
> > > > > > > > >> >> timer register counts to the value specified in TBCCR0? What
happens
> > > > > > > > >> >> in continuous mode when the same happens?
> > > > > > > > >> >>
> > > > > > > > >> >> - Bart
> > > > > > > > >> >>
> > > > > > > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > > > > > > >> >> >
> > > > > > > > >> >> >
> > > > > > > > >> >> > Hello Friends/Members,
> > > > > > > > >> >> >
> > > > > > > > >> >> > I am using MSP430F2418 device and want to generate the PWM on pin
TB5
> > > > > > > > >> >> > using
> > > > > > > > >> >> > continuous mode of TimerB. I am using this timer - module 4 and
> > > > > > > > >> >> > module 6
> > > > > > > > >> >> > -
> > > > > > > > >> >> > for two different timeout values. I want to generate a PWM of
50%
> > > > > > > > >> >> > duty
> > > > > > > > >> >> > cycle
> > > > > > > > >> >> > and a period of 150Hz using module 5 which in turn will output a
PWM
> > > > > > > > >> >> > on
> > > > > > > > >> >> > TB5.
> > > > > > > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to
configure
> > > > > > > > >> >> > TimerB
> > > > > > > > >> >> > and corresponding modules:
> > > > > > > > >> >> >
> > > > > > > > >> >> > void Init_TimerB (void)
> > > > > > > > >> >> > {
> > > > > > > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB
/
> > > > > > > > >> >> > Stop
> > > > > > > > >> >> > TimerB
> > > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2
/
> > > > > > > > >> >> > Stop
> > > > > > > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > > > > > > >> >> >
> > > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide
by
> > > > > > > > >> >> > 2
> > > > > > > > >> >> > /
> > > > > > > > >> >> > Continuous
> > > > > > > > >> >> > }
> > > > > > > > >> >> >
> > > > > > > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > > > > > > >> >> > {
> > > > > > > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > > > > > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE |
OUT);
> > > > > > > > >> >> > TBCCR4 = (TBR + tout);
> > > > > > > > >> >> > }
> > > > > > > > >> >> >
> > > > > > > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > > > > > > >> >> > {
> > > > > > > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > > > > > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > > >> >> > //OUTMOD_4 = Toggle TB6
> > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > > > > > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE |
OUT);
> > > > > > > > >> >> > TBCCR6 = (TBR + tout);
> > > > > > > > >> >> > }
> > > > > > > > >> >> >
> > > > > > > > >> >> > void ConfigTimerB5_PWM (void)
> > > > > > > > >> >> > {
> > > > > > > > >> >> > P4SEL &= ~0xA0;
> > > > > > > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > > > > > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > > > > > > >> >> >
> > > > > > > > >> >> > TBCCR0 = 0;
> > > > > > > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > > > > > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE |
OUT);
> > > > > > > > >> >> > TBCCR5 = (1660);
> > > > > > > > >> >> > }
> > > > > > > > >> >> >
> > > > > > > > >> >> > I am not sure of module 5 configuration. Please guide me to get
the
> > > > > > > > >> >> > PWM
> > > > > > > > >> >> > in
> > > > > > > > >> >> > continuous mode. If I use UP mode for timer, then I am able to
> > > > > > > > >> >> > generate
> > > > > > > > >> >> > the
> > > > > > > > >> >> > PWM properly but failing to get required timeouts. Is it possible
to
> > > > > > > > >> >> > use
> > > > > > > > >> >> > timer either in Up or Continuous mode to generate both PWM as well
as
> > > > > > > > >> >> > timeouts? Please help me for this. Your earliest help in this
regard
> > > > > > > > >> >> > will be
> > > > > > > > >> >> > highly appreciated. Thanks in advance.
> > > > > > > > >> >> >
> > > > > > > > >> >> >
> > > > > > > > >> >>
> > > > > > > > >> >
> > > > > > > > >> >
> > > > > > > > >>
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: Re: PWM using TimerB in Continuous mode - Bart Oegema - Sep 25 12:04:25 2009
What have you tried from what Michael suggested? We don't have any
idea what you've tried or what your code looks like at this point, so
we couldn't help you if we wanted to.
- Bart
On Thu, Sep 24, 2009 at 11:20 PM, ti2tt
wrote:
>
> Hello Forum members,
>
> Has anyone experienced similar issues with PWM? Please share your views. I am in
desperate need for the solution. Request you all for the help.
>
> Thanks in advance.
> --- In m...@yahoogroups.com, "ti2tt" wrote:
> >
> > Hello Michael,
> >
> > Thanks for your kind help. I am still to get the classic mistake cleared. I hope you
will be kind enough to give me the right solution. Your earliest help will be highly
appreciated. Thanks in advance.
> > --- In m...@yahoogroups.com, "Michael" wrote:
> > >
> > > At this point you really should have enought data to arrive at the right conclusion
and be able to solve your problem. But to not be cruel and spare you the suffering
(althought Onestone may say the contrary ;-) ):
> > >
> > > Your problem is that by changing TACCRx to a lower value than the present count of
TAR, you are missing that periods EQUx event, thus only after TAR rolles over will the
EQUx event (TACCRx = TAR) occur and change the pin state. Remember the Compare Module only
looks for the event in which TACCRx is equal to TAR, setting the EQUx internal signal,
which in turn affects the OUTPUTx unit. EQUx sets only while TACCRx = TAR, not while
TACCRx >= TAR. Understanding this is the center of your issue.
> > >
> > > It will be helpful for you to read the timerB chapter. Timer B has additional
options to solve this problem on the hardware level, automatically choosing when to load
the real (and hidden) compare register TBCLx with the value in TBCCRx.
> > >
> > > Short answer, you need to check if TAR is still lower than the new value of TACCRx
you want to write:
> > > while (value > (TAR-20) // Check if new value is too close or past TAR.
> > > ; //Wait until TAR rolles over
> > > TACCR = value;
> > >
> > > Better yet, don't change TACCRx directly. Instead use a global variable, for example
PERIOD, and use TACCRx interrupt to write that value into TACCRx. As long as you aren't
using a bit toggle mode, but reset/set or set/reset, all should work fine.
> > >
> > > __interrupt void TimerA1 (void)
> > > {
> > > switch (TAIV)
> > > {
> > > case TACC_x:
> > > TACCRx = Period;
> > > break;
> > > }
> > > }
> > >
> > > I hope I was not too condescending in giving you the answer instead of leading you
to it as I first intended and tried.
> > >
> > > Best Regards,
> > > Michael
> > >
> > >
> > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > >
> > > > I think you're still missing it. You're both lengthening and
> > > > shortening the duty cycle in your application, but this only happens
> > > > when you're making the duty cycle shorter. Look closely at Michael's
> > > > example and hint.
> > > >
> > > > - Bart
> > > >
> > > > On Wed, Sep 16, 2009 at 12:28 AM, ti2tt wrote:
> > > > >
> > > > >
> > > > >
> > > > > Hello Michael,
> > > > >
> > > > > With ref to your example, the ON or OFF time will change and in turn the duty
cycle of PWM will change. But how to avoid it? What could be the remedy for classic
mistake?
> > > > >
> > > > > Thanks in advance.
> > > > >
> > > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > > >
> > > > > > Hello,
> > > > > >
> > > > > > Thanks Michael.
> > > > > >
> > > > > > I am trying to locate the "Classic mistake". What is the way out to avoid this
mistake? Your example clears the point where the mistake is occurring.
> > > > > >
> > > > > > Thanks in advance.
> > > > > > --- In m...@yahoogroups.com, "tintronic" wrote:
> > > > > > >
> > > > > > > Let me guess, it only happens when you are lowering the DC but not when
you're increasing it? Classic mistake, think about it.
> > > > > > >
> > > > > > > Hint: What happens when TAR is nearing TACCRx and you write a new value to
TACCRx that is lower than the actual count of TAR.
> > > > > > >
> > > > > > > TACCRx is 1000 and TAR is 900.
> > > > > > > You write TACCRx = 800.
> > > > > > > What happens next?
> > > > > > >
> > > > > > > Regards,
> > > > > > > Michael K.
> > > > > > >
> > > > > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > > > > >
> > > > > > > > Hello Bart / Forum members,
> > > > > > > >
> > > > > > > > Thank you for your guidance to understant the UP/Continuous mode.
> > > > > > > >
> > > > > > > > I am now able to generate the PWM in continuous mode and can vary the PWM
duty cycle from 0% to 100%. Here I have observed that the PWM duty cycle deviates to 100%
at lower values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have
solution for the same? This happens at some regular interval. This interval instance could
be the TBR overflow, but I am not sure. Does anyone has similar observation? Please
provide me solution for this.
> > > > > > > >
> > > > > > > > Thanks in advance.
> > > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > >
> > > > > > > > > To basically repeat my question from earlier, what happens in each of
> > > > > > > > > the timer modes? Back off from trying to create a PWM output for the
> > > > > > > > > moment, and think about how the module functions.
> > > > > > > > >
> > > > > > > > > To give you part of the solution to get you started a bit further in
> > > > > > > > > the direction I'm thinking, in UP mode the timer counts up to the
> > > > > > > > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > > > > > > > counting up again.
> > > > > > > > >
> > > > > > > > > What happens (and what are you depending on in your timeout routines)
> > > > > > > > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > > > > > > > expected, what is happening? When the timeouts are working in
> > > > > > > > > continuous mode, what is happening?
> > > > > > > > >
> > > > > > > > > - Bart
> > > > > > > > >
> > > > > > > > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Hello Bart,
> > > > > > > > > >
> > > > > > > > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I
was
> > > > > > > > > > unable to find why the continuous mode is not generating the PWM. The
PWM
> > > > > > > > > > generation is possible in continuos mode even. Please let me know
what
> > > > > > > > > > exactly is going wrong with my code.
> > > > > > > > > >
> > > > > > > > > > Thanks in advance.
> > > > > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > > >>
> > > > > > > > > >> You'll find it in the MSP430x2xx Family User Guide, specifically
chapter
> > > > > > > > > >> 12.
> > > > > > > > > >>
> > > > > > > > > >> http://www.ti.com/litv/pdf/slau144e
> > > > > > > > > >>
> > > > > > > > > >> - Bart
> > > > > > > > > >>
> > > > > > > > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > > > > > > > >> >
> > > > > > > > > >> >
> > > > > > > > > >> > Thanks Bart for your reply.!! I tried to look for the different
mode
> > > > > > > > > >> > configurations but alas.
> > > > > > > > > >> >
> > > > > > > > > >> > Does anyone have solution for this? I really need the same very
much as
> > > > > > > > > >> > project work is held up. I request all forum members for the
same.
> > > > > > > > > >> > Thanks in
> > > > > > > > > >> > advance.
> > > > > > > > > >> >
> > > > > > > > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > > >> >>
> > > > > > > > > >> >> Read and think about what is happening in the different timer
modes
> > > > > > > > > >> >> (up and continuous, in this case). What happens in UP mode when
the
> > > > > > > > > >> >> timer register counts to the value specified in TBCCR0? What
happens
> > > > > > > > > >> >> in continuous mode when the same happens?
> > > > > > > > > >> >>
> > > > > > > > > >> >> - Bart
> > > > > > > > > >> >>
> > > > > > > > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > > > > > > > >> >> >
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > Hello Friends/Members,
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > I am using MSP430F2418 device and want to generate the PWM on
pin TB5
> > > > > > > > > >> >> > using
> > > > > > > > > >> >> > continuous mode of TimerB. I am using this timer - module 4
and
> > > > > > > > > >> >> > module 6
> > > > > > > > > >> >> > -
> > > > > > > > > >> >> > for two different timeout values. I want to generate a PWM of
50%
> > > > > > > > > >> >> > duty
> > > > > > > > > >> >> > cycle
> > > > > > > > > >> >> > and a period of 150Hz using module 5 which in turn will output a
PWM
> > > > > > > > > >> >> > on
> > > > > > > > > >> >> > TB5.
> > > > > > > > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to
configure
> > > > > > > > > >> >> > TimerB
> > > > > > > > > >> >> > and corresponding modules:
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > void Init_TimerB (void)
> > > > > > > > > >> >> > {
> > > > > > > > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear
TimerB /
> > > > > > > > > >> >> > Stop
> > > > > > > > > >> >> > TimerB
> > > > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2
/
> > > > > > > > > >> >> > Stop
> > > > > > > > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK /
Divide by
> > > > > > > > > >> >> > 2
> > > > > > > > > >> >> > /
> > > > > > > > > >> >> > Continuous
> > > > > > > > > >> >> > }
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > > > > > > > >> >> > {
> > > > > > > > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > > > > > > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE |
OUT);
> > > > > > > > > >> >> > TBCCR4 = (TBR + tout);
> > > > > > > > > >> >> > }
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > > > > > > > >> >> > {
> > > > > > > > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > > > > > > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > > > >> >> > //OUTMOD_4 = Toggle TB6
> > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > > > > > > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE |
OUT);
> > > > > > > > > >> >> > TBCCR6 = (TBR + tout);
> > > > > > > > > >> >> > }
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > void ConfigTimerB5_PWM (void)
> > > > > > > > > >> >> > {
> > > > > > > > > >> >> > P4SEL &= ~0xA0;
> > > > > > > > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > > > > > > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > TBCCR0 = 0;
> > > > > > > > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > > > > > > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE |
OUT);
> > > > > > > > > >> >> > TBCCR5 = (1660);
> > > > > > > > > >> >> > }
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > I am not sure of module 5 configuration. Please guide me to get
the
> > > > > > > > > >> >> > PWM
> > > > > > > > > >> >> > in
> > > > > > > > > >> >> > continuous mode. If I use UP mode for timer, then I am able
to
> > > > > > > > > >> >> > generate
> > > > > > > > > >> >> > the
> > > > > > > > > >> >> > PWM properly but failing to get required timeouts. Is it
possible to
> > > > > > > > > >> >> > use
> > > > > > > > > >> >> > timer either in Up or Continuous mode to generate both PWM as
well as
> > > > > > > > > >> >> > timeouts? Please help me for this. Your earliest help in this
regard
> > > > > > > > > >> >> > will be
> > > > > > > > > >> >> > highly appreciated. Thanks in advance.
> > > > > > > > > >> >> >
> > > > > > > > > >> >> >
> > > > > > > > > >> >>
> > > > > > > > > >> >
> > > > > > > > > >> >
> > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - Michael - Sep 25 13:27:30 2009
I really can't tell you anything more. I think I made it quite clear what your problem is
and how to solve it, even babystep guided you. If you still can't make it work, the only
advice I have left would be a change of career.
Regards,
Michael K.
--- In m...@yahoogroups.com, "ti2tt"
wrote:
>
> Hello Forum members,
>
> Has anyone experienced similar issues with PWM? Please share your views. I am in
desperate need for the solution. Request you all for the help.
>
> Thanks in advance.
> --- In m...@yahoogroups.com, "ti2tt" wrote:
> >
> > Hello Michael,
> >
> > Thanks for your kind help. I am still to get the classic mistake cleared. I hope you
will be kind enough to give me the right solution. Your earliest help will be highly
appreciated. Thanks in advance.
> > --- In m...@yahoogroups.com, "Michael" wrote:
> > >
> > > At this point you really should have enought data to arrive at the right conclusion
and be able to solve your problem. But to not be cruel and spare you the suffering
(althought Onestone may say the contrary ;-) ):
> > >
> > > Your problem is that by changing TACCRx to a lower value than the present count of
TAR, you are missing that periods EQUx event, thus only after TAR rolles over will the
EQUx event (TACCRx = TAR) occur and change the pin state. Remember the Compare Module only
looks for the event in which TACCRx is equal to TAR, setting the EQUx internal signal,
which in turn affects the OUTPUTx unit. EQUx sets only while TACCRx = TAR, not while
TACCRx >= TAR. Understanding this is the center of your issue.
> > >
> > > It will be helpful for you to read the timerB chapter. Timer B has additional
options to solve this problem on the hardware level, automatically choosing when to load
the real (and hidden) compare register TBCLx with the value in TBCCRx.
> > >
> > > Short answer, you need to check if TAR is still lower than the new value of TACCRx
you want to write:
> > > while (value > (TAR-20) // Check if new value is too close or past TAR.
> > > ; //Wait until TAR rolles over
> > > TACCR = value;
> > >
> > > Better yet, don't change TACCRx directly. Instead use a global variable, for example
PERIOD, and use TACCRx interrupt to write that value into TACCRx. As long as you aren't
using a bit toggle mode, but reset/set or set/reset, all should work fine.
> > >
> > > __interrupt void TimerA1 (void)
> > > {
> > > switch (TAIV)
> > > {
> > > case TACC_x:
> > > TACCRx = Period;
> > > break;
> > > }
> > > }
> > >
> > > I hope I was not too condescending in giving you the answer instead of leading you
to it as I first intended and tried.
> > >
> > > Best Regards,
> > > Michael
> > >
> > >
> > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > >
> > > > I think you're still missing it. You're both lengthening and
> > > > shortening the duty cycle in your application, but this only happens
> > > > when you're making the duty cycle shorter. Look closely at Michael's
> > > > example and hint.
> > > >
> > > > - Bart
> > > >
> > > > On Wed, Sep 16, 2009 at 12:28 AM, ti2tt wrote:
> > > > >
> > > > >
> > > > >
> > > > > Hello Michael,
> > > > >
> > > > > With ref to your example, the ON or OFF time will change and in turn the duty
cycle of PWM will change. But how to avoid it? What could be the remedy for classic
mistake?
> > > > >
> > > > > Thanks in advance.
> > > > >
> > > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > > >
> > > > > > Hello,
> > > > > >
> > > > > > Thanks Michael.
> > > > > >
> > > > > > I am trying to locate the "Classic mistake". What is the way out to avoid this
mistake? Your example clears the point where the mistake is occurring.
> > > > > >
> > > > > > Thanks in advance.
> > > > > > --- In m...@yahoogroups.com, "tintronic" wrote:
> > > > > > >
> > > > > > > Let me guess, it only happens when you are lowering the DC but not when
you're increasing it? Classic mistake, think about it.
> > > > > > >
> > > > > > > Hint: What happens when TAR is nearing TACCRx and you write a new value to
TACCRx that is lower than the actual count of TAR.
> > > > > > >
> > > > > > > TACCRx is 1000 and TAR is 900.
> > > > > > > You write TACCRx = 800.
> > > > > > > What happens next?
> > > > > > >
> > > > > > > Regards,
> > > > > > > Michael K.
> > > > > > >
> > > > > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > > > > >
> > > > > > > > Hello Bart / Forum members,
> > > > > > > >
> > > > > > > > Thank you for your guidance to understant the UP/Continuous mode.
> > > > > > > >
> > > > > > > > I am now able to generate the PWM in continuous mode and can vary the PWM
duty cycle from 0% to 100%. Here I have observed that the PWM duty cycle deviates to 100%
at lower values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone have
solution for the same? This happens at some regular interval. This interval instance could
be the TBR overflow, but I am not sure. Does anyone has similar observation? Please
provide me solution for this.
> > > > > > > >
> > > > > > > > Thanks in advance.
> > > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > >
> > > > > > > > > To basically repeat my question from earlier, what happens in each of
> > > > > > > > > the timer modes? Back off from trying to create a PWM output for the
> > > > > > > > > moment, and think about how the module functions.
> > > > > > > > >
> > > > > > > > > To give you part of the solution to get you started a bit further in
> > > > > > > > > the direction I'm thinking, in UP mode the timer counts up to the
> > > > > > > > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > > > > > > > counting up again.
> > > > > > > > >
> > > > > > > > > What happens (and what are you depending on in your timeout routines)
> > > > > > > > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > > > > > > > expected, what is happening? When the timeouts are working in
> > > > > > > > > continuous mode, what is happening?
> > > > > > > > >
> > > > > > > > > - Bart
> > > > > > > > >
> > > > > > > > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Hello Bart,
> > > > > > > > > >
> > > > > > > > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I
was
> > > > > > > > > > unable to find why the continuous mode is not generating the PWM. The
PWM
> > > > > > > > > > generation is possible in continuos mode even. Please let me know
what
> > > > > > > > > > exactly is going wrong with my code.
> > > > > > > > > >
> > > > > > > > > > Thanks in advance.
> > > > > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > > >>
> > > > > > > > > >> You'll find it in the MSP430x2xx Family User Guide, specifically
chapter
> > > > > > > > > >> 12.
> > > > > > > > > >>
> > > > > > > > > >> http://www.ti.com/litv/pdf/slau144e
> > > > > > > > > >>
> > > > > > > > > >> - Bart
> > > > > > > > > >>
> > > > > > > > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > > > > > > > >> >
> > > > > > > > > >> >
> > > > > > > > > >> > Thanks Bart for your reply.!! I tried to look for the different
mode
> > > > > > > > > >> > configurations but alas.
> > > > > > > > > >> >
> > > > > > > > > >> > Does anyone have solution for this? I really need the same very
much as
> > > > > > > > > >> > project work is held up. I request all forum members for the
same.
> > > > > > > > > >> > Thanks in
> > > > > > > > > >> > advance.
> > > > > > > > > >> >
> > > > > > > > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > > >> >>
> > > > > > > > > >> >> Read and think about what is happening in the different timer
modes
> > > > > > > > > >> >> (up and continuous, in this case). What happens in UP mode when
the
> > > > > > > > > >> >> timer register counts to the value specified in TBCCR0? What
happens
> > > > > > > > > >> >> in continuous mode when the same happens?
> > > > > > > > > >> >>
> > > > > > > > > >> >> - Bart
> > > > > > > > > >> >>
> > > > > > > > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > > > > > > > >> >> >
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > Hello Friends/Members,
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > I am using MSP430F2418 device and want to generate the PWM on
pin TB5
> > > > > > > > > >> >> > using
> > > > > > > > > >> >> > continuous mode of TimerB. I am using this timer - module 4
and
> > > > > > > > > >> >> > module 6
> > > > > > > > > >> >> > -
> > > > > > > > > >> >> > for two different timeout values. I want to generate a PWM of
50%
> > > > > > > > > >> >> > duty
> > > > > > > > > >> >> > cycle
> > > > > > > > > >> >> > and a period of 150Hz using module 5 which in turn will output a
PWM
> > > > > > > > > >> >> > on
> > > > > > > > > >> >> > TB5.
> > > > > > > > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to
configure
> > > > > > > > > >> >> > TimerB
> > > > > > > > > >> >> > and corresponding modules:
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > void Init_TimerB (void)
> > > > > > > > > >> >> > {
> > > > > > > > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear
TimerB /
> > > > > > > > > >> >> > Stop
> > > > > > > > > >> >> > TimerB
> > > > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2
/
> > > > > > > > > >> >> > Stop
> > > > > > > > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK /
Divide by
> > > > > > > > > >> >> > 2
> > > > > > > > > >> >> > /
> > > > > > > > > >> >> > Continuous
> > > > > > > > > >> >> > }
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > > > > > > > >> >> > {
> > > > > > > > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > > > > > > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE |
OUT);
> > > > > > > > > >> >> > TBCCR4 = (TBR + tout);
> > > > > > > > > >> >> > }
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > > > > > > > >> >> > {
> > > > > > > > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > > > > > > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > > > >> >> > //OUTMOD_4 = Toggle TB6
> > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > > > > > > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE |
OUT);
> > > > > > > > > >> >> > TBCCR6 = (TBR + tout);
> > > > > > > > > >> >> > }
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > void ConfigTimerB5_PWM (void)
> > > > > > > > > >> >> > {
> > > > > > > > > >> >> > P4SEL &= ~0xA0;
> > > > > > > > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > > > > > > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > TBCCR0 = 0;
> > > > > > > > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > > > > > > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is written
> > > > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE |
OUT);
> > > > > > > > > >> >> > TBCCR5 = (1660);
> > > > > > > > > >> >> > }
> > > > > > > > > >> >> >
> > > > > > > > > >> >> > I am not sure of module 5 configuration. Please guide me to get
the
> > > > > > > > > >> >> > PWM
> > > > > > > > > >> >> > in
> > > > > > > > > >> >> > continuous mode. If I use UP mode for timer, then I am able
to
> > > > > > > > > >> >> > generate
> > > > > > > > > >> >> > the
> > > > > > > > > >> >> > PWM properly but failing to get required timeouts. Is it
possible to
> > > > > > > > > >> >> > use
> > > > > > > > > >> >> > timer either in Up or Continuous mode to generate both PWM as
well as
> > > > > > > > > >> >> > timeouts? Please help me for this. Your earliest help in this
regard
> > > > > > > > > >> >> > will be
> > > > > > > > > >> >> > highly appreciated. Thanks in advance.
> > > > > > > > > >> >> >
> > > > > > > > > >> >> >
> > > > > > > > > >> >>
> > > > > > > > > >> >
> > > > > > > > > >> >
> > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Sep 26 2:03:38 2009
Below is the code for this PWM,
Timer Initialisation -
void Init_TimerB (void)
{
TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB / Stop
TimerB
TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 / Stop
TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by 2 /
Continuous
}
PWM initialisation -
void ConfigTimerB5_PWM (void)
{
P4SEL &= ~0xA0;
P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
P4DIR |= 0x20; // P4.5 - Select compare as output
TBCCTL5 &= ~CCIE; //Disable interrupt
TBCCTL5 &= ~CAP; //Compare mode
//CM_0 = No Capture
//CCIS_1 = Capture/Compare input is TB4
//SCS = Synchronous capture
//CLLD_0 = Load compare latch (TBCLx) when
TBCCRx is written
//OUTMOD_3 = Set/Reset
//CCIE = Enable interrupt
//OUT = Output high on pin
TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
TBCCR5 = DACOUT; //PWM Duty cycle
}
The ISR for TimerB -
void ISR_TimerB (void) INTERRUPT[TIMERB1_VECTOR]
{
switch (TBIV)
{
case TBIV_TBCCR1:
break;
case TBIV_TBCCR5:
TBCCTL5 &= ~CCIFG; //Clear interrupt flag
// TBCCR5 += DACOUT;
TBCCR0 = (TBCCR5 + DACOUT);
if (DACOUT < 150)
{
if (TBCCR5 > TBCCR0)
{
TBCCR5 += (PWM_Period - (TBCCR0+1));
}
else
{
TBCCR5 += PWM_Period;
}
}
else
{
TBCCR5 += PWM_Period;
}
break;
case TBIV_TBCCR4:
break;
case TBIV_TBCCR6:
break;
}
}
I have tried to implement the guidelines from Michael but still the PWM is missing at the
lower values. May be my implementation is different than what Michael suggested, so there
could be a mistake. Please guide me to correct the mistake for this code.
Thanks in advance.
--- In m...@yahoogroups.com, Bart Oegema
wrote:
>
> What have you tried from what Michael suggested? We don't have any
> idea what you've tried or what your code looks like at this point, so
> we couldn't help you if we wanted to.
>
> - Bart
>
> On Thu, Sep 24, 2009 at 11:20 PM, ti2tt wrote:
> >
> >
> >
> > Hello Forum members,
> >
> > Has anyone experienced similar issues with PWM? Please share your views. I am in
desperate need for the solution. Request you all for the help.
> >
> > Thanks in advance.
> > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > >
> > > Hello Michael,
> > >
> > > Thanks for your kind help. I am still to get the classic mistake cleared. I hope you
will be kind enough to give me the right solution. Your earliest help will be highly
appreciated. Thanks in advance.
> > > --- In m...@yahoogroups.com, "Michael" wrote:
> > > >
> > > > At this point you really should have enought data to arrive at the right
conclusion and be able to solve your problem. But to not be cruel and spare you the
suffering (althought Onestone may say the contrary ;-) ):
> > > >
> > > > Your problem is that by changing TACCRx to a lower value than the present count of
TAR, you are missing that periods EQUx event, thus only after TAR rolles over will the
EQUx event (TACCRx = TAR) occur and change the pin state. Remember the Compare Module only
looks for the event in which TACCRx is equal to TAR, setting the EQUx internal signal,
which in turn affects the OUTPUTx unit. EQUx sets only while TACCRx = TAR, not while
TACCRx >= TAR. Understanding this is the center of your issue.
> > > >
> > > > It will be helpful for you to read the timerB chapter. Timer B has additional
options to solve this problem on the hardware level, automatically choosing when to load
the real (and hidden) compare register TBCLx with the value in TBCCRx.
> > > >
> > > > Short answer, you need to check if TAR is still lower than the new value of TACCRx
you want to write:
> > > > while (value > (TAR-20) // Check if new value is too close or past TAR.
> > > > ; //Wait until TAR rolles over
> > > > TACCR = value;
> > > >
> > > > Better yet, don't change TACCRx directly. Instead use a global variable, for
example PERIOD, and use TACCRx interrupt to write that value into TACCRx. As long as you
aren't using a bit toggle mode, but reset/set or set/reset, all should work fine.
> > > >
> > > > __interrupt void TimerA1 (void)
> > > > {
> > > > switch (TAIV)
> > > > {
> > > > case TACC_x:
> > > > TACCRx = Period;
> > > > break;
> > > > }
> > > > }
> > > >
> > > > I hope I was not too condescending in giving you the answer instead of leading you
to it as I first intended and tried.
> > > >
> > > > Best Regards,
> > > > Michael
> > > >
> > > >
> > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > >
> > > > > I think you're still missing it. You're both lengthening and
> > > > > shortening the duty cycle in your application, but this only happens
> > > > > when you're making the duty cycle shorter. Look closely at Michael's
> > > > > example and hint.
> > > > >
> > > > > - Bart
> > > > >
> > > > > On Wed, Sep 16, 2009 at 12:28 AM, ti2tt wrote:
> > > > > >
> > > > > >
> > > > > >
> > > > > > Hello Michael,
> > > > > >
> > > > > > With ref to your example, the ON or OFF time will change and in turn the duty
cycle of PWM will change. But how to avoid it? What could be the remedy for classic
mistake?
> > > > > >
> > > > > > Thanks in advance.
> > > > > >
> > > > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > > > >
> > > > > > > Hello,
> > > > > > >
> > > > > > > Thanks Michael.
> > > > > > >
> > > > > > > I am trying to locate the "Classic mistake". What is the way out to avoid
this mistake? Your example clears the point where the mistake is occurring.
> > > > > > >
> > > > > > > Thanks in advance.
> > > > > > > --- In m...@yahoogroups.com, "tintronic" wrote:
> > > > > > > >
> > > > > > > > Let me guess, it only happens when you are lowering the DC but not when
you're increasing it? Classic mistake, think about it.
> > > > > > > >
> > > > > > > > Hint: What happens when TAR is nearing TACCRx and you write a new value to
TACCRx that is lower than the actual count of TAR.
> > > > > > > >
> > > > > > > > TACCRx is 1000 and TAR is 900.
> > > > > > > > You write TACCRx = 800.
> > > > > > > > What happens next?
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Michael K.
> > > > > > > >
> > > > > > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > > > > > >
> > > > > > > > > Hello Bart / Forum members,
> > > > > > > > >
> > > > > > > > > Thank you for your guidance to understant the UP/Continuous mode.
> > > > > > > > >
> > > > > > > > > I am now able to generate the PWM in continuous mode and can vary the
PWM duty cycle from 0% to 100%. Here I have observed that the PWM duty cycle deviates to
100% at lower values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone
have solution for the same? This happens at some regular interval. This interval instance
could be the TBR overflow, but I am not sure. Does anyone has similar observation? Please
provide me solution for this.
> > > > > > > > >
> > > > > > > > > Thanks in advance.
> > > > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > > >
> > > > > > > > > > To basically repeat my question from earlier, what happens in each
of
> > > > > > > > > > the timer modes? Back off from trying to create a PWM output for
the
> > > > > > > > > > moment, and think about how the module functions.
> > > > > > > > > >
> > > > > > > > > > To give you part of the solution to get you started a bit further
in
> > > > > > > > > > the direction I'm thinking, in UP mode the timer counts up to the
> > > > > > > > > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > > > > > > > > counting up again.
> > > > > > > > > >
> > > > > > > > > > What happens (and what are you depending on in your timeout
routines)
> > > > > > > > > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > > > > > > > > expected, what is happening? When the timeouts are working in
> > > > > > > > > > continuous mode, what is happening?
> > > > > > > > > >
> > > > > > > > > > - Bart
> > > > > > > > > >
> > > > > > > > > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Hello Bart,
> > > > > > > > > > >
> > > > > > > > > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I
was
> > > > > > > > > > > unable to find why the continuous mode is not generating the PWM.
The PWM
> > > > > > > > > > > generation is possible in continuos mode even. Please let me know
what
> > > > > > > > > > > exactly is going wrong with my code.
> > > > > > > > > > >
> > > > > > > > > > > Thanks in advance.
> > > > > > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > > > >>
> > > > > > > > > > >> You'll find it in the MSP430x2xx Family User Guide, specifically
chapter
> > > > > > > > > > >> 12.
> > > > > > > > > > >>
> > > > > > > > > > >> http://www.ti.com/litv/pdf/slau144e
> > > > > > > > > > >>
> > > > > > > > > > >> - Bart
> > > > > > > > > > >>
> > > > > > > > > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > > > > > > > > >> >
> > > > > > > > > > >> >
> > > > > > > > > > >> > Thanks Bart for your reply.!! I tried to look for the different
mode
> > > > > > > > > > >> > configurations but alas.
> > > > > > > > > > >> >
> > > > > > > > > > >> > Does anyone have solution for this? I really need the same very
much as
> > > > > > > > > > >> > project work is held up. I request all forum members for the
same.
> > > > > > > > > > >> > Thanks in
> > > > > > > > > > >> > advance.
> > > > > > > > > > >> >
> > > > > > > > > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > > > >> >>
> > > > > > > > > > >> >> Read and think about what is happening in the different timer
modes
> > > > > > > > > > >> >> (up and continuous, in this case). What happens in UP mode when
the
> > > > > > > > > > >> >> timer register counts to the value specified in TBCCR0? What
happens
> > > > > > > > > > >> >> in continuous mode when the same happens?
> > > > > > > > > > >> >>
> > > > > > > > > > >> >> - Bart
> > > > > > > > > > >> >>
> > > > > > > > > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > Hello Friends/Members,
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > I am using MSP430F2418 device and want to generate the PWM on
pin TB5
> > > > > > > > > > >> >> > using
> > > > > > > > > > >> >> > continuous mode of TimerB. I am using this timer - module 4
and
> > > > > > > > > > >> >> > module 6
> > > > > > > > > > >> >> > -
> > > > > > > > > > >> >> > for two different timeout values. I want to generate a PWM of
50%
> > > > > > > > > > >> >> > duty
> > > > > > > > > > >> >> > cycle
> > > > > > > > > > >> >> > and a period of 150Hz using module 5 which in turn will output
a PWM
> > > > > > > > > > >> >> > on
> > > > > > > > > > >> >> > TB5.
> > > > > > > > > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to
configure
> > > > > > > > > > >> >> > TimerB
> > > > > > > > > > >> >> > and corresponding modules:
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > void Init_TimerB (void)
> > > > > > > > > > >> >> > {
> > > > > > > > > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear
TimerB /
> > > > > > > > > > >> >> > Stop
> > > > > > > > > > >> >> > TimerB
> > > > > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by
2 /
> > > > > > > > > > >> >> > Stop
> > > > > > > > > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK /
Divide by
> > > > > > > > > > >> >> > 2
> > > > > > > > > > >> >> > /
> > > > > > > > > > >> >> > Continuous
> > > > > > > > > > >> >> > }
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > > > > > > > > >> >> > {
> > > > > > > > > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > > > > > > > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is
written
> > > > > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > > > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE |
OUT);
> > > > > > > > > > >> >> > TBCCR4 = (TBR + tout);
> > > > > > > > > > >> >> > }
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > > > > > > > > >> >> > {
> > > > > > > > > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > > > > > > > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is
written
> > > > > > > > > > >> >> > //OUTMOD_4 = Toggle TB6
> > > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > > > > > > > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE |
OUT);
> > > > > > > > > > >> >> > TBCCR6 = (TBR + tout);
> > > > > > > > > > >> >> > }
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > void ConfigTimerB5_PWM (void)
> > > > > > > > > > >> >> > {
> > > > > > > > > > >> >> > P4SEL &= ~0xA0;
> > > > > > > > > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > > > > > > > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > TBCCR0 = 0;
> > > > > > > > > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > > > > > > > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is
written
> > > > > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > > > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE |
OUT);
> > > > > > > > > > >> >> > TBCCR5 = (1660);
> > > > > > > > > > >> >> > }
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > I am not sure of module 5 configuration. Please guide me to
get the
> > > > > > > > > > >> >> > PWM
> > > > > > > > > > >> >> > in
> > > > > > > > > > >> >> > continuous mode. If I use UP mode for timer, then I am able
to
> > > > > > > > > > >> >> > generate
> > > > > > > > > > >> >> > the
> > > > > > > > > > >> >> > PWM properly but failing to get required timeouts. Is it
possible to
> > > > > > > > > > >> >> > use
> > > > > > > > > > >> >> > timer either in Up or Continuous mode to generate both PWM as
well as
> > > > > > > > > > >> >> > timeouts? Please help me for this. Your earliest help in this
regard
> > > > > > > > > > >> >> > will be
> > > > > > > > > > >> >> > highly appreciated. Thanks in advance.
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >>
> > > > > > > > > > >> >
> > > > > > > > > > >> >
> > > > > > > > > > >>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Sep 26 2:23:14 2009
Hello Michael,
Sorry to keep pestering you.
Below is my understanding for continous mode of TimerB.
In continuous mode for TimerB to generate the PWM,TBCCR0 and TBCCR5 will come into
picture. TBCCR5 is my code requirement while the TBCCR0 is default. I have selected the
output mode 3 which is set/reset. When TBR=TBCCR5, the EQUx event will set the pin and
when TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both the TBCCR0 and
TBCCR5.
Please clarify if I am wrongly interpreting the continuous mode.
Thanks in advance.
--- In m...@yahoogroups.com, "Michael"
wrote:
>
> I really can't tell you anything more. I think I made it quite clear what your problem
is and how to solve it, even babystep guided you. If you still can't make it work, the
only advice I have left would be a change of career.
>
> Regards,
> Michael K.
>
> --- In m...@yahoogroups.com, "ti2tt" wrote:
> >
> > Hello Forum members,
> >
> > Has anyone experienced similar issues with PWM? Please share your views. I am in
desperate need for the solution. Request you all for the help.
> >
> > Thanks in advance.
> > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > >
> > > Hello Michael,
> > >
> > > Thanks for your kind help. I am still to get the classic mistake cleared. I hope you
will be kind enough to give me the right solution. Your earliest help will be highly
appreciated. Thanks in advance.
> > > --- In m...@yahoogroups.com, "Michael" wrote:
> > > >
> > > > At this point you really should have enought data to arrive at the right
conclusion and be able to solve your problem. But to not be cruel and spare you the
suffering (althought Onestone may say the contrary ;-) ):
> > > >
> > > > Your problem is that by changing TACCRx to a lower value than the present count of
TAR, you are missing that periods EQUx event, thus only after TAR rolles over will the
EQUx event (TACCRx = TAR) occur and change the pin state. Remember the Compare Module only
looks for the event in which TACCRx is equal to TAR, setting the EQUx internal signal,
which in turn affects the OUTPUTx unit. EQUx sets only while TACCRx = TAR, not while
TACCRx >= TAR. Understanding this is the center of your issue.
> > > >
> > > > It will be helpful for you to read the timerB chapter. Timer B has additional
options to solve this problem on the hardware level, automatically choosing when to load
the real (and hidden) compare register TBCLx with the value in TBCCRx.
> > > >
> > > > Short answer, you need to check if TAR is still lower than the new value of TACCRx
you want to write:
> > > > while (value > (TAR-20) // Check if new value is too close or past TAR.
> > > > ; //Wait until TAR rolles over
> > > > TACCR = value;
> > > >
> > > > Better yet, don't change TACCRx directly. Instead use a global variable, for
example PERIOD, and use TACCRx interrupt to write that value into TACCRx. As long as you
aren't using a bit toggle mode, but reset/set or set/reset, all should work fine.
> > > >
> > > > __interrupt void TimerA1 (void)
> > > > {
> > > > switch (TAIV)
> > > > {
> > > > case TACC_x:
> > > > TACCRx = Period;
> > > > break;
> > > > }
> > > > }
> > > >
> > > > I hope I was not too condescending in giving you the answer instead of leading you
to it as I first intended and tried.
> > > >
> > > > Best Regards,
> > > > Michael
> > > >
> > > >
> > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > >
> > > > > I think you're still missing it. You're both lengthening and
> > > > > shortening the duty cycle in your application, but this only happens
> > > > > when you're making the duty cycle shorter. Look closely at Michael's
> > > > > example and hint.
> > > > >
> > > > > - Bart
> > > > >
> > > > > On Wed, Sep 16, 2009 at 12:28 AM, ti2tt wrote:
> > > > > >
> > > > > >
> > > > > >
> > > > > > Hello Michael,
> > > > > >
> > > > > > With ref to your example, the ON or OFF time will change and in turn the duty
cycle of PWM will change. But how to avoid it? What could be the remedy for classic
mistake?
> > > > > >
> > > > > > Thanks in advance.
> > > > > >
> > > > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > > > >
> > > > > > > Hello,
> > > > > > >
> > > > > > > Thanks Michael.
> > > > > > >
> > > > > > > I am trying to locate the "Classic mistake". What is the way out to avoid
this mistake? Your example clears the point where the mistake is occurring.
> > > > > > >
> > > > > > > Thanks in advance.
> > > > > > > --- In m...@yahoogroups.com, "tintronic" wrote:
> > > > > > > >
> > > > > > > > Let me guess, it only happens when you are lowering the DC but not when
you're increasing it? Classic mistake, think about it.
> > > > > > > >
> > > > > > > > Hint: What happens when TAR is nearing TACCRx and you write a new value to
TACCRx that is lower than the actual count of TAR.
> > > > > > > >
> > > > > > > > TACCRx is 1000 and TAR is 900.
> > > > > > > > You write TACCRx = 800.
> > > > > > > > What happens next?
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Michael K.
> > > > > > > >
> > > > > > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > > > > > >
> > > > > > > > > Hello Bart / Forum members,
> > > > > > > > >
> > > > > > > > > Thank you for your guidance to understant the UP/Continuous mode.
> > > > > > > > >
> > > > > > > > > I am now able to generate the PWM in continuous mode and can vary the
PWM duty cycle from 0% to 100%. Here I have observed that the PWM duty cycle deviates to
100% at lower values i.e. at 0 to 10%. Does anyone have observed the same? Does anyone
have solution for the same? This happens at some regular interval. This interval instance
could be the TBR overflow, but I am not sure. Does anyone has similar observation? Please
provide me solution for this.
> > > > > > > > >
> > > > > > > > > Thanks in advance.
> > > > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > > >
> > > > > > > > > > To basically repeat my question from earlier, what happens in each
of
> > > > > > > > > > the timer modes? Back off from trying to create a PWM output for
the
> > > > > > > > > > moment, and think about how the module functions.
> > > > > > > > > >
> > > > > > > > > > To give you part of the solution to get you started a bit further
in
> > > > > > > > > > the direction I'm thinking, in UP mode the timer counts up to the
> > > > > > > > > > value set in TBCCTL0, after which it rolls over to zero and starts
> > > > > > > > > > counting up again.
> > > > > > > > > >
> > > > > > > > > > What happens (and what are you depending on in your timeout
routines)
> > > > > > > > > > in continuous mode? When you're producing PWM outputs in UP mode as
> > > > > > > > > > expected, what is happening? When the timeouts are working in
> > > > > > > > > > continuous mode, what is happening?
> > > > > > > > > >
> > > > > > > > > > - Bart
> > > > > > > > > >
> > > > > > > > > > On Sun, Sep 6, 2009 at 10:25 PM, ti2tt wrote:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Hello Bart,
> > > > > > > > > > >
> > > > > > > > > > > I read this chapter 13 for TimerB (chapter 12 is for Timer A), but I
was
> > > > > > > > > > > unable to find why the continuous mode is not generating the PWM.
The PWM
> > > > > > > > > > > generation is possible in continuos mode even. Please let me know
what
> > > > > > > > > > > exactly is going wrong with my code.
> > > > > > > > > > >
> > > > > > > > > > > Thanks in advance.
> > > > > > > > > > > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > > > >>
> > > > > > > > > > >> You'll find it in the MSP430x2xx Family User Guide, specifically
chapter
> > > > > > > > > > >> 12.
> > > > > > > > > > >>
> > > > > > > > > > >> http://www.ti.com/litv/pdf/slau144e
> > > > > > > > > > >>
> > > > > > > > > > >> - Bart
> > > > > > > > > > >>
> > > > > > > > > > >> On Fri, Sep 4, 2009 at 11:34 PM, ti2tt wrote:
> > > > > > > > > > >> >
> > > > > > > > > > >> >
> > > > > > > > > > >> > Thanks Bart for your reply.!! I tried to look for the different
mode
> > > > > > > > > > >> > configurations but alas.
> > > > > > > > > > >> >
> > > > > > > > > > >> > Does anyone have solution for this? I really need the same very
much as
> > > > > > > > > > >> > project work is held up. I request all forum members for the
same.
> > > > > > > > > > >> > Thanks in
> > > > > > > > > > >> > advance.
> > > > > > > > > > >> >
> > > > > > > > > > >> > --- In m...@yahoogroups.com, Bart Oegema wrote:
> > > > > > > > > > >> >>
> > > > > > > > > > >> >> Read and think about what is happening in the different timer
modes
> > > > > > > > > > >> >> (up and continuous, in this case). What happens in UP mode when
the
> > > > > > > > > > >> >> timer register counts to the value specified in TBCCR0? What
happens
> > > > > > > > > > >> >> in continuous mode when the same happens?
> > > > > > > > > > >> >>
> > > > > > > > > > >> >> - Bart
> > > > > > > > > > >> >>
> > > > > > > > > > >> >> On Wed, Sep 2, 2009 at 7:57 AM, ti2tt wrote:
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > Hello Friends/Members,
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > I am using MSP430F2418 device and want to generate the PWM on
pin TB5
> > > > > > > > > > >> >> > using
> > > > > > > > > > >> >> > continuous mode of TimerB. I am using this timer - module 4
and
> > > > > > > > > > >> >> > module 6
> > > > > > > > > > >> >> > -
> > > > > > > > > > >> >> > for two different timeout values. I want to generate a PWM of
50%
> > > > > > > > > > >> >> > duty
> > > > > > > > > > >> >> > cycle
> > > > > > > > > > >> >> > and a period of 150Hz using module 5 which in turn will output
a PWM
> > > > > > > > > > >> >> > on
> > > > > > > > > > >> >> > TB5.
> > > > > > > > > > >> >> > I am using ACLK=1MHz. Below is the code, I have written to
configure
> > > > > > > > > > >> >> > TimerB
> > > > > > > > > > >> >> > and corresponding modules:
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > void Init_TimerB (void)
> > > > > > > > > > >> >> > {
> > > > > > > > > > >> >> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear
TimerB /
> > > > > > > > > > >> >> > Stop
> > > > > > > > > > >> >> > TimerB
> > > > > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by
2 /
> > > > > > > > > > >> >> > Stop
> > > > > > > > > > >> >> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK /
Divide by
> > > > > > > > > > >> >> > 2
> > > > > > > > > > >> >> > /
> > > > > > > > > > >> >> > Continuous
> > > > > > > > > > >> >> > }
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > void ConfigTimerB4_Timeout (UINT tout)
> > > > > > > > > > >> >> > {
> > > > > > > > > > >> >> > TBCCTL4 &= ~CCIE; //Disable interrupt
> > > > > > > > > > >> >> > TBCCTL4 &= ~CAP; //Compare mode
> > > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is
written
> > > > > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > > > > >> >> > TBCCTL4 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_0 | CCIE |
OUT);
> > > > > > > > > > >> >> > TBCCR4 = (TBR + tout);
> > > > > > > > > > >> >> > }
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > void ConfigTimerB6_Timeout (UINT tout)
> > > > > > > > > > >> >> > {
> > > > > > > > > > >> >> > TBCCTL6 &= ~CCIE; //Disable interrupt
> > > > > > > > > > >> >> > TBCCTL6 &= ~CAP; //Compare mode
> > > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB6
> > > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is
written
> > > > > > > > > > >> >> > //OUTMOD_4 = Toggle TB6
> > > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > > >> >> > //OUT = Output high on pin if OUTMOD_0
> > > > > > > > > > >> >> > TBCCTL6 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_4 | CCIE |
OUT);
> > > > > > > > > > >> >> > TBCCR6 = (TBR + tout);
> > > > > > > > > > >> >> > }
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > void ConfigTimerB5_PWM (void)
> > > > > > > > > > >> >> > {
> > > > > > > > > > >> >> > P4SEL &= ~0xA0;
> > > > > > > > > > >> >> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > > > > > > > > >> >> > P4DIR |= 0x20; // P4.5 - Select compare as output
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > TBCCR0 = 0;
> > > > > > > > > > >> >> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > > > > > > > > >> >> > TBCCTL5 &= ~CAP; //Compare mode
> > > > > > > > > > >> >> > //CM_0 = No Capture
> > > > > > > > > > >> >> > //CCIS_1 = Capture/Compare input is TB4
> > > > > > > > > > >> >> > //SCS = Synchronous capture
> > > > > > > > > > >> >> > //CLLD_0 = Load compare latch (TBCLx) when TBCCRx is
written
> > > > > > > > > > >> >> > //OUTMOD_0 = output value of OUT on pin
> > > > > > > > > > >> >> > //CCIE = Enable interrupt
> > > > > > > > > > >> >> > //OUT = Output high on pin
> > > > > > > > > > >> >> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE |
OUT);
> > > > > > > > > > >> >> > TBCCR5 = (1660);
> > > > > > > > > > >> >> > }
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> > I am not sure of module 5 configuration. Please guide me to
get the
> > > > > > > > > > >> >> > PWM
> > > > > > > > > > >> >> > in
> > > > > > > > > > >> >> > continuous mode. If I use UP mode for timer, then I am able
to
> > > > > > > > > > >> >> > generate
> > > > > > > > > > >> >> > the
> > > > > > > > > > >> >> > PWM properly but failing to get required timeouts. Is it
possible to
> > > > > > > > > > >> >> > use
> > > > > > > > > > >> >> > timer either in Up or Continuous mode to generate both PWM as
well as
> > > > > > > > > > >> >> > timeouts? Please help me for this. Your earliest help in this
regard
> > > > > > > > > > >> >> > will be
> > > > > > > > > > >> >> > highly appreciated. Thanks in advance.
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >> >
> > > > > > > > > > >> >>
> > > > > > > > > > >> >
> > > > > > > > > > >> >
> > > > > > > > > > >>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - Michael - Sep 28 12:11:58 2009
> When TBR=TBCCR5, the EQUx event will set the pin and when
> TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both
> the TBCCR0 and TBCCR5.
Yes... almost. Only EQUx doesn't use TBCCRx but TBCLx, which is an internal (invisible)
register. You can control when TBCLx is automatically loaded with the value in TBCCRx by
means of the CLLDx bits in TBCCTLx register. Any mode but CLLD_0 will solve your problem
and you won't have missed EQUx events, so no jumps to DC=100% when changing to a lower
DC.
Michael K.
--- In m...@yahoogroups.com, "ti2tt"
wrote:
>
> Hello Michael,
>
> Sorry to keep pestering you.
>
> Below is my understanding for continous mode of TimerB.
>
> In continuous mode for TimerB to generate the PWM,TBCCR0 and TBCCR5
> will come into picture. TBCCR5 is my code requirement while the
> TBCCR0 is default. I have selected the output mode 3 which is
> set/reset. When TBR=TBCCR5, the EQUx event will set the pin and when
> TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both
> the TBCCR0 and TBCCR5.
>
> Please clarify if I am wrongly interpreting the continuous mode.
>
> Thanks in advance.
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - ti2tt - Nov 9 10:35:46 2009
Hello All and a special hello to Michael,
Sorry to keep pestering you, Michael.
I am still unable to resolve the PWM issue and seriously thinking of changing career as
Michael advised. Sincerely speaking, I tried very much to analyse the timer behaviour but
to my tough luck I could not figure out the classic mistake. I tried to capture the timer
counts, both theoretically and practically, at different stages of execution to analyse. I
also tried different register settings for TimerB. Please help me out to resolve the
issue. I am including the functions here again. Some constants in code - PWM_Period =
3334; ACLK=1MHz; DACOUT=any value less than 3334;
void Init_TimerB (void)
{
TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB / Stop
TimerB
TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 / Stop
TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by 2 /
Continuous
}
void ConfigTimerB5_PWM (void)
{
P4SEL &= ~0xA0;
P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
P4DIR |= 0x20; // P4.5 - Select compare as output
TBCCTL5 &= ~CCIE; //Disable interrupt
TBCCTL5 &= ~CAP; //Compare mode
//CM_0 = No Capture
//CCIS_1 = Capture/Compare input is TB4
//SCS = Synchronous capture
//CLLD_0 = Load compare latch (TBCLx) when
TBCCRx is written
//OUTMOD_3 = Set/Reset
//CCIE = Enable interrupt
//OUT = Output high on pin
TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
TBCCR5 = DACOUT; //PWM Duty cycle
}
Timer ISR -
void ISR_TimerB (void) INTERRUPT[TIMERB1_VECTOR]
{
switch (TBIV)
{
case TBIV_TBCCR1:
break;
case TBIV_TBCCR5: // CCR5 int=10
TBCCTL5 &= ~CCIFG; //Clear interrupt flag
TBCCR0 = (TBCCR5 + DACOUT);
TBCCR5 += PWM_Period; //PWM_Period=3334
break;
}
}
Please help me to figure out the implementation. Thanks in advance.
--- In m...@yahoogroups.com, "Michael"
wrote:
>
> > When TBR=TBCCR5, the EQUx event will set the pin and when
> > TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both
> > the TBCCR0 and TBCCR5.
>
> Yes... almost. Only EQUx doesn't use TBCCRx but TBCLx, which is an internal (invisible)
register. You can control when TBCLx is automatically loaded with the value in TBCCRx by
means of the CLLDx bits in TBCCTLx register. Any mode but CLLD_0 will solve your problem
and you won't have missed EQUx events, so no jumps to DC=100% when changing to a lower
DC.
>
> Michael K.
>
> --- In m...@yahoogroups.com, "ti2tt" wrote:
> >
> > Hello Michael,
> >
> > Sorry to keep pestering you.
> >
> > Below is my understanding for continous mode of TimerB.
> >
> > In continuous mode for TimerB to generate the PWM,TBCCR0 and TBCCR5
> > will come into picture. TBCCR5 is my code requirement while the
> > TBCCR0 is default. I have selected the output mode 3 which is
> > set/reset. When TBR=TBCCR5, the EQUx event will set the pin and when
> > TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both
> > the TBCCR0 and TBCCR5.
> >
> > Please clarify if I am wrongly interpreting the continuous mode.
> >
> > Thanks in advance.
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - Michael - Nov 9 11:05:26 2009
You changed from timer A to timer B but are not using the feature of timer B that solves
your problem. My guess is you haven't taken the time to read THE ENTIRE CHAPTER of timer
B, from top to bottom without skipping anything, no matter if you already readed it or if
you don't understand it at first.
Basically, you're using CLLD_0 which is the same as using timer A, disregarding the
ability of choosing when TBCLx will be loaded with the value in TBCCRx. Use CLLD_1 and
your problems will disappear.
By the way, there are a lot of things that don't make much sense in
your code (comments stripped):
Number 1)
> void Init_TimerB (void)
> {
> TBCTL = (TBCLR | MC_0);
> TBCTL = (CNTL_0 | TBSSEL_1 | ID_1);
> TBCTL &= ~(TBIE | TBIFG);
> TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2)
> }
You're changing the TBCTL register 4 times in a row!! What's that about?
Number 2)
> TBCCTL5 &= ~CCIE;
> TBCCTL5 &= ~CAP;
> TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
With the third instruction you're disregarding what you did with the first two. The first
two are useless unless you use |= instad of = on the third instruction. Do you understand
the difference between the operand |=, &= and = ?
Number 3)
> switch (TBIV)
> {
> case TBIV_TBCCR1:
> break;
> case TBIV_TBCCR5:
> TBCCTL5 &= ~CCIFG;
> TBCCR0 = (TBCCR5 + DACOUT);
> TBCCR5 += PWM_Period;
> break;
> }
TBCCTL5 &= ~CCIFG is superfluous, since by reading TBIV (by the switch instruction) and
entering TBIV_TBCCR5 this flag is automatically cleared.
Really, STOP programming and RTFM. Then read it again and take notes. Then read it again
along with your notes.
Michael K.
--- In m...@yahoogroups.com, "ti2tt"
wrote:
>
> Hello All and a special hello to Michael,
>
> Sorry to keep pestering you, Michael.
>
> I am still unable to resolve the PWM issue and seriously thinking of changing career as
Michael advised. Sincerely speaking, I tried very much to analyse the timer behaviour but
to my tough luck I could not figure out the classic mistake. I tried to capture the timer
counts, both theoretically and practically, at different stages of execution to analyse. I
also tried different register settings for TimerB. Please help me out to resolve the
issue. I am including the functions here again. Some constants in code - PWM_Period =
3334; ACLK=1MHz; DACOUT=any value less than 3334;
>
> void Init_TimerB (void)
> {
> TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB /
Stop TimerB
> TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 / Stop
> TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
>
> TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by 2 /
Continuous
> }
>
> void ConfigTimerB5_PWM (void)
> {
> P4SEL &= ~0xA0;
> P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> P4DIR |= 0x20; // P4.5 - Select compare as output
>
> TBCCTL5 &= ~CCIE; //Disable interrupt
> TBCCTL5 &= ~CAP; //Compare mode
> //CM_0 = No Capture
> //CCIS_1 = Capture/Compare input is TB4
> //SCS = Synchronous capture
> //CLLD_0 = Load compare latch (TBCLx) when
TBCCRx is written
> //OUTMOD_3 = Set/Reset
> //CCIE = Enable interrupt
> //OUT = Output high on pin
> TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> TBCCR5 = DACOUT; //PWM Duty cycle
> }
>
> Timer ISR -
> void ISR_TimerB (void) INTERRUPT[TIMERB1_VECTOR]
> {
> switch (TBIV)
> {
> case TBIV_TBCCR1:
> break;
> case TBIV_TBCCR5: // CCR5 int=10
> TBCCTL5 &= ~CCIFG; //Clear interrupt flag
> TBCCR0 = (TBCCR5 + DACOUT);
> TBCCR5 += PWM_Period; //PWM_Period=3334
> break;
> }
> }
>
> Please help me to figure out the implementation. Thanks in advance.
>
> --- In m...@yahoogroups.com, "Michael" wrote:
> >
> > > When TBR=TBCCR5, the EQUx event will set the pin and when
> > > TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both
> > > the TBCCR0 and TBCCR5.
> >
> > Yes... almost. Only EQUx doesn't use TBCCRx but TBCLx, which is an internal
(invisible) register. You can control when TBCLx is automatically loaded with the value in
TBCCRx by means of the CLLDx bits in TBCCTLx register. Any mode but CLLD_0 will solve your
problem and you won't have missed EQUx events, so no jumps to DC=100% when changing to a
lower DC.
> >
> > Michael K.
> >
> > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > >
> > > Hello Michael,
> > >
> > > Sorry to keep pestering you.
> > >
> > > Below is my understanding for continous mode of TimerB.
> > >
> > > In continuous mode for TimerB to generate the PWM,TBCCR0 and TBCCR5
> > > will come into picture. TBCCR5 is my code requirement while the
> > > TBCCR0 is default. I have selected the output mode 3 which is
> > > set/reset. When TBR=TBCCR5, the EQUx event will set the pin and when
> > > TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both
> > > the TBCCR0 and TBCCR5.
> > >
> > > Please clarify if I am wrongly interpreting the continuous mode.
> > >
> > > Thanks in advance.
>
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - old_cow_yellow - Nov 9 11:18:13 2009
Michael,
You have to give credit to ti2tt. He did write his own code and did not rely on video or
"sample code".
-- OCY
--- In m...@yahoogroups.com, "Michael"
wrote:
>
> You changed from timer A to timer B but are not using the feature of timer B that solves
your problem. My guess is you haven't taken the time to read THE ENTIRE CHAPTER of timer
B, from top to bottom without skipping anything, no matter if you already readed it or if
you don't understand it at first.
> Basically, you're using CLLD_0 which is the same as using timer A, disregarding the
ability of choosing when TBCLx will be loaded with the value in TBCCRx. Use CLLD_1 and
your problems will disappear.
>
> By the way, there are a lot of things that don't make much sense in
> your code (comments stripped):
>
> Number 1)
> > void Init_TimerB (void)
> > {
> > TBCTL = (TBCLR | MC_0);
> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1);
> > TBCTL &= ~(TBIE | TBIFG);
> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2)
> > }
> You're changing the TBCTL register 4 times in a row!! What's that about?
>
> Number 2)
> > TBCCTL5 &= ~CCIE;
> > TBCCTL5 &= ~CAP;
> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> With the third instruction you're disregarding what you did with the first two. The
first two are useless unless you use |= instad of = on the third instruction. Do you
understand the difference between the operand |=, &= and = ?
>
> Number 3)
> > switch (TBIV)
> > {
> > case TBIV_TBCCR1:
> > break;
> > case TBIV_TBCCR5:
> > TBCCTL5 &= ~CCIFG;
> > TBCCR0 = (TBCCR5 + DACOUT);
> > TBCCR5 += PWM_Period;
> > break;
> > }
>
> TBCCTL5 &= ~CCIFG is superfluous, since by reading TBIV (by the switch instruction) and
entering TBIV_TBCCR5 this flag is automatically cleared.
>
> Really, STOP programming and RTFM. Then read it again and take notes. Then read it again
along with your notes.
>
> Michael K.
>
> --- In m...@yahoogroups.com, "ti2tt" wrote:
> >
> > Hello All and a special hello to Michael,
> >
> > Sorry to keep pestering you, Michael.
> >
> > I am still unable to resolve the PWM issue and seriously thinking of changing career
as Michael advised. Sincerely speaking, I tried very much to analyse the timer behaviour
but to my tough luck I could not figure out the classic mistake. I tried to capture the
timer counts, both theoretically and practically, at different stages of execution to
analyse. I also tried different register settings for TimerB. Please help me out to
resolve the issue. I am including the functions here again. Some constants in code -
PWM_Period = 3334; ACLK=1MHz; DACOUT=any value less than 3334;
> >
> > void Init_TimerB (void)
> > {
> > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB /
Stop TimerB
> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 / Stop
> > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> >
> > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by 2 /
Continuous
> > }
> >
> > void ConfigTimerB5_PWM (void)
> > {
> > P4SEL &= ~0xA0;
> > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > P4DIR |= 0x20; // P4.5 - Select compare as output
> >
> > TBCCTL5 &= ~CCIE; //Disable interrupt
> > TBCCTL5 &= ~CAP; //Compare mode
> > //CM_0 = No Capture
> > //CCIS_1 = Capture/Compare input is TB4
> > //SCS = Synchronous capture
> > //CLLD_0 = Load compare latch (TBCLx) when
TBCCRx is written
> > //OUTMOD_3 = Set/Reset
> > //CCIE = Enable interrupt
> > //OUT = Output high on pin
> > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > TBCCR5 = DACOUT; //PWM Duty cycle
> > }
> >
> > Timer ISR -
> > void ISR_TimerB (void) INTERRUPT[TIMERB1_VECTOR]
> > {
> > switch (TBIV)
> > {
> > case TBIV_TBCCR1:
> > break;
> > case TBIV_TBCCR5: // CCR5 int=10
> > TBCCTL5 &= ~CCIFG; //Clear interrupt flag
> > TBCCR0 = (TBCCR5 + DACOUT);
> > TBCCR5 += PWM_Period; //PWM_Period=3334
> > break;
> > }
> > }
> >
> > Please help me to figure out the implementation. Thanks in advance.
> >
> > --- In m...@yahoogroups.com, "Michael" wrote:
> > >
> > > > When TBR=TBCCR5, the EQUx event will set the pin and when
> > > > TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both
> > > > the TBCCR0 and TBCCR5.
> > >
> > > Yes... almost. Only EQUx doesn't use TBCCRx but TBCLx, which is an internal
(invisible) register. You can control when TBCLx is automatically loaded with the value in
TBCCRx by means of the CLLDx bits in TBCCTLx register. Any mode but CLLD_0 will solve your
problem and you won't have missed EQUx events, so no jumps to DC=100% when changing to a
lower DC.
> > >
> > > Michael K.
> > >
> > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > >
> > > > Hello Michael,
> > > >
> > > > Sorry to keep pestering you.
> > > >
> > > > Below is my understanding for continous mode of TimerB.
> > > >
> > > > In continuous mode for TimerB to generate the PWM,TBCCR0 and TBCCR5
> > > > will come into picture. TBCCR5 is my code requirement while the
> > > > TBCCR0 is default. I have selected the output mode 3 which is
> > > > set/reset. When TBR=TBCCR5, the EQUx event will set the pin and when
> > > > TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both
> > > > the TBCCR0 and TBCCR5.
> > > >
> > > > Please clarify if I am wrongly interpreting the continuous mode.
> > > >
> > > > Thanks in advance.
> > >
>
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - Michael - Nov 10 8:53:25 2009
OCY,
> You have to give credit to ti2tt. He did write his own code and did
> not rely on video
funny...
> or "sample code".
Is that supposed to be a good thing? Maybe not "rely on" but at least take a look at.
But anyway, it seems to me he is not relying on the User's Guide either, nor on the
previous posts and explanations for that matter.
I challenge you (I don't mean it harshly) to read the entire thread (all twenty-something
posts) and say that again.
Maybe I'm being too harsh, but if you read the entire thread you will understand why. He
needs to stop writing code almost blindly (you can see that on his last code snippet)
hoping to get it working and start THINKING. For godness sake, STOP WRITING CODE AND START
THINKING! (you can hardly call it programming as there seems to be no 'programm' - no
structure - behind his code and posts)
Regards,
Michael K.
--- In m...@yahoogroups.com, "old_cow_yellow"
wrote:
>
> Michael,
>
> You have to give credit to ti2tt. He did write his own code and did not rely on video or
"sample code".
>
> -- OCY
>
> --- In m...@yahoogroups.com, "Michael" wrote:
> >
> > You changed from timer A to timer B but are not using the feature of timer B that
solves your problem. My guess is you haven't taken the time to read THE ENTIRE CHAPTER of
timer B, from top to bottom without skipping anything, no matter if you already readed it
or if you don't understand it at first.
> > Basically, you're using CLLD_0 which is the same as using timer A, disregarding the
ability of choosing when TBCLx will be loaded with the value in TBCCRx. Use CLLD_1 and
your problems will disappear.
> >
> > By the way, there are a lot of things that don't make much sense in
> > your code (comments stripped):
> >
> > Number 1)
> > > void Init_TimerB (void)
> > > {
> > > TBCTL = (TBCLR | MC_0);
> > > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1);
> > > TBCTL &= ~(TBIE | TBIFG);
> > > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2)
> > > }
> > You're changing the TBCTL register 4 times in a row!! What's that about?
> >
> > Number 2)
> > > TBCCTL5 &= ~CCIE;
> > > TBCCTL5 &= ~CAP;
> > > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > With the third instruction you're disregarding what you did with the first two. The
first two are useless unless you use |= instad of = on the third instruction. Do you
understand the difference between the operand |=, &= and = ?
> >
> > Number 3)
> > > switch (TBIV)
> > > {
> > > case TBIV_TBCCR1:
> > > break;
> > > case TBIV_TBCCR5:
> > > TBCCTL5 &= ~CCIFG;
> > > TBCCR0 = (TBCCR5 + DACOUT);
> > > TBCCR5 += PWM_Period;
> > > break;
> > > }
> >
> > TBCCTL5 &= ~CCIFG is superfluous, since by reading TBIV (by the switch instruction)
and entering TBIV_TBCCR5 this flag is automatically cleared.
> >
> > Really, STOP programming and RTFM. Then read it again and take notes. Then read it
again along with your notes.
> >
> > Michael K.
> >
> > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > >
> > > Hello All and a special hello to Michael,
> > >
> > > Sorry to keep pestering you, Michael.
> > >
> > > I am still unable to resolve the PWM issue and seriously thinking of changing career
as Michael advised. Sincerely speaking, I tried very much to analyse the timer behaviour
but to my tough luck I could not figure out the classic mistake. I tried to capture the
timer counts, both theoretically and practically, at different stages of execution to
analyse. I also tried different register settings for TimerB. Please help me out to
resolve the issue. I am including the functions here again. Some constants in code -
PWM_Period = 3334; ACLK=1MHz; DACOUT=any value less than 3334;
> > >
> > > void Init_TimerB (void)
> > > {
> > > TBCTL = (TBCLR | MC_0); //Individual compare latch / Clear TimerB
/ Stop TimerB
> > > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1); //16bit / ACLK / Divide by 2 / Stop
> > > TBCTL &= ~(TBIE | TBIFG); //Disable TBIV and flag
> > >
> > > TBCTL = (CNTL_0 | TBSSEL_1 | ID_1 | MC_2); //16bit / ACLK / Divide by 2 /
Continuous
> > > }
> > >
> > > void ConfigTimerB5_PWM (void)
> > > {
> > > P4SEL &= ~0xA0;
> > > P4SEL |= 0x20; // P4.5 - Select as TB5 functionality
> > > P4DIR |= 0x20; // P4.5 - Select compare as output
> > >
> > > TBCCTL5 &= ~CCIE; //Disable interrupt
> > > TBCCTL5 &= ~CAP; //Compare mode
> > > //CM_0 = No Capture
> > > //CCIS_1 = Capture/Compare input is TB4
> > > //SCS = Synchronous capture
> > > //CLLD_0 = Load compare latch (TBCLx) when
TBCCRx is written
> > > //OUTMOD_3 = Set/Reset
> > > //CCIE = Enable interrupt
> > > //OUT = Output high on pin
> > > TBCCTL5 = (CM_0 | CCIS_1 | SCS | CLLD_0 | OUTMOD_3 | CCIE | OUT);
> > > TBCCR5 = DACOUT; //PWM Duty cycle
> > > }
> > >
> > > Timer ISR -
> > > void ISR_TimerB (void) INTERRUPT[TIMERB1_VECTOR]
> > > {
> > > switch (TBIV)
> > > {
> > > case TBIV_TBCCR1:
> > > break;
> > > case TBIV_TBCCR5: // CCR5 int=10
> > > TBCCTL5 &= ~CCIFG; //Clear interrupt flag
> > > TBCCR0 = (TBCCR5 + DACOUT);
> > > TBCCR5 += PWM_Period; //PWM_Period=3334
> > > break;
> > > }
> > > }
> > >
> > > Please help me to figure out the implementation. Thanks in advance.
> > >
> > > --- In m...@yahoogroups.com, "Michael" wrote:
> > > >
> > > > > When TBR=TBCCR5, the EQUx event will set the pin and when
> > > > > TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both
> > > > > the TBCCR0 and TBCCR5.
> > > >
> > > > Yes... almost. Only EQUx doesn't use TBCCRx but TBCLx, which is an internal
(invisible) register. You can control when TBCLx is automatically loaded with the value in
TBCCRx by means of the CLLDx bits in TBCCTLx register. Any mode but CLLD_0 will solve your
problem and you won't have missed EQUx events, so no jumps to DC=100% when changing to a
lower DC.
> > > >
> > > > Michael K.
> > > >
> > > > --- In m...@yahoogroups.com, "ti2tt" wrote:
> > > > >
> > > > > Hello Michael,
> > > > >
> > > > > Sorry to keep pestering you.
> > > > >
> > > > > Below is my understanding for continous mode of TimerB.
> > > > >
> > > > > In continuous mode for TimerB to generate the PWM,TBCCR0 and TBCCR5
> > > > > will come into picture. TBCCR5 is my code requirement while the
> > > > > TBCCR0 is default. I have selected the output mode 3 which is
> > > > > set/reset. When TBR=TBCCR5, the EQUx event will set the pin and when
> > > > > TBR=TBCCR0, EQUx event will reset the pin. So I need to handle both
> > > > > the TBCCR0 and TBCCR5.
> > > > >
> > > > > Please clarify if I am wrongly interpreting the continuous mode.
> > > > >
> > > > > Thanks in advance.
> > > >
> > >
>
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )Re: PWM using TimerB in Continuous mode - old_cow_yellow - Nov 10 9:48:49 2009
Michael,
I see your point.
I am aware of IMPS. Is there also an IPPS? (Where the first P stands for Parrot.) M or P,
which is better?
-- OCY
--- In m...@yahoogroups.com, "Michael"
wrote:
>
> OCY,
> > You have to give credit to ti2tt. He did write his own code and did
> > not rely on video
>
> funny...
>
> > or "sample code".
> Is that supposed to be a good thing? Maybe not "rely on" but at least take a look at.
> But anyway, it seems to me he is not relying on the User's Guide either, nor on the
previous posts and explanations for that matter.
>
> I challenge you (I don't mean it harshly) to read the entire thread (all
twenty-something posts) and say that again.
>
> Maybe I'm being too harsh, but if you read the entire thread you will understand why. He
needs to stop writing code almost blindly (you can see that on his last code snippet)
hoping to get it working and start THINKING. For godness sake, STOP WRITING CODE AND START
THINKING! (you can hardly call it programming as there seems to be no 'programm' - no
structure - behind his code and posts)
>
> Regards,
> Michael K.
>
> --- In m...@yahoogroups.com, "old_cow_yellow" wrote:
> >
> > Michael,
> >
> > You have to give credit to ti2tt. He did write his own code and did not rely on video
or "sample code".
> >
> > -- OCY
> >
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )