Designing a project based on LED to ON and OFF based on interrupt from momentary
switch. Using F2013 kit. I have stuck with soft-start LED ON and soft-start LED
OFF. Can anyone give some ideas.
LED switches ON - for interrupt
LED is in ON state for 1 min and automatically switches OFF. During 1 minute
wait, momentary switch is pressed LED should switch OFF.
I have gone through sampleEZ codes posted in "Files" section.
From those I came up with some sort of coding technique.
The best I can think is:-
1. Define P1.DIR as output pin.
2. connect momentary switch to pin 7.
3. write an "if" loop to accept interrupt from pin7 and LED starts to switch
ON.
4. Once LED is switched ON, insert another if loop to receive interrupt from
momentary switch to turn LED OFF in that 1 minute duration or wait for 1 minute
to switch LED OFF automatically.
5. I have connected N-channel MOSFET to receive output from MSP430 in parallel
with 10K resistor.
6. Supply voltage is connected directly to MSP430.
7. LED is connected directly to supply voltage with 100 ohm resistor and drain
of MOSFET.
I'm new to MSP430. Using Code composer studio for simulation and debug.
Waiting for your replies.
Soft-Start to "ON" and Soft-Start to "OFF" - LED
Started by ●April 15, 2010
Reply by ●April 15, 20102010-04-15
shskurkra,
You might simply use two interrupt routines. One for your button, a second one tied to a timer of your choice. On a button press, if the LED is off, turn it on and start a timer running that will trigger a second interrupt at 60 seconds to turn the LED off and stop the timer. If the LED is on when the button's pressed, turn it and the timer off.
So, if the user presses the button only once, LED stays on for one minute and then turns off. If the user presses the button a second time in less than a minute, LED turns off. No loops, and you can run in a pretty low power mode waiting for the initial button press. HTH
--- In m..., "shskurkra" wrote:
>
> Designing a project based on LED to ON and OFF based on interrupt from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON and soft-start LED OFF. Can anyone give some ideas.
>
> LED switches ON - for interrupt
> LED is in ON state for 1 min and automatically switches OFF. During 1 minute wait, momentary switch is pressed LED should switch OFF.
>
> I have gone through sampleEZ codes posted in "Files" section.
> From those I came up with some sort of coding technique.
>
> The best I can think is:-
> 1. Define P1.DIR as output pin.
> 2. connect momentary switch to pin 7.
> 3. write an "if" loop to accept interrupt from pin7 and LED starts to switch ON.
> 4. Once LED is switched ON, insert another if loop to receive interrupt from momentary switch to turn LED OFF in that 1 minute duration or wait for 1 minute to switch LED OFF automatically.
> 5. I have connected N-channel MOSFET to receive output from MSP430 in parallel with 10K resistor.
> 6. Supply voltage is connected directly to MSP430.
> 7. LED is connected directly to supply voltage with 100 ohm resistor and drain of MOSFET.
>
> I'm new to MSP430. Using Code composer studio for simulation and debug.
>
> Waiting for your replies.
>
You might simply use two interrupt routines. One for your button, a second one tied to a timer of your choice. On a button press, if the LED is off, turn it on and start a timer running that will trigger a second interrupt at 60 seconds to turn the LED off and stop the timer. If the LED is on when the button's pressed, turn it and the timer off.
So, if the user presses the button only once, LED stays on for one minute and then turns off. If the user presses the button a second time in less than a minute, LED turns off. No loops, and you can run in a pretty low power mode waiting for the initial button press. HTH
--- In m..., "shskurkra" wrote:
>
> Designing a project based on LED to ON and OFF based on interrupt from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON and soft-start LED OFF. Can anyone give some ideas.
>
> LED switches ON - for interrupt
> LED is in ON state for 1 min and automatically switches OFF. During 1 minute wait, momentary switch is pressed LED should switch OFF.
>
> I have gone through sampleEZ codes posted in "Files" section.
> From those I came up with some sort of coding technique.
>
> The best I can think is:-
> 1. Define P1.DIR as output pin.
> 2. connect momentary switch to pin 7.
> 3. write an "if" loop to accept interrupt from pin7 and LED starts to switch ON.
> 4. Once LED is switched ON, insert another if loop to receive interrupt from momentary switch to turn LED OFF in that 1 minute duration or wait for 1 minute to switch LED OFF automatically.
> 5. I have connected N-channel MOSFET to receive output from MSP430 in parallel with 10K resistor.
> 6. Supply voltage is connected directly to MSP430.
> 7. LED is connected directly to supply voltage with 100 ohm resistor and drain of MOSFET.
>
> I'm new to MSP430. Using Code composer studio for simulation and debug.
>
> Waiting for your replies.
>
Reply by ●April 16, 20102010-04-16
Thanks Bob, for your potential feedback. How about turning LED ON from dim to
bright and vice versa.
I looked through PWM continuous signal.
Do you have an alternative method like altering duty cycle for certain seconds to start LED from dim to certain brightness.
--- In m..., "Bob" wrote:
>
> shskurkra,
>
> You might simply use two interrupt routines. One for your button, a second one tied to a timer of your choice. On a button press, if the LED is off, turn it on and start a timer running that will trigger a second interrupt at 60 seconds to turn the LED off and stop the timer. If the LED is on when the button's pressed, turn it and the timer off.
>
> So, if the user presses the button only once, LED stays on for one minute and then turns off. If the user presses the button a second time in less than a minute, LED turns off. No loops, and you can run in a pretty low power mode waiting for the initial button press. HTH
> --- In m..., "shskurkra" wrote:
> >
> > Designing a project based on LED to ON and OFF based on interrupt from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON and soft-start LED OFF. Can anyone give some ideas.
> >
> > LED switches ON - for interrupt
> > LED is in ON state for 1 min and automatically switches OFF. During 1 minute wait, momentary switch is pressed LED should switch OFF.
> >
> > I have gone through sampleEZ codes posted in "Files" section.
> > From those I came up with some sort of coding technique.
> >
> > The best I can think is:-
> > 1. Define P1.DIR as output pin.
> > 2. connect momentary switch to pin 7.
> > 3. write an "if" loop to accept interrupt from pin7 and LED starts to switch ON.
> > 4. Once LED is switched ON, insert another if loop to receive interrupt from momentary switch to turn LED OFF in that 1 minute duration or wait for 1 minute to switch LED OFF automatically.
> > 5. I have connected N-channel MOSFET to receive output from MSP430 in parallel with 10K resistor.
> > 6. Supply voltage is connected directly to MSP430.
> > 7. LED is connected directly to supply voltage with 100 ohm resistor and drain of MOSFET.
> >
> > I'm new to MSP430. Using Code composer studio for simulation and debug.
> >
> > Waiting for your replies.
>
I looked through PWM continuous signal.
Do you have an alternative method like altering duty cycle for certain seconds to start LED from dim to certain brightness.
--- In m..., "Bob" wrote:
>
> shskurkra,
>
> You might simply use two interrupt routines. One for your button, a second one tied to a timer of your choice. On a button press, if the LED is off, turn it on and start a timer running that will trigger a second interrupt at 60 seconds to turn the LED off and stop the timer. If the LED is on when the button's pressed, turn it and the timer off.
>
> So, if the user presses the button only once, LED stays on for one minute and then turns off. If the user presses the button a second time in less than a minute, LED turns off. No loops, and you can run in a pretty low power mode waiting for the initial button press. HTH
> --- In m..., "shskurkra" wrote:
> >
> > Designing a project based on LED to ON and OFF based on interrupt from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON and soft-start LED OFF. Can anyone give some ideas.
> >
> > LED switches ON - for interrupt
> > LED is in ON state for 1 min and automatically switches OFF. During 1 minute wait, momentary switch is pressed LED should switch OFF.
> >
> > I have gone through sampleEZ codes posted in "Files" section.
> > From those I came up with some sort of coding technique.
> >
> > The best I can think is:-
> > 1. Define P1.DIR as output pin.
> > 2. connect momentary switch to pin 7.
> > 3. write an "if" loop to accept interrupt from pin7 and LED starts to switch ON.
> > 4. Once LED is switched ON, insert another if loop to receive interrupt from momentary switch to turn LED OFF in that 1 minute duration or wait for 1 minute to switch LED OFF automatically.
> > 5. I have connected N-channel MOSFET to receive output from MSP430 in parallel with 10K resistor.
> > 6. Supply voltage is connected directly to MSP430.
> > 7. LED is connected directly to supply voltage with 100 ohm resistor and drain of MOSFET.
> >
> > I'm new to MSP430. Using Code composer studio for simulation and debug.
> >
> > Waiting for your replies.
>
Reply by ●April 16, 20102010-04-16
I've not had need to write such routines, but I believe I've seen them
in John Davies' text on the MSP430
(http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
and if I remember correctly, the code examples can be downloaded.
--- In m..., "shskurkra" wrote:
>
> Thanks Bob, for your potential feedback. How about turning LED ON from dim to bright and vice versa.
> I looked through PWM continuous signal.
> Do you have an alternative method like altering duty cycle for certain seconds to start LED from dim to certain brightness.
> --- In m..., "Bob" wrote:
> >
> > shskurkra,
> >
> > You might simply use two interrupt routines. One for your button, a second one tied to a timer of your choice. On a button press, if the LED is off, turn it on and start a timer running that will trigger a second interrupt at 60 seconds to turn the LED off and stop the timer. If the LED is on when the button's pressed, turn it and the timer off.
> >
> > So, if the user presses the button only once, LED stays on for one minute and then turns off. If the user presses the button a second time in less than a minute, LED turns off. No loops, and you can run in a pretty low power mode waiting for the initial button press. HTH
> >
> >
> > --- In m..., "shskurkra" wrote:
> > >
> > > Designing a project based on LED to ON and OFF based on interrupt from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON and soft-start LED OFF. Can anyone give some ideas.
> > >
> > > LED switches ON - for interrupt
> > > LED is in ON state for 1 min and automatically switches OFF. During 1 minute wait, momentary switch is pressed LED should switch OFF.
> > >
> > > I have gone through sampleEZ codes posted in "Files" section.
> > > From those I came up with some sort of coding technique.
> > >
> > > The best I can think is:-
> > > 1. Define P1.DIR as output pin.
> > > 2. connect momentary switch to pin 7.
> > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to switch ON.
> > > 4. Once LED is switched ON, insert another if loop to receive interrupt from momentary switch to turn LED OFF in that 1 minute duration or wait for 1 minute to switch LED OFF automatically.
> > > 5. I have connected N-channel MOSFET to receive output from MSP430 in parallel with 10K resistor.
> > > 6. Supply voltage is connected directly to MSP430.
> > > 7. LED is connected directly to supply voltage with 100 ohm resistor and drain of MOSFET.
> > >
> > > I'm new to MSP430. Using Code composer studio for simulation and debug.
> > >
> > > Waiting for your replies.
> > >
>
--- In m..., "shskurkra" wrote:
>
> Thanks Bob, for your potential feedback. How about turning LED ON from dim to bright and vice versa.
> I looked through PWM continuous signal.
> Do you have an alternative method like altering duty cycle for certain seconds to start LED from dim to certain brightness.
> --- In m..., "Bob" wrote:
> >
> > shskurkra,
> >
> > You might simply use two interrupt routines. One for your button, a second one tied to a timer of your choice. On a button press, if the LED is off, turn it on and start a timer running that will trigger a second interrupt at 60 seconds to turn the LED off and stop the timer. If the LED is on when the button's pressed, turn it and the timer off.
> >
> > So, if the user presses the button only once, LED stays on for one minute and then turns off. If the user presses the button a second time in less than a minute, LED turns off. No loops, and you can run in a pretty low power mode waiting for the initial button press. HTH
> >
> >
> > --- In m..., "shskurkra" wrote:
> > >
> > > Designing a project based on LED to ON and OFF based on interrupt from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON and soft-start LED OFF. Can anyone give some ideas.
> > >
> > > LED switches ON - for interrupt
> > > LED is in ON state for 1 min and automatically switches OFF. During 1 minute wait, momentary switch is pressed LED should switch OFF.
> > >
> > > I have gone through sampleEZ codes posted in "Files" section.
> > > From those I came up with some sort of coding technique.
> > >
> > > The best I can think is:-
> > > 1. Define P1.DIR as output pin.
> > > 2. connect momentary switch to pin 7.
> > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to switch ON.
> > > 4. Once LED is switched ON, insert another if loop to receive interrupt from momentary switch to turn LED OFF in that 1 minute duration or wait for 1 minute to switch LED OFF automatically.
> > > 5. I have connected N-channel MOSFET to receive output from MSP430 in parallel with 10K resistor.
> > > 6. Supply voltage is connected directly to MSP430.
> > > 7. LED is connected directly to supply voltage with 100 ohm resistor and drain of MOSFET.
> > >
> > > I'm new to MSP430. Using Code composer studio for simulation and debug.
> > >
> > > Waiting for your replies.
> > >
>
Reply by ●April 16, 20102010-04-16
The example is 8.18. One question, can I simulate Assembly code and C
written code together in code composer studio v4.
On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
> I've not had need to write such routines, but I believe I've seen them in
> John Davies' text on the MSP430 (
> http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> and if I remember correctly, the code examples can be downloaded.
> --- In m... , "shskurkra"
> wrote:
> >
> > Thanks Bob, for your potential feedback. How about turning LED ON from
> dim to bright and vice versa.
> > I looked through PWM continuous signal.
> > Do you have an alternative method like altering duty cycle for certain
> seconds to start LED from dim to certain brightness.
> >
> >
> > --- In m... , "Bob"
> wrote:
> > >
> > > shskurkra,
> > >
> > > You might simply use two interrupt routines. One for your button, a
> second one tied to a timer of your choice. On a button press, if the LED is
> off, turn it on and start a timer running that will trigger a second
> interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> is on when the button's pressed, turn it and the timer off.
> > >
> > > So, if the user presses the button only once, LED stays on for one
> minute and then turns off. If the user presses the button a second time in
> less than a minute, LED turns off. No loops, and you can run in a pretty low
> power mode waiting for the initial button press. HTH
> > >
> > >
> > > --- In m... , "shskurkra"
> wrote:
> > > >
> > > > Designing a project based on LED to ON and OFF based on interrupt
> from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> and soft-start LED OFF. Can anyone give some ideas.
> > > >
> > > > LED switches ON - for interrupt
> > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> minute wait, momentary switch is pressed LED should switch OFF.
> > > >
> > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > From those I came up with some sort of coding technique.
> > > >
> > > > The best I can think is:-
> > > > 1. Define P1.DIR as output pin.
> > > > 2. connect momentary switch to pin 7.
> > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> switch ON.
> > > > 4. Once LED is switched ON, insert another if loop to receive
> interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> wait for 1 minute to switch LED OFF automatically.
> > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> parallel with 10K resistor.
> > > > 6. Supply voltage is connected directly to MSP430.
> > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> and drain of MOSFET.
> > > >
> > > > I'm new to MSP430. Using Code composer studio for simulation and
> debug.
> > > >
> > > > Waiting for your replies.
> > > >
> > >
> >
>
written code together in code composer studio v4.
On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
> I've not had need to write such routines, but I believe I've seen them in
> John Davies' text on the MSP430 (
> http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> and if I remember correctly, the code examples can be downloaded.
> --- In m... , "shskurkra"
> wrote:
> >
> > Thanks Bob, for your potential feedback. How about turning LED ON from
> dim to bright and vice versa.
> > I looked through PWM continuous signal.
> > Do you have an alternative method like altering duty cycle for certain
> seconds to start LED from dim to certain brightness.
> >
> >
> > --- In m... , "Bob"
> wrote:
> > >
> > > shskurkra,
> > >
> > > You might simply use two interrupt routines. One for your button, a
> second one tied to a timer of your choice. On a button press, if the LED is
> off, turn it on and start a timer running that will trigger a second
> interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> is on when the button's pressed, turn it and the timer off.
> > >
> > > So, if the user presses the button only once, LED stays on for one
> minute and then turns off. If the user presses the button a second time in
> less than a minute, LED turns off. No loops, and you can run in a pretty low
> power mode waiting for the initial button press. HTH
> > >
> > >
> > > --- In m... , "shskurkra"
> wrote:
> > > >
> > > > Designing a project based on LED to ON and OFF based on interrupt
> from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> and soft-start LED OFF. Can anyone give some ideas.
> > > >
> > > > LED switches ON - for interrupt
> > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> minute wait, momentary switch is pressed LED should switch OFF.
> > > >
> > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > From those I came up with some sort of coding technique.
> > > >
> > > > The best I can think is:-
> > > > 1. Define P1.DIR as output pin.
> > > > 2. connect momentary switch to pin 7.
> > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> switch ON.
> > > > 4. Once LED is switched ON, insert another if loop to receive
> interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> wait for 1 minute to switch LED OFF automatically.
> > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> parallel with 10K resistor.
> > > > 6. Supply voltage is connected directly to MSP430.
> > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> and drain of MOSFET.
> > > >
> > > > I'm new to MSP430. Using Code composer studio for simulation and
> debug.
> > > >
> > > > Waiting for your replies.
> > > >
> > >
> >
>
Reply by ●April 16, 20102010-04-16
>can I simulate Assembly code and C
>written code together in code composer studio v4.
Sorry, I don't know the answer to that...
--- In m..., Shreyas Kumar Krishnappa wrote:
>
> The example is 8.18. One question, can I simulate Assembly code and C
> written code together in code composer studio v4.
> On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
>
> >
> >
> > I've not had need to write such routines, but I believe I've seen them in
> > John Davies' text on the MSP430 (
> > http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> > and if I remember correctly, the code examples can be downloaded.
> >
> >
> > --- In m... , "shskurkra"
> > wrote:
> > >
> > > Thanks Bob, for your potential feedback. How about turning LED ON from
> > dim to bright and vice versa.
> > > I looked through PWM continuous signal.
> > > Do you have an alternative method like altering duty cycle for certain
> > seconds to start LED from dim to certain brightness.
> > >
> > >
> > > --- In m... , "Bob"
> > wrote:
> > > >
> > > > shskurkra,
> > > >
> > > > You might simply use two interrupt routines. One for your button, a
> > second one tied to a timer of your choice. On a button press, if the LED is
> > off, turn it on and start a timer running that will trigger a second
> > interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> > is on when the button's pressed, turn it and the timer off.
> > > >
> > > > So, if the user presses the button only once, LED stays on for one
> > minute and then turns off. If the user presses the button a second time in
> > less than a minute, LED turns off. No loops, and you can run in a pretty low
> > power mode waiting for the initial button press. HTH
> > > >
> > > >
> > > > --- In m... , "shskurkra"
> > wrote:
> > > > >
> > > > > Designing a project based on LED to ON and OFF based on interrupt
> > from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> > and soft-start LED OFF. Can anyone give some ideas.
> > > > >
> > > > > LED switches ON - for interrupt
> > > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> > minute wait, momentary switch is pressed LED should switch OFF.
> > > > >
> > > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > > From those I came up with some sort of coding technique.
> > > > >
> > > > > The best I can think is:-
> > > > > 1. Define P1.DIR as output pin.
> > > > > 2. connect momentary switch to pin 7.
> > > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> > switch ON.
> > > > > 4. Once LED is switched ON, insert another if loop to receive
> > interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> > wait for 1 minute to switch LED OFF automatically.
> > > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> > parallel with 10K resistor.
> > > > > 6. Supply voltage is connected directly to MSP430.
> > > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> > and drain of MOSFET.
> > > > >
> > > > > I'm new to MSP430. Using Code composer studio for simulation and
> > debug.
> > > > >
> > > > > Waiting for your replies.
> > > > >
> > > >
> > >
> >
> >
> >
>
>
>written code together in code composer studio v4.
Sorry, I don't know the answer to that...
--- In m..., Shreyas Kumar Krishnappa wrote:
>
> The example is 8.18. One question, can I simulate Assembly code and C
> written code together in code composer studio v4.
> On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
>
> >
> >
> > I've not had need to write such routines, but I believe I've seen them in
> > John Davies' text on the MSP430 (
> > http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> > and if I remember correctly, the code examples can be downloaded.
> >
> >
> > --- In m... , "shskurkra"
> > wrote:
> > >
> > > Thanks Bob, for your potential feedback. How about turning LED ON from
> > dim to bright and vice versa.
> > > I looked through PWM continuous signal.
> > > Do you have an alternative method like altering duty cycle for certain
> > seconds to start LED from dim to certain brightness.
> > >
> > >
> > > --- In m... , "Bob"
> > wrote:
> > > >
> > > > shskurkra,
> > > >
> > > > You might simply use two interrupt routines. One for your button, a
> > second one tied to a timer of your choice. On a button press, if the LED is
> > off, turn it on and start a timer running that will trigger a second
> > interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> > is on when the button's pressed, turn it and the timer off.
> > > >
> > > > So, if the user presses the button only once, LED stays on for one
> > minute and then turns off. If the user presses the button a second time in
> > less than a minute, LED turns off. No loops, and you can run in a pretty low
> > power mode waiting for the initial button press. HTH
> > > >
> > > >
> > > > --- In m... , "shskurkra"
> > wrote:
> > > > >
> > > > > Designing a project based on LED to ON and OFF based on interrupt
> > from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> > and soft-start LED OFF. Can anyone give some ideas.
> > > > >
> > > > > LED switches ON - for interrupt
> > > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> > minute wait, momentary switch is pressed LED should switch OFF.
> > > > >
> > > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > > From those I came up with some sort of coding technique.
> > > > >
> > > > > The best I can think is:-
> > > > > 1. Define P1.DIR as output pin.
> > > > > 2. connect momentary switch to pin 7.
> > > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> > switch ON.
> > > > > 4. Once LED is switched ON, insert another if loop to receive
> > interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> > wait for 1 minute to switch LED OFF automatically.
> > > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> > parallel with 10K resistor.
> > > > > 6. Supply voltage is connected directly to MSP430.
> > > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> > and drain of MOSFET.
> > > > >
> > > > > I'm new to MSP430. Using Code composer studio for simulation and
> > debug.
> > > > >
> > > > > Waiting for your replies.
> > > > >
> > > >
> > >
> >
> >
> >
>
>
Reply by ●April 28, 20102010-04-28
The code to turn LED ON and OFF for interrupts; The program is good, please let
me know.
Thank you
=======PROGRAM
=======#include
static volatile bool timer_event;
int main( ) {
WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
BCSCTL1= CALBC1_8MHZ;
DCOCTL= CALDCO_8MHZ;
__enable_interrupt( );
for ( ; ; ) {
//P7OUT ^= 0x01; // using XOR toggles the pin value.
P7OUT = 0x01; // LED ON.
for ( timer_event= false; !timer_event; )
P7OUT = 0x00; // LED OFF;
else
for ( ; ; ) {
P7OUT = 0x00; // LED OFF.
}
return 0;
}
TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
#pragma vector= TIMERA0_VECTOR
__interrupt void timer_A2( void ) {
timer_event= true;
return;
}
================--- In m..., "Bob" wrote:
>
> >can I simulate Assembly code and C
> >written code together in code composer studio v4.
> Sorry, I don't know the answer to that...
>
> --- In m..., Shreyas Kumar Krishnappa wrote:
> >
> > The example is 8.18. One question, can I simulate Assembly code and C
> > written code together in code composer studio v4.
> >
> >
> > On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
> >
> > >
> > >
> > > I've not had need to write such routines, but I believe I've seen them in
> > > John Davies' text on the MSP430 (
> > > http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> > > and if I remember correctly, the code examples can be downloaded.
> > >
> > >
> > > --- In m... , "shskurkra"
> > > wrote:
> > > >
> > > > Thanks Bob, for your potential feedback. How about turning LED ON from
> > > dim to bright and vice versa.
> > > > I looked through PWM continuous signal.
> > > > Do you have an alternative method like altering duty cycle for certain
> > > seconds to start LED from dim to certain brightness.
> > > >
> > > >
> > > > --- In m... , "Bob"
> > > wrote:
> > > > >
> > > > > shskurkra,
> > > > >
> > > > > You might simply use two interrupt routines. One for your button, a
> > > second one tied to a timer of your choice. On a button press, if the LED is
> > > off, turn it on and start a timer running that will trigger a second
> > > interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> > > is on when the button's pressed, turn it and the timer off.
> > > > >
> > > > > So, if the user presses the button only once, LED stays on for one
> > > minute and then turns off. If the user presses the button a second time in
> > > less than a minute, LED turns off. No loops, and you can run in a pretty low
> > > power mode waiting for the initial button press. HTH
> > > > >
> > > > >
> > > > > --- In m... , "shskurkra"
> > > wrote:
> > > > > >
> > > > > > Designing a project based on LED to ON and OFF based on interrupt
> > > from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> > > and soft-start LED OFF. Can anyone give some ideas.
> > > > > >
> > > > > > LED switches ON - for interrupt
> > > > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> > > minute wait, momentary switch is pressed LED should switch OFF.
> > > > > >
> > > > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > > > From those I came up with some sort of coding technique.
> > > > > >
> > > > > > The best I can think is:-
> > > > > > 1. Define P1.DIR as output pin.
> > > > > > 2. connect momentary switch to pin 7.
> > > > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> > > switch ON.
> > > > > > 4. Once LED is switched ON, insert another if loop to receive
> > > interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> > > wait for 1 minute to switch LED OFF automatically.
> > > > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> > > parallel with 10K resistor.
> > > > > > 6. Supply voltage is connected directly to MSP430.
> > > > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> > > and drain of MOSFET.
> > > > > >
> > > > > > I'm new to MSP430. Using Code composer studio for simulation and
> > > debug.
> > > > > >
> > > > > > Waiting for your replies.
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
>
Thank you
=======PROGRAM
=======#include
static volatile bool timer_event;
int main( ) {
WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
BCSCTL1= CALBC1_8MHZ;
DCOCTL= CALDCO_8MHZ;
__enable_interrupt( );
for ( ; ; ) {
//P7OUT ^= 0x01; // using XOR toggles the pin value.
P7OUT = 0x01; // LED ON.
for ( timer_event= false; !timer_event; )
P7OUT = 0x00; // LED OFF;
else
for ( ; ; ) {
P7OUT = 0x00; // LED OFF.
}
return 0;
}
TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
#pragma vector= TIMERA0_VECTOR
__interrupt void timer_A2( void ) {
timer_event= true;
return;
}
================--- In m..., "Bob" wrote:
>
> >can I simulate Assembly code and C
> >written code together in code composer studio v4.
> Sorry, I don't know the answer to that...
>
> --- In m..., Shreyas Kumar Krishnappa wrote:
> >
> > The example is 8.18. One question, can I simulate Assembly code and C
> > written code together in code composer studio v4.
> >
> >
> > On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
> >
> > >
> > >
> > > I've not had need to write such routines, but I believe I've seen them in
> > > John Davies' text on the MSP430 (
> > > http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> > > and if I remember correctly, the code examples can be downloaded.
> > >
> > >
> > > --- In m... , "shskurkra"
> > > wrote:
> > > >
> > > > Thanks Bob, for your potential feedback. How about turning LED ON from
> > > dim to bright and vice versa.
> > > > I looked through PWM continuous signal.
> > > > Do you have an alternative method like altering duty cycle for certain
> > > seconds to start LED from dim to certain brightness.
> > > >
> > > >
> > > > --- In m... , "Bob"
> > > wrote:
> > > > >
> > > > > shskurkra,
> > > > >
> > > > > You might simply use two interrupt routines. One for your button, a
> > > second one tied to a timer of your choice. On a button press, if the LED is
> > > off, turn it on and start a timer running that will trigger a second
> > > interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> > > is on when the button's pressed, turn it and the timer off.
> > > > >
> > > > > So, if the user presses the button only once, LED stays on for one
> > > minute and then turns off. If the user presses the button a second time in
> > > less than a minute, LED turns off. No loops, and you can run in a pretty low
> > > power mode waiting for the initial button press. HTH
> > > > >
> > > > >
> > > > > --- In m... , "shskurkra"
> > > wrote:
> > > > > >
> > > > > > Designing a project based on LED to ON and OFF based on interrupt
> > > from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> > > and soft-start LED OFF. Can anyone give some ideas.
> > > > > >
> > > > > > LED switches ON - for interrupt
> > > > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> > > minute wait, momentary switch is pressed LED should switch OFF.
> > > > > >
> > > > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > > > From those I came up with some sort of coding technique.
> > > > > >
> > > > > > The best I can think is:-
> > > > > > 1. Define P1.DIR as output pin.
> > > > > > 2. connect momentary switch to pin 7.
> > > > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> > > switch ON.
> > > > > > 4. Once LED is switched ON, insert another if loop to receive
> > > interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> > > wait for 1 minute to switch LED OFF automatically.
> > > > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> > > parallel with 10K resistor.
> > > > > > 6. Supply voltage is connected directly to MSP430.
> > > > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> > > and drain of MOSFET.
> > > > > >
> > > > > > I'm new to MSP430. Using Code composer studio for simulation and
> > > debug.
> > > > > >
> > > > > > Waiting for your replies.
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
>
Reply by ●April 28, 20102010-04-28
The code for LED ON and OFF. Managed to write, but not sure about the for loop
part errors. Please let me know. Thank you.
========PROGRAM
========#include
static volatile bool timer_event;
int main( ) {
WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
BCSCTL1= CALBC1_8MHZ;
DCOCTL= CALDCO_8MHZ;
__enable_interrupt( );
for ( ; ; ) {
//P7OUT ^= 0x01; // using XOR toggles the pin value.
P7OUT = 0x01; // LED ON.
for ( timer_event= false; !timer_event; )
P7OUT = 0x00; // LED OFF;
else
for ( ; ; ) {
P7OUT = 0x00; // LED OFF.
}
return 0;
}
TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
#pragma vector= TIMERA0_VECTOR
__interrupt void timer_A2( void ) {
timer_event= true;
return;
}
================--- In m..., "Bob" wrote:
>
> >can I simulate Assembly code and C
> >written code together in code composer studio v4.
> Sorry, I don't know the answer to that...
>
> --- In m..., Shreyas Kumar Krishnappa wrote:
> >
> > The example is 8.18. One question, can I simulate Assembly code and C
> > written code together in code composer studio v4.
> >
> >
> > On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
> >
> > >
> > >
> > > I've not had need to write such routines, but I believe I've seen them in
> > > John Davies' text on the MSP430 (
> > > http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> > > and if I remember correctly, the code examples can be downloaded.
> > >
> > >
> > > --- In m... , "shskurkra"
> > > wrote:
> > > >
> > > > Thanks Bob, for your potential feedback. How about turning LED ON from
> > > dim to bright and vice versa.
> > > > I looked through PWM continuous signal.
> > > > Do you have an alternative method like altering duty cycle for certain
> > > seconds to start LED from dim to certain brightness.
> > > >
> > > >
> > > > --- In m... , "Bob"
> > > wrote:
> > > > >
> > > > > shskurkra,
> > > > >
> > > > > You might simply use two interrupt routines. One for your button, a
> > > second one tied to a timer of your choice. On a button press, if the LED is
> > > off, turn it on and start a timer running that will trigger a second
> > > interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> > > is on when the button's pressed, turn it and the timer off.
> > > > >
> > > > > So, if the user presses the button only once, LED stays on for one
> > > minute and then turns off. If the user presses the button a second time in
> > > less than a minute, LED turns off. No loops, and you can run in a pretty low
> > > power mode waiting for the initial button press. HTH
> > > > >
> > > > >
> > > > > --- In m... , "shskurkra"
> > > wrote:
> > > > > >
> > > > > > Designing a project based on LED to ON and OFF based on interrupt
> > > from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> > > and soft-start LED OFF. Can anyone give some ideas.
> > > > > >
> > > > > > LED switches ON - for interrupt
> > > > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> > > minute wait, momentary switch is pressed LED should switch OFF.
> > > > > >
> > > > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > > > From those I came up with some sort of coding technique.
> > > > > >
> > > > > > The best I can think is:-
> > > > > > 1. Define P1.DIR as output pin.
> > > > > > 2. connect momentary switch to pin 7.
> > > > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> > > switch ON.
> > > > > > 4. Once LED is switched ON, insert another if loop to receive
> > > interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> > > wait for 1 minute to switch LED OFF automatically.
> > > > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> > > parallel with 10K resistor.
> > > > > > 6. Supply voltage is connected directly to MSP430.
> > > > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> > > and drain of MOSFET.
> > > > > >
> > > > > > I'm new to MSP430. Using Code composer studio for simulation and
> > > debug.
> > > > > >
> > > > > > Waiting for your replies.
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
>
========PROGRAM
========#include
static volatile bool timer_event;
int main( ) {
WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
BCSCTL1= CALBC1_8MHZ;
DCOCTL= CALDCO_8MHZ;
__enable_interrupt( );
for ( ; ; ) {
//P7OUT ^= 0x01; // using XOR toggles the pin value.
P7OUT = 0x01; // LED ON.
for ( timer_event= false; !timer_event; )
P7OUT = 0x00; // LED OFF;
else
for ( ; ; ) {
P7OUT = 0x00; // LED OFF.
}
return 0;
}
TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
#pragma vector= TIMERA0_VECTOR
__interrupt void timer_A2( void ) {
timer_event= true;
return;
}
================--- In m..., "Bob" wrote:
>
> >can I simulate Assembly code and C
> >written code together in code composer studio v4.
> Sorry, I don't know the answer to that...
>
> --- In m..., Shreyas Kumar Krishnappa wrote:
> >
> > The example is 8.18. One question, can I simulate Assembly code and C
> > written code together in code composer studio v4.
> >
> >
> > On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
> >
> > >
> > >
> > > I've not had need to write such routines, but I believe I've seen them in
> > > John Davies' text on the MSP430 (
> > > http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> > > and if I remember correctly, the code examples can be downloaded.
> > >
> > >
> > > --- In m... , "shskurkra"
> > > wrote:
> > > >
> > > > Thanks Bob, for your potential feedback. How about turning LED ON from
> > > dim to bright and vice versa.
> > > > I looked through PWM continuous signal.
> > > > Do you have an alternative method like altering duty cycle for certain
> > > seconds to start LED from dim to certain brightness.
> > > >
> > > >
> > > > --- In m... , "Bob"
> > > wrote:
> > > > >
> > > > > shskurkra,
> > > > >
> > > > > You might simply use two interrupt routines. One for your button, a
> > > second one tied to a timer of your choice. On a button press, if the LED is
> > > off, turn it on and start a timer running that will trigger a second
> > > interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> > > is on when the button's pressed, turn it and the timer off.
> > > > >
> > > > > So, if the user presses the button only once, LED stays on for one
> > > minute and then turns off. If the user presses the button a second time in
> > > less than a minute, LED turns off. No loops, and you can run in a pretty low
> > > power mode waiting for the initial button press. HTH
> > > > >
> > > > >
> > > > > --- In m... , "shskurkra"
> > > wrote:
> > > > > >
> > > > > > Designing a project based on LED to ON and OFF based on interrupt
> > > from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> > > and soft-start LED OFF. Can anyone give some ideas.
> > > > > >
> > > > > > LED switches ON - for interrupt
> > > > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> > > minute wait, momentary switch is pressed LED should switch OFF.
> > > > > >
> > > > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > > > From those I came up with some sort of coding technique.
> > > > > >
> > > > > > The best I can think is:-
> > > > > > 1. Define P1.DIR as output pin.
> > > > > > 2. connect momentary switch to pin 7.
> > > > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> > > switch ON.
> > > > > > 4. Once LED is switched ON, insert another if loop to receive
> > > interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> > > wait for 1 minute to switch LED OFF automatically.
> > > > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> > > parallel with 10K resistor.
> > > > > > 6. Supply voltage is connected directly to MSP430.
> > > > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> > > and drain of MOSFET.
> > > > > >
> > > > > > I'm new to MSP430. Using Code composer studio for simulation and
> > > debug.
> > > > > >
> > > > > > Waiting for your replies.
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
>
Reply by ●April 30, 20102010-04-30
Hi Bob, I tried to simulate the code in CCSV4, but I have 14 errors. One error
is about "bool" static code. Can you give me some hints to debug this program.
Thank you.
The program i used to execute is
=================#include
static volatile bool timer_event;
int main( ) {
WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
//BCSCTL1= CALBC1_16MHZ;
//DCOCTL= CALDCO_16MHZ;
BCSCTL1= CALBC1_16MHZ;
DCOCTL= CALDCO_16MHZ;
// BCSCTL1= XT2OFF | RSEL3 | RSEL2 | RSEL1 | RSEL0; // Microcontroller runs at faster rate at 16MHz range
// DCOCTL= DCO2 | DCO1 | DCO0; // Microcontroller runs at faster rate 16MHz range
__enable_interrupt( );
for ( ; ; ) {
//P7OUT ^= 0x01; // using XOR toggles the pin value.
P7OUT = 0x01; // LED ON.
for ( timer_event= false; !timer_event; )
P7OUT = 0x00; // LED OFF;
else
for ( ; ; ) {
P7OUT = 0x00; // LED OFF.
}
return 0;
}
}
TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
//TACCR0= 19999; // 10ms intervals.[change here for 15 seconds or 30 seconds delay]
TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
//TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
#pragma vector= TIMERA0_VECTOR
__interrupt void timer_A2( void ) {
timer_event= true;
return 0;
}
}
============================--- In m..., "shskurkra" wrote:
>
> The code to turn LED ON and OFF for interrupts; The program is good, please let me know.
> Thank you
> =======> PROGRAM
> =======> #include
> static volatile bool timer_event;
>
> int main( ) {
>
> WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
>
> P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
>
> P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
>
> BCSCTL1= CALBC1_8MHZ;
> DCOCTL= CALDCO_8MHZ;
> __enable_interrupt( );
>
> for ( ; ; ) {
> //P7OUT ^= 0x01; // using XOR toggles the pin value.
> P7OUT = 0x01; // LED ON.
> for ( timer_event= false; !timer_event; )
> P7OUT = 0x00; // LED OFF;
> else
> for ( ; ; ) {
> P7OUT = 0x00; // LED OFF.
> }
>
> return 0;
> }
> TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
> TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
> TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
> TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
>
> #pragma vector= TIMERA0_VECTOR
> __interrupt void timer_A2( void ) {
> timer_event= true;
> return;
> }
> ========> ========> --- In m..., "Bob" wrote:
> >
> > >can I simulate Assembly code and C
> > >written code together in code composer studio v4.
> > Sorry, I don't know the answer to that...
> >
> > --- In m..., Shreyas Kumar Krishnappa wrote:
> > >
> > > The example is 8.18. One question, can I simulate Assembly code and C
> > > written code together in code composer studio v4.
> > >
> > >
> > > On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
> > >
> > > >
> > > >
> > > > I've not had need to write such routines, but I believe I've seen them in
> > > > John Davies' text on the MSP430 (
> > > > http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> > > > and if I remember correctly, the code examples can be downloaded.
> > > >
> > > >
> > > > --- In m... , "shskurkra"
> > > > wrote:
> > > > >
> > > > > Thanks Bob, for your potential feedback. How about turning LED ON from
> > > > dim to bright and vice versa.
> > > > > I looked through PWM continuous signal.
> > > > > Do you have an alternative method like altering duty cycle for certain
> > > > seconds to start LED from dim to certain brightness.
> > > > >
> > > > >
> > > > > --- In m... , "Bob"
> > > > wrote:
> > > > > >
> > > > > > shskurkra,
> > > > > >
> > > > > > You might simply use two interrupt routines. One for your button, a
> > > > second one tied to a timer of your choice. On a button press, if the LED is
> > > > off, turn it on and start a timer running that will trigger a second
> > > > interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> > > > is on when the button's pressed, turn it and the timer off.
> > > > > >
> > > > > > So, if the user presses the button only once, LED stays on for one
> > > > minute and then turns off. If the user presses the button a second time in
> > > > less than a minute, LED turns off. No loops, and you can run in a pretty low
> > > > power mode waiting for the initial button press. HTH
> > > > > >
> > > > > >
> > > > > > --- In m... , "shskurkra"
> > > > wrote:
> > > > > > >
> > > > > > > Designing a project based on LED to ON and OFF based on interrupt
> > > > from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> > > > and soft-start LED OFF. Can anyone give some ideas.
> > > > > > >
> > > > > > > LED switches ON - for interrupt
> > > > > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> > > > minute wait, momentary switch is pressed LED should switch OFF.
> > > > > > >
> > > > > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > > > > From those I came up with some sort of coding technique.
> > > > > > >
> > > > > > > The best I can think is:-
> > > > > > > 1. Define P1.DIR as output pin.
> > > > > > > 2. connect momentary switch to pin 7.
> > > > > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> > > > switch ON.
> > > > > > > 4. Once LED is switched ON, insert another if loop to receive
> > > > interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> > > > wait for 1 minute to switch LED OFF automatically.
> > > > > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> > > > parallel with 10K resistor.
> > > > > > > 6. Supply voltage is connected directly to MSP430.
> > > > > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> > > > and drain of MOSFET.
> > > > > > >
> > > > > > > I'm new to MSP430. Using Code composer studio for simulation and
> > > > debug.
> > > > > > >
> > > > > > > Waiting for your replies.
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
>
The program i used to execute is
=================#include
static volatile bool timer_event;
int main( ) {
WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
//BCSCTL1= CALBC1_16MHZ;
//DCOCTL= CALDCO_16MHZ;
BCSCTL1= CALBC1_16MHZ;
DCOCTL= CALDCO_16MHZ;
// BCSCTL1= XT2OFF | RSEL3 | RSEL2 | RSEL1 | RSEL0; // Microcontroller runs at faster rate at 16MHz range
// DCOCTL= DCO2 | DCO1 | DCO0; // Microcontroller runs at faster rate 16MHz range
__enable_interrupt( );
for ( ; ; ) {
//P7OUT ^= 0x01; // using XOR toggles the pin value.
P7OUT = 0x01; // LED ON.
for ( timer_event= false; !timer_event; )
P7OUT = 0x00; // LED OFF;
else
for ( ; ; ) {
P7OUT = 0x00; // LED OFF.
}
return 0;
}
}
TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
//TACCR0= 19999; // 10ms intervals.[change here for 15 seconds or 30 seconds delay]
TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
//TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
#pragma vector= TIMERA0_VECTOR
__interrupt void timer_A2( void ) {
timer_event= true;
return 0;
}
}
============================--- In m..., "shskurkra" wrote:
>
> The code to turn LED ON and OFF for interrupts; The program is good, please let me know.
> Thank you
> =======> PROGRAM
> =======> #include
> static volatile bool timer_event;
>
> int main( ) {
>
> WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
>
> P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
>
> P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
>
> BCSCTL1= CALBC1_8MHZ;
> DCOCTL= CALDCO_8MHZ;
> __enable_interrupt( );
>
> for ( ; ; ) {
> //P7OUT ^= 0x01; // using XOR toggles the pin value.
> P7OUT = 0x01; // LED ON.
> for ( timer_event= false; !timer_event; )
> P7OUT = 0x00; // LED OFF;
> else
> for ( ; ; ) {
> P7OUT = 0x00; // LED OFF.
> }
>
> return 0;
> }
> TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
> TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
> TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
> TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
>
> #pragma vector= TIMERA0_VECTOR
> __interrupt void timer_A2( void ) {
> timer_event= true;
> return;
> }
> ========> ========> --- In m..., "Bob" wrote:
> >
> > >can I simulate Assembly code and C
> > >written code together in code composer studio v4.
> > Sorry, I don't know the answer to that...
> >
> > --- In m..., Shreyas Kumar Krishnappa wrote:
> > >
> > > The example is 8.18. One question, can I simulate Assembly code and C
> > > written code together in code composer studio v4.
> > >
> > >
> > > On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
> > >
> > > >
> > > >
> > > > I've not had need to write such routines, but I believe I've seen them in
> > > > John Davies' text on the MSP430 (
> > > > http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> > > > and if I remember correctly, the code examples can be downloaded.
> > > >
> > > >
> > > > --- In m... , "shskurkra"
> > > > wrote:
> > > > >
> > > > > Thanks Bob, for your potential feedback. How about turning LED ON from
> > > > dim to bright and vice versa.
> > > > > I looked through PWM continuous signal.
> > > > > Do you have an alternative method like altering duty cycle for certain
> > > > seconds to start LED from dim to certain brightness.
> > > > >
> > > > >
> > > > > --- In m... , "Bob"
> > > > wrote:
> > > > > >
> > > > > > shskurkra,
> > > > > >
> > > > > > You might simply use two interrupt routines. One for your button, a
> > > > second one tied to a timer of your choice. On a button press, if the LED is
> > > > off, turn it on and start a timer running that will trigger a second
> > > > interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> > > > is on when the button's pressed, turn it and the timer off.
> > > > > >
> > > > > > So, if the user presses the button only once, LED stays on for one
> > > > minute and then turns off. If the user presses the button a second time in
> > > > less than a minute, LED turns off. No loops, and you can run in a pretty low
> > > > power mode waiting for the initial button press. HTH
> > > > > >
> > > > > >
> > > > > > --- In m... , "shskurkra"
> > > > wrote:
> > > > > > >
> > > > > > > Designing a project based on LED to ON and OFF based on interrupt
> > > > from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> > > > and soft-start LED OFF. Can anyone give some ideas.
> > > > > > >
> > > > > > > LED switches ON - for interrupt
> > > > > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> > > > minute wait, momentary switch is pressed LED should switch OFF.
> > > > > > >
> > > > > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > > > > From those I came up with some sort of coding technique.
> > > > > > >
> > > > > > > The best I can think is:-
> > > > > > > 1. Define P1.DIR as output pin.
> > > > > > > 2. connect momentary switch to pin 7.
> > > > > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> > > > switch ON.
> > > > > > > 4. Once LED is switched ON, insert another if loop to receive
> > > > interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> > > > wait for 1 minute to switch LED OFF automatically.
> > > > > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> > > > parallel with 10K resistor.
> > > > > > > 6. Supply voltage is connected directly to MSP430.
> > > > > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> > > > and drain of MOSFET.
> > > > > > >
> > > > > > > I'm new to MSP430. Using Code composer studio for simulation and
> > > > debug.
> > > > > > >
> > > > > > > Waiting for your replies.
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
>
Reply by ●April 30, 20102010-04-30
Hi Bob, I tried to execute the code, but I have errors. Regarding "bool", the
number "59999999" . Does anybody can give me ideas to debug this program.
Thank you.
===========#include
static volatile bool timer_event;
int main( ) {
WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
//BCSCTL1= CALBC1_16MHZ;
//DCOCTL= CALDCO_16MHZ;
BCSCTL1= CALBC1_16MHZ;
DCOCTL= CALDCO_16MHZ;
// BCSCTL1= XT2OFF | RSEL3 | RSEL2 | RSEL1 | RSEL0; // Microcontroller runs at faster rate at 16MHz range
// DCOCTL= DCO2 | DCO1 | DCO0; // Microcontroller runs at faster rate 16MHz range
__enable_interrupt( );
for ( ; ; ) {
//P7OUT ^= 0x01; // using XOR toggles the pin value.
P7OUT = 0x01; // LED ON.
for ( timer_event= false; !timer_event; )
P7OUT = 0x00; // LED OFF;
else
for ( ; ; ) {
P7OUT = 0x00; // LED OFF.
}
return 0;
}
}
TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
//TACCR0= 19999; // 10ms intervals.[change here for 15 seconds or 30 seconds delay]
TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
#pragma vector= TIMERA0_VECTOR
__interrupt void timer_A2( void ) {
timer_event= true;
return 0;
}
}
=======
--- In m..., "shskurkra" wrote:
>
> The code for LED ON and OFF. Managed to write, but not sure about the for loop part errors. Please let me know. Thank you.
> ========> PROGRAM
> ========> #include
> static volatile bool timer_event;
>
> int main( ) {
>
> WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
>
> P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
>
> P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
>
> BCSCTL1= CALBC1_8MHZ;
> DCOCTL= CALDCO_8MHZ;
>
> __enable_interrupt( );
>
> for ( ; ; ) {
> //P7OUT ^= 0x01; // using XOR toggles the pin value.
> P7OUT = 0x01; // LED ON.
> for ( timer_event= false; !timer_event; )
> P7OUT = 0x00; // LED OFF;
> else
> for ( ; ; ) {
> P7OUT = 0x00; // LED OFF.
> }
>
> return 0;
> }
> TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
> TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
> TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
> TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
> #pragma vector= TIMERA0_VECTOR
> __interrupt void timer_A2( void ) {
> timer_event= true;
> return;
> }
> ================> --- In m..., "Bob" wrote:
> >
> > >can I simulate Assembly code and C
> > >written code together in code composer studio v4.
> > Sorry, I don't know the answer to that...
> >
> > --- In m..., Shreyas Kumar Krishnappa wrote:
> > >
> > > The example is 8.18. One question, can I simulate Assembly code and C
> > > written code together in code composer studio v4.
> > >
> > >
> > > On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
> > >
> > > >
> > > >
> > > > I've not had need to write such routines, but I believe I've seen them in
> > > > John Davies' text on the MSP430 (
> > > > http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> > > > and if I remember correctly, the code examples can be downloaded.
> > > >
> > > >
> > > > --- In m... , "shskurkra"
> > > > wrote:
> > > > >
> > > > > Thanks Bob, for your potential feedback. How about turning LED ON from
> > > > dim to bright and vice versa.
> > > > > I looked through PWM continuous signal.
> > > > > Do you have an alternative method like altering duty cycle for certain
> > > > seconds to start LED from dim to certain brightness.
> > > > >
> > > > >
> > > > > --- In m... , "Bob"
> > > > wrote:
> > > > > >
> > > > > > shskurkra,
> > > > > >
> > > > > > You might simply use two interrupt routines. One for your button, a
> > > > second one tied to a timer of your choice. On a button press, if the LED is
> > > > off, turn it on and start a timer running that will trigger a second
> > > > interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> > > > is on when the button's pressed, turn it and the timer off.
> > > > > >
> > > > > > So, if the user presses the button only once, LED stays on for one
> > > > minute and then turns off. If the user presses the button a second time in
> > > > less than a minute, LED turns off. No loops, and you can run in a pretty low
> > > > power mode waiting for the initial button press. HTH
> > > > > >
> > > > > >
> > > > > > --- In m... , "shskurkra"
> > > > wrote:
> > > > > > >
> > > > > > > Designing a project based on LED to ON and OFF based on interrupt
> > > > from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> > > > and soft-start LED OFF. Can anyone give some ideas.
> > > > > > >
> > > > > > > LED switches ON - for interrupt
> > > > > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> > > > minute wait, momentary switch is pressed LED should switch OFF.
> > > > > > >
> > > > > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > > > > From those I came up with some sort of coding technique.
> > > > > > >
> > > > > > > The best I can think is:-
> > > > > > > 1. Define P1.DIR as output pin.
> > > > > > > 2. connect momentary switch to pin 7.
> > > > > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> > > > switch ON.
> > > > > > > 4. Once LED is switched ON, insert another if loop to receive
> > > > interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> > > > wait for 1 minute to switch LED OFF automatically.
> > > > > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> > > > parallel with 10K resistor.
> > > > > > > 6. Supply voltage is connected directly to MSP430.
> > > > > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> > > > and drain of MOSFET.
> > > > > > >
> > > > > > > I'm new to MSP430. Using Code composer studio for simulation and
> > > > debug.
> > > > > > >
> > > > > > > Waiting for your replies.
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
>
Thank you.
===========#include
static volatile bool timer_event;
int main( ) {
WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
//BCSCTL1= CALBC1_16MHZ;
//DCOCTL= CALDCO_16MHZ;
BCSCTL1= CALBC1_16MHZ;
DCOCTL= CALDCO_16MHZ;
// BCSCTL1= XT2OFF | RSEL3 | RSEL2 | RSEL1 | RSEL0; // Microcontroller runs at faster rate at 16MHz range
// DCOCTL= DCO2 | DCO1 | DCO0; // Microcontroller runs at faster rate 16MHz range
__enable_interrupt( );
for ( ; ; ) {
//P7OUT ^= 0x01; // using XOR toggles the pin value.
P7OUT = 0x01; // LED ON.
for ( timer_event= false; !timer_event; )
P7OUT = 0x00; // LED OFF;
else
for ( ; ; ) {
P7OUT = 0x00; // LED OFF.
}
return 0;
}
}
TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
//TACCR0= 19999; // 10ms intervals.[change here for 15 seconds or 30 seconds delay]
TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
#pragma vector= TIMERA0_VECTOR
__interrupt void timer_A2( void ) {
timer_event= true;
return 0;
}
}
=======
--- In m..., "shskurkra" wrote:
>
> The code for LED ON and OFF. Managed to write, but not sure about the for loop part errors. Please let me know. Thank you.
> ========> PROGRAM
> ========> #include
> static volatile bool timer_event;
>
> int main( ) {
>
> WDTCTL= WDTPW + WDTHOLD; // turn off the watchdog timer.
>
> P2DIR |= 0x00; // Set P2.0 to input direction, that is bit 0 is turned to input
>
> P7DIR |= 0x01; // Set P7.0 to output direction, that is bit 0 is turned to output
>
> BCSCTL1= CALBC1_8MHZ;
> DCOCTL= CALDCO_8MHZ;
>
> __enable_interrupt( );
>
> for ( ; ; ) {
> //P7OUT ^= 0x01; // using XOR toggles the pin value.
> P7OUT = 0x01; // LED ON.
> for ( timer_event= false; !timer_event; )
> P7OUT = 0x00; // LED OFF;
> else
> for ( ; ; ) {
> P7OUT = 0x00; // LED OFF.
> }
>
> return 0;
> }
> TACTL= MC_0 | TASSEL_2 | ID_3 | TACLR; // reset it, first.
> TACCTL0= CM_0 | CCIS_2 | SCS | OUTMOD_1 | CCIE; // set the mode.
> TACCR0= 59999999; // For 15 seconds 29999999 or 30 seconds 59999999 delay]
> TACTL= MC_1 | TASSEL_2 | ID_3; // turn it off.
> #pragma vector= TIMERA0_VECTOR
> __interrupt void timer_A2( void ) {
> timer_event= true;
> return;
> }
> ================> --- In m..., "Bob" wrote:
> >
> > >can I simulate Assembly code and C
> > >written code together in code composer studio v4.
> > Sorry, I don't know the answer to that...
> >
> > --- In m..., Shreyas Kumar Krishnappa wrote:
> > >
> > > The example is 8.18. One question, can I simulate Assembly code and C
> > > written code together in code composer studio v4.
> > >
> > >
> > > On Thu, Apr 15, 2010 at 11:13 PM, Bob wrote:
> > >
> > > >
> > > >
> > > > I've not had need to write such routines, but I believe I've seen them in
> > > > John Davies' text on the MSP430 (
> > > > http://www.amazon.com/MSP430-Microcontroller-Basics-John-Davies/dp/0750682760),
> > > > and if I remember correctly, the code examples can be downloaded.
> > > >
> > > >
> > > > --- In m... , "shskurkra"
> > > > wrote:
> > > > >
> > > > > Thanks Bob, for your potential feedback. How about turning LED ON from
> > > > dim to bright and vice versa.
> > > > > I looked through PWM continuous signal.
> > > > > Do you have an alternative method like altering duty cycle for certain
> > > > seconds to start LED from dim to certain brightness.
> > > > >
> > > > >
> > > > > --- In m... , "Bob"
> > > > wrote:
> > > > > >
> > > > > > shskurkra,
> > > > > >
> > > > > > You might simply use two interrupt routines. One for your button, a
> > > > second one tied to a timer of your choice. On a button press, if the LED is
> > > > off, turn it on and start a timer running that will trigger a second
> > > > interrupt at 60 seconds to turn the LED off and stop the timer. If the LED
> > > > is on when the button's pressed, turn it and the timer off.
> > > > > >
> > > > > > So, if the user presses the button only once, LED stays on for one
> > > > minute and then turns off. If the user presses the button a second time in
> > > > less than a minute, LED turns off. No loops, and you can run in a pretty low
> > > > power mode waiting for the initial button press. HTH
> > > > > >
> > > > > >
> > > > > > --- In m... , "shskurkra"
> > > > wrote:
> > > > > > >
> > > > > > > Designing a project based on LED to ON and OFF based on interrupt
> > > > from momentary switch. Using F2013 kit. I have stuck with soft-start LED ON
> > > > and soft-start LED OFF. Can anyone give some ideas.
> > > > > > >
> > > > > > > LED switches ON - for interrupt
> > > > > > > LED is in ON state for 1 min and automatically switches OFF. During 1
> > > > minute wait, momentary switch is pressed LED should switch OFF.
> > > > > > >
> > > > > > > I have gone through sampleEZ codes posted in "Files" section.
> > > > > > > From those I came up with some sort of coding technique.
> > > > > > >
> > > > > > > The best I can think is:-
> > > > > > > 1. Define P1.DIR as output pin.
> > > > > > > 2. connect momentary switch to pin 7.
> > > > > > > 3. write an "if" loop to accept interrupt from pin7 and LED starts to
> > > > switch ON.
> > > > > > > 4. Once LED is switched ON, insert another if loop to receive
> > > > interrupt from momentary switch to turn LED OFF in that 1 minute duration or
> > > > wait for 1 minute to switch LED OFF automatically.
> > > > > > > 5. I have connected N-channel MOSFET to receive output from MSP430 in
> > > > parallel with 10K resistor.
> > > > > > > 6. Supply voltage is connected directly to MSP430.
> > > > > > > 7. LED is connected directly to supply voltage with 100 ohm resistor
> > > > and drain of MOSFET.
> > > > > > >
> > > > > > > I'm new to MSP430. Using Code composer studio for simulation and
> > > > debug.
> > > > > > >
> > > > > > > Waiting for your replies.
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
>