Jump to content
43oh

Recommended Posts

And I just wanted to know if the following:

And I just wanted to know if the following:

 

#deta3agu.jpg

 

#a5uhage5.jpg

 

Are they built-in..?

If so, could you please help me sort it out to understand the presence of Vcc and ground that they talk about in the two different situations?

You may just encircle them in the MSP430 that I have initially put in the blog?

Link to post
Share on other sites

You have been told before not to add a post to the bottom if the one before is your as well, instead, use the edit function to append to your post.

You're on the right track, it does indeed cost some effort to "switch" an output from 0 (0 volts) to 1 (3.6 volts). The whole idea is that electronics can influence each other through control voltages or currents. To switch an output pin from 0 volts to 3.6 volts a conductive path to ground must be broken (more accurately, be hard to flow current through or get a high resistance) while a path to Vcc (a voltage acquired indirectly from the USB plug) must be made (or more accurately, be easy to flow current through or get a low resistance).

Such switching behaviour is made possible by means of so called transistors (just do a search on the web for more information on transistors); when some small internal signal becomes high, the output on the pin will become high as well and similar for low.

Switching from ground to Vcc costs some effort, this effort is apparent in the form of heat produced (electrical power is "burned") in the transistors, that's why modern computers need such good cooling; they have so many transistors that switch so often that a very significant part of the power fed to them is turned into heat. The effort is physical in nature, but not mechanical. The control is done by saturating or depleting a part of the transistor with electrons, a substance that in it's very definition is controllable with electricity (more accurately, electricity is the manipulation of electrons).

 

Pull-up and pull-down resistors are built into the msp430, but you'll need to enable them. Otherwise the pins have a very low impedance when in output mode, which would cause a short out in the msp430 damaging the microcontroller in the chip package.

Link to post
Share on other sites

Ya, I got it.. Thanks!! And your explanation was sooo edible...! Motivates me to learn more...! Thanks...!

 

I just have some doubts with me:

 

# I just need to know about CCR0 value.. On choosing SMCLK, we know that without prescaling, it runs at 1 MHz frequency, and that value which we assign it for CCR0, is that the time until which the clock would keep counting up? Or it's something more...? Because maximum of CCR0 would take up value of only 65535, what does that indicate?

How to go about that if I need my timer to count upto 20 seconds?

 

#I just get confused with frequency of the timer, the interval with which timer is ticking, it's dependency over frequency( since 1/frequency is the time period, won't it be 1microsecond)?

 

# when I keep my outmode 5, i.e., Reset... When the required count suppose CCR0 has reached 19,( as in my case I wanted the timer to count until 20 seconds), after which the timer sets to 0 right?

Is there any code or any statement to check if the timer has reached 0?

 

#And once this condition is reached like setting back to 0, if I press the reset button, the timer would start counting from first according to my code right?

 

4eqe2e9u.jpg

 

This is for reference.

 

# My aim is to make the LEDs glow once after 20 seconds have passed, and during the time I would keep pressing the push button, and suppose I press it 8 times in those 20 seconds, my leds that I've connected in the breadboard using jumper wires should glow like 1000,

i.e., Led1 : on

Led2 : off

Led3 : off

Led4 : off

 

For this I connected P1.0, P1.1, P1.2 and P1.4 for my outputs in sequence.

And anodic parts of which I connected in the line connecting the wire to the ground part on the right side of the launchpad.

 

# Except for the timer part, the rest of the coding is as contained in this:

https://www.dropbox.com/s/9uva0e57cbtfhp2/CODING%20FOR%20HARDWARE%20TASK.docx

 

# For the switch debouncing, I used software debouncing wherein the principle is like:

Enable external interrupt and when interrupt occurs, increment a static variable j that initially was 0, and make another static variable k which was 0 initially to be 1, and during interrupt in it's rising edge, call for the watchdog timer for 32ms stay up, so during this time the switch debouncing would be cleared which is considered to be of the range of maximum 10-20ms. Then when watchdog completes it's cycle enable external interrupt. And during this time if switch is released, falling edge occurs, interrupt is enabled, j again increments, and k is made to be 1 and conditions are included again and the process continues.

 

The variable k is initialised in order to check up with the state of the switch. Initially it's 0, meaning it's unpressed. And the code follows.

Link to post
Share on other sites
  • 2 weeks later...

Ya, I got it.. Thanks!! And your explanation was sooo edible...! Motivates me to learn more...! Thanks...!

 

I just have some doubts with me:

 

# I just need to know about CCR0 value.. On choosing SMCLK, we know that without prescaling, it runs at 1 MHz frequency, and that value which we assign it for CCR0, is that the time until which the clock would keep counting up? Or it's something more...? Because maximum of CCR0 would take up value of only 65535, what does that indicate?

How to go about that if I need my timer to count upto 20 seconds?

 

As the basis for my answers, I'll use the family guide. This very useful document contains most answers you'll be looking for.

Assuming you have SMCLK set to run at 1 MHz (the default) and you have set your timer prescaler to 1, CCR0 will be able to count up to 65536/1MHz = 65536 us (microseconds) or 65.536 ms.

This is depicted in Figure 12-3 on page 359 of the family guide; the counter starts at 0 and counts up to and including CCR0, so 0 up to and including 65535 with the max value for CCR0.

 

If you want a larger time period there are a few solutions:

- use a slower source for your timer clock

- count a number of cycles of the timer overflow

- use multiple timers

 

First let's slow the timer clock down by selecting SMCLK/8 as clock source, instead of SMCLK/1.

As visible in Figure 12-1 on page 357 of the family guide, this is done by changing the IDx value. In section 12.3.1 we find these bits to be part of TACTL. So we can use that to slow the timer clock by a factor 8. Now instead of 65.536 ms we can count up to 524.288 ms or about half a second.

Now we can use an interrupt on the timer overflow to count 38 of those periods culminating to 38 * 524.288 = 19922.944 ms or about 19.9 seconds.

 

Instead of using SMCLK we could also use ACLK, which may be an internal very lowpower oscillator (about 12kHz) or an external watch crystal (at 32768 Hz). As seen in Figure 12-1 we need to set TASSEL from 00 to 01. Now we can count to exactly 2.0 seconds when not using IDx to set the prescaler. With prescaler we can count up to 2 * 8 = 16 seconds. Would we want to count to 20 seconds, you could either count 10 periods of 2 seconds, or use ACLK/2 to count 5 periods of 4 seconds.

 

One last option might be to use the Watchdog timer instead of TimerA. You cannot set how much if counted by the watchdog timer, but you can set the prescaler to 32768, so you can create a 1 second timer when using a crystal in combination with the watchdog timer.

 

 

#I just get confused with frequency of the timer, the interval with which timer is ticking, it's dependency over frequency( since 1/frequency is the time period, won't it be 1microsecond)?

Yes. The timer increment will be updated once every 1/timer clock second. So for a clock at 1MHz the period will be 1us.

 

# when I keep my outmode 5, i.e., Reset... When the required count suppose CCR0 has reached 19,( as in my case I wanted the timer to count until 20 seconds), after which the timer sets to 0 right?

Not exactly. Setting CCR0 to 19 will let your timer count to 20 microseconds, not 20 seconds. After that the timer will be set to 0 and count up again. So It will be set to 0 every 20 microseconds.

OUTMOD5 is not related to this set to 0 behaviour, OUTMOD5 means that for the given output (for example, the output related to CCR1), the signal will go low when the timer reaches the value set in the corresponding CCR register (and it will never go high again). You could for example use modes 2, 3, 6 and 7 for PWM behaviour, or mode 4 for a frequency generator. Mode 0 means the pin is set to GPIO instead of timer output and mode 1 and 5 are only useful if you want to set or clear an output on a very strict time delay, but not for pulsing.

 

Is there any code or any statement to check if the timer has reached 0?

You can use interrupts to trigger a section of code whenever CCR0 is reached.

 

#And once this condition is reached like setting back to 0, if I press the reset button, the timer would start counting from first according to my code right?

I haven't looked into your code yet. But if you press your reset button, the pin will be set up according to your initialisation code, or to input if you omitted such code. After you start the timer, your pin will (given you set it to timer output) go/stay low when the timer reaches the corresponding CCR value again.

4eqe2e9u.jpg

 

This is for reference.

 

# My aim is to make the LEDs glow once after 20 seconds have passed, and during the time I would keep pressing the push button, and suppose I press it 8 times in those 20 seconds, my leds that I've connected in the breadboard using jumper wires should glow like 1000,

i.e., Led1 : on

Led2 : off

Led3 : off

Led4 : off

 

For this I connected P1.0, P1.1, P1.2 and P1.4 for my outputs in sequence.

And anodic parts of which I connected in the line connecting the wire to the ground part on the right side of the launchpad.

 

# Except for the timer part, the rest of the coding is as contained in this:

https://www.dropbox.com/s/9uva0e57cbtfhp2/CODING%20FOR%20HARDWARE%20TASK.docx

Alright, you want to count the number of button presses during the initial 20 seconds, and then display that count value thereafter. Is that correct?

Your LEDs should be connected with the cathode to the ground orthe anode to Vcc. Since LEDs have a forward current from anode to cathode. Make sure to use resistors to limit the current.

 

# For the switch debouncing, I used software debouncing wherein the principle is like:

Enable external interrupt and when interrupt occurs, increment a static variable j that initially was 0, and make another static variable k which was 0 initially to be 1, and during interrupt in it's rising edge, call for the watchdog timer for 32ms stay up, so during this time the switch debouncing would be cleared which is considered to be of the range of maximum 10-20ms. Then when watchdog completes it's cycle enable external interrupt. And during this time if switch is released, falling edge occurs, interrupt is enabled, j again increments, and k is made to be 1 and conditions are included again and the process continues.

 

The variable k is initialised in order to check up with the state of the switch. Initially it's 0, meaning it's unpressed. And the code follows.

Debouncing is always tricky, your principle sound okay, assuming you have indeed less than 32ms bounce time. Note that is you use the watchdog for this, you cannot use it for the timer I described. Very careful engineering may allow you to doubly use peripherals, but in this case you cannot.

 

I'll have a look at your code, but I will not provide you with fully functioning code. That's what you can do yourself :-)

Also, since you're not using the timer for PWM or any output at all, don't bother about the OUTMOD value, since it is only useful for outputs. In your case you use it purely as a timer.

I hope you can use some of my notes :)

Link to post
Share on other sites

Sir..... Thank you soooooo much!!! I've got it done!!! It's blinking exactly after 20 seconds...

 

First video that I took!!:

 

 

And I used hardware switch debouncing using a resistor to connect to Vcc from P1.3, and a capacitor from P1.3 to ground getting it quite easier...

 

 

 

02/07/14:

 

I have a query:

 

Is there any simulation software available for MSP430 G2553 and CCSv5 for it's coding in Windows 8?? And if so, could you provide me a link which could help me free download ?

I saw @@bluehash referring to QSimKit in other post, but is that fine for the above specifics?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...