| Newsgroups |
gmane.comp.hardware.texas-instruments.msp430.discuss |
| Message-ID |
<[email protected]> |
--------------26C53F13BC0B4441625CA9BB
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
First you don't use DCOCTL and BSCCTL, these are for the DCO or
digitally controlled oscillator, and the basic clock module. these
govern the instruction execution rate, the peripheral to use is the
timer, and there are many ways to do it using the timer. Secondly make
sure you are you using a speaker not a piezo sounder. Often they are
badly described in catalogues. A sounder will always have the same
tone. Do you want the sounds to run for a fixed time or is one sound
always on? The MSP430 has quite powerful timer control functions. The
basic timer functions, like clock source, clock division, start, stop,
and count mode are set in the TxCTL register while each timer channel
has its own control register so that each channel could be running a
different timer function. The 2553 spoils you for choice, you have 2 3
channel timers of Type A. In the channel control register you can
control what happens to that channels assigned output pin when the timer
match occurs, so, for example set TimerA0_0 (timer type A number 0
channel 0) so that it interrupts after a desired time, and when it
interrupts it toggles its output pin, this generates a square wave, and
all you then need do is decide the time period, create a small ISR which
simple adds the time period to generate the desired frequenct to that
channels CCRx register, and, make sure the interrupt flag is cleared.
CH0 clears the iFG automatically, and has it's own interrupt vector, if
you use ch1 or ch2 you will need to use the TAIV vector to select the
right channel ISR. This works well in continuous mode. If you need to
recude the timer maximum count for any reason, for example it is running
an RTC and you want it to only count to 32768 your isr will need to
account for this.
If you only want the timer tone to run for a certain time then start a
second timer at the same time yoiu enable to frequency output and have
its ISR stop both timers and set the output pin of the tone output to '0'.
It's worthwhile studying and playing around with the timers, as well as
reading every app note you can get. If you truly understand how these
timers work you can do almost anything with a small micro. For example
people compare the blinky LED to 'Hello World' on a PC or high level
language, but in fact it's much more potent than that, more akin to a
sensor and communications toolkit in a few easy registers.
Al
On 18/11/2016 5:08 AM, [email protected] [msp430] wrote:
>
>
> Hello, my name is Trevor! I was wondering if anyone could help me
> generate 3 different sounds using a piezo speaker on a msp430 using
> only assembly language. I understand these different 3 sounds are
> different frequencies and are thus controlled by DCOCTL and the
> different BSCCTL registers. In theory, I believed a jump statement
> could go to different labels where the settings of the registers and
> the DCOCTL could be changed ,however i keep getting the same output sound.
>
>
>
>
--------------26C53F13BC0B4441625CA9BB
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<head>
<style type="text/css">
<!--
/* start of attachment style */
.ygrp-photo-title{
clear: both;
font-size: smaller;
height: 15px;
overflow: hidden;
text-align: center;
width: 75px;
}
div.ygrp-photo{
background-position: center;
background-repeat: no-repeat;
background-color: white;
border: 1px solid black;
height: 62px;
width: 62px;
}
div.photo-title
a,
div.photo-title a:active,
div.photo-title a:hover,
div.photo-title a:visited {
text-decoration: none;
}
div.attach-table div.attach-row {
clear: both;
}
div.attach-table div.attach-row div {
float: left;
/* margin: 2px;*/
}
p {
clear: both;
padding: 15px 0 3px 0;
overflow: hidden;
}
div.ygrp-file {
width: 30px;
valign: middle;
}
div.attach-table div.attach-row div div a {
text-decoration: none;
}
div.attach-table div.attach-row div div span {
font-weight: normal;
}
div.ygrp-file-title {
font-weight: bold;
}
/* end of attachment style */
-->
</style>
</head>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<!-- |**|begin egp html banner|**| -->
<br><br>
<!-- |**|end egp html banner|**| -->
<font size="-1">First you don't use DCOCTL and BSCCTL, these are for
the DCO or digitally controlled oscillator, and the basic clock
module. these govern the instruction execution rate, the
peripheral to use is the timer, and there are many ways to do it
using the timer. Secondly make sure you are you using a speaker
not a piezo sounder. Often they are badly described in catalogues.
A sounder will always have the same tone. Do you want the sounds
to run for a fixed time or is one sound always on? The MSP430 has
quite powerful timer control functions. The basic timer functions,
like clock source, clock division, start, stop, and count mode are
set in the TxCTL register while each timer channel has its own
control register so that each channel could be running a different
timer function. The 2553 spoils you for choice, you have 2 3
channel timers of Type A. In the channel control register you can
control what happens to that channels assigned output pin when the
timer match occurs, so, for example set TimerA0_0 (timer type A
number 0 channel 0) so that it interrupts after a desired time,
and when it interrupts it toggles its output pin, this generates a
square wave, and all you then need do is decide the time period,
create a small ISR which simple adds the time period to generate
the desired frequenct to that channels CCRx register, and, make
sure the interrupt flag is cleared. CH0 clears the iFG
automatically, and has it's own interrupt vector, if you use ch1
or ch2 you will need to use the TAIV vector to select the right
channel ISR. This works well in continuous mode. If you need to
recude the timer maximum count for any reason, for example it is
running an RTC and you want it to only count to 32768 your isr
will need to account for this.<br>
<br>
If you only want the timer tone to run for a certain time then
start a second timer at the same time yoiu enable to frequency
output and have its ISR stop both timers and set the output pin of
the tone output to '0'.<br>
<br>
It's worthwhile studying and playing around with the timers, as
well as reading every app note you can get. If you truly
understand how these timers work you can do almost anything with a
small micro. For example people compare the blinky LED to 'Hello
World' on a PC or high level language, but in fact it's much more
potent than that, more akin to a sensor and communications toolkit
in a few easy registers.<br>
<br>
<br>
Al<br>
</font><br>
<div class="moz-cite-prefix">On 18/11/2016 5:08 AM,
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a> [msp430] wrote:<br>
</div>
<blockquote cite="mid:[email protected]" type="cite">
<meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
<br>
<br>
<p><span>Hello, my name is Trevor! I was wondering if anyone could
help me generate 3 different sounds using a piezo speaker on a
msp430 using only assembly language. I understand these
different 3 sounds are different frequencies and are thus
controlled by DCOCTL and the different BSCCTL registers. In
theory, I believed a jump statement could go to different
labels where the settings of the registers and the DCOCTL
could be changed ,however i keep getting the same output
sound.</span></p>
<br>
<br>
<div width="1"></div>
</blockquote>
<br>
<!-- |**|begin egp html banner|**| -->
<br>
<br>
<!-- |**|end egp html banner|**| -->
<div width="1" style="color: white; clear: both;"/>__._,_.___</div>
<div id="fromDMARC" style="clear:both; margin-top: 10px;">
<hr style="height:2px ; border-width:0; color:#E3E3E3; background-color:#E3E3E3;">
Posted by: Onestone <[email protected]> <hr style="height:2px ; border-width:0; color:#E3E3E3; background-color:#E3E3E3;">
</div>
<!-- Start Recommendations -->
<!-- End Recommendations -->
<!-- |**|begin egp html banner|**| -->
<br><br>
<tt>
To unsubscribe from the msp430 group, send an email to:<BR>
[email protected]<BR>
<BR>
</tt>
<br><br>
<!-- |**|end egp html banner|**| -->
<!-- |**|begin egp html banner|**| -->
<img src="http://geo.yahoo.com/serv?s=97476590/grpId=2342629/grpspId=1705005378/msgId=52531/stime=1479411532" width="1" height="1"> <br>
<!-- |**|end egp html banner|**| -->
<!-- |**|begin egp html banner|**| -->
<br>
<!-- |**|begin egp html banner|**| -->
<div id="ygrp-vital" style="background-color: #f2f2f2; font-family: Verdana; font-size: 10px; margin-bottom: 10px; padding: 10px;">
<span id="vithd" style="font-weight: bold; color: #333; text-transform: uppercase; "><a href="https://groups.yahoo.com/neo/groups/msp430/info;_ylc=X3oDMTJlb2NjNG9pBF9TAzk3MzU5NzE0BGdycElkAzIzNDI2MjkEZ3Jwc3BJZAMxNzA1MDA1Mzc4BHNlYwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTQ3OTQxMTUzMg--" style="text-decoration: none;">Visit Your Group</a></span>
<ul style="list-style-type: none; margin: 0; padding: 0; display: inline;">
<li style="border-right: 1px solid #000; font-weight: 700; display: inline; padding: 0 5px; margin-left: 0;">
<span class="cat"><a href="https://groups.yahoo.com/neo/groups/msp430/members/all;_ylc=X3oDMTJmMnFqbjM5BF9TAzk3MzU5NzE0BGdycElkAzIzNDI2MjkEZ3Jwc3BJZAMxNzA1MDA1Mzc4BHNlYwN2dGwEc2xrA3ZtYnJzBHN0aW1lAzE0Nzk0MTE1MzI-" style="text-decoration: none;">New Members</a></span>
<span class="ct" style="color: #ff7900;">1</span>
</li>
</ul>
</div>
<div id="ft" style="font-family: Arial; font-size: 11px; margin-top: 5px; padding: 0 2px 0 0; clear: both;">
<a href="https://groups.yahoo.com/neo;_ylc=X3oDMTJkOWlzYWEwBF9TAzk3NDc2NTkwBGdycElkAzIzNDI2MjkEZ3Jwc3BJZAMxNzA1MDA1Mzc4BHNlYwNmdHIEc2xrA2dmcARzdGltZQMxNDc5NDExNTMy" style="float: left;"><img src="http://l.yimg.com/ru/static/images/yg/img/email/new_logo/logo-groups-137x15.png" height="15" width="137" alt="Yahoo! Groups" style="border: 0;"/></a>
<div style="color: #747575; float: right;"> • <a href="https://info.yahoo.com/privacy/us/yahoo/groups/details.html" style="text-decoration: none;">Privacy</a> • <a href="mailto:[email protected]?subject=Unsubscribe" style="text-decoration: none;">Unsubscribe</a> • <a href="https://info.yahoo.com/legal/us/yahoo/utos/terms/" style="text-decoration: none;">Terms of Use</a> </div>
</div>
<!-- |**|end egp html banner|**| -->
</div> <!-- ygrp-msg -->
<br>
<!-- |**|end egp html banner|**| -->
<div style="color: white; clear: both;"/>__,_._,___</div>
</body>
</html>
--------------26C53F13BC0B4441625CA9BB--