We now define an interrupt vector. When a timer interrupt occurs, it runs the code defined in the interrupt routine. Take a look at the Interrupt routine.
#include <msp430x14x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P6DIR |= 0x08; // P6.3 Set P6.3 to output
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 60000;
TACTL = TASSEL_2 + MC_2; // SMCLK, contmode
_BIS_SR(GIE); // Enable interrupt
}
// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
P6OUT ^= 0×08; // Toggle P6.3
CCR0 += 60000; // Add Offset to CCR0
}
If you run this code you and observe the signal, you get a screen shot something similar to

Some Experiments
Here are some experiments you can do.
1. Try changing
CCR0 += 60000;
to
CCR0 += 30000;
and you will observe that time period becomes half. Changing it to CCR0 += 6000; will reduce it to 1/10th.
2. If you want a slower timer, you may change the
TACTL = TASSEL_2 + MC_2;
to
TACTL = TASSEL_1 + MC_2;
Which will change the clock from SMCLK ( derived from 4 MHz) to ACLK ( derived from 32.768 KHz).
3. If you change
TACTL = TASSEL_2 + MC_2 ;
to
TACTL = TASSEL_2 + MC_2 + ID_1;
it doubles the time period ( by by halving the clock period used for timer interrupt). Bit 7-6 defines it.
IDx Bits
00 divide by 1
01 divide by 2
10 divide by 4
11 divide by 8
Uncategorized
Add three more lines in the main programs ( highlighted in red).
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P6DIR |= 0x08; // P6.3 Set P6.3 to output
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 60000;
TACTL = TASSEL_2 + MC_2; // SMCLK, contmode
_BIS_SR(GIE); // Enable interrupt
}
Let is now try to understand the code one by one..
CCTL0 Register
If you plan to use a Timer, the first register that you need to set is CCTL0. It is a 16 bit register and settings of this register effects how we use the register. For our purpose we just tell it to enable the interrupt using
CCTL0 = CCIE;
Notice that we have not yet enabled the timer.
CCR0
This register will define the amount of time after which the timer event will occur. We have set it to
CCR0 = 60000;
TACTL
Bit 9-8 selects the source of the clock
The Possible values are
00 TACLK
01 ACLK
10 SMCLK
11 INCLK
We have basically selected the SMCLK which is a 4 MHz clock in our case.
The bits 5-4 selects how the counting. Possible values are
00 Stop mode: the timer is halted
01 Up mode: the timer counts up to TACCR0
10 Continuous mode: the timer counts up to 0FFFFh
11 Up/down mode: the timer counts up to TACCR0 then down to 0000h
We have selected 10 which makes the counter count upto 0FFFFh
Enable General Interrupt
Finally we have to enable the general interrupt using.
_BIS_SR(GIE);
This statements sets the GIE bit in the Status register which enables the interrupt. Notice that we have not yet defined the interrupt vector. We will do it in the next page. The code as of now will compile but will not produce any observable result.

Uncategorized
We will understand the concept of timer by writing an actual software. The purpose of the program is to generate well defined pulse(s) of alternate high and low. This is something simple, but the key here is to understand the Timer concept rather than generating the square pulse. You will need an oscilloscope to capture the high low sequence.
Preparing your hardware
Before we start our experiment, let us make sure that our hardware is in place. We do this by writing the following code and checking that we are getting high ( or low ) at an IO port of the board we are testing. In out case it is P6.3, but you can use any other port.
Use the following code and make sure that the P6.3 ( or your chosen port) turns high and low before you start experimenting.
#include "msp430x14x.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P6DIR |= 0x08; // P6.3 Set P6.3 to output
P6OUT &= ~0x08; // P6.4 is low
//P6OUT |= 0x08; // Use this if you want to check for high output.
}
In the next page we will write the actual code that will run timer.

Uncategorized
Let us assume you want to show a specific content of a webpage that shows an example html code. How do you do that ?
If you write the content as it is, it just applies the markup and the html codes itself are not displayed.
There is one solution. Use a tool from accessify.
All you have to do is copy the content of the html that you wish to display in the tool’s text area and click convert to Escape characters. It renders the escaped character into that you can use.
Uncategorized
Did you get an error trying to generate a netlist from Cadence 16.3 Orcad for the Allegro PCB Editor 16.3. In some enterprise edition you get an error that pops up saying
Error initializing COM property pages
and says some “wrong pointer” etc.
Here is a quick solution for it. Take a look at the screen shot

Basically, you need to run the Orcad as an Administrator. You need to do it only the first time.
Go
Uncategorized
The capacity of a battery life is specified either in Ampere Hour or in Watts Hour. Let us understand the two terms and the inter relation between them.
The Ampere Hour is more intuitive term for expressing the battery life. If a battery is specified at 20 Ampere hour then the implication is simple – A 20 Ampere hour battery life will last for 20 hours if it draws 1 Ampere of current. It will last for 10 hours if it draws 2 Ampere of current. Simple ?
The problem with the Ampere hour specification is that it does not specify the Voltage at the battery. Let us say you have two batteries. Both the batteries A and B has a Ampere Hour rating of 10 Ampere Hour. However, Battery A is at 3.6 Volts while the Battery B is at 7.2 Volts. Now if you draw 1 Ampere of current from both the batteries, both will last 10 hours. But the Battery B is delivering 1 Ampere at 7.2 Volts while the battery A is delivering it at only 3.6 Volts. I strictly technical terms we say that battery B has double the capacity of the battery A.
This is where the Watt hours come in play. If a battery is rated 20 Watt hours, it will mean that it will last for 20 hours if 1 Watt power is drawn from it. Now watt is defined at the product of the Volt ( at the battery) and Ampere ( drawn from the battery).
In the previous example, the 20 Ampere Hour 7.2 Volt battery would be rated as 1440 Watt Hour while the 20 Ampere Hour 3.6 Volt battery would be rated at 720 Watt Hour.
You can use the battery life calculator to calculate the life of a battery. This calculator just calculates the battery life if you know the Ampere Hour rating and the current drawn from the battery.
Uncategorized