Powered By Blogger

Saturday, June 13, 2015

I'M RUNNING FROM THE PAST !!!

I'm running from the past,  'cause I can't let it to last.
It's haunting me to blast, still I'm not running too fast..
I'm a Mr.  Nobody,  I'm a mere cypher.
Ooh forgot to Mention, I'm also a fighter..

They call it to empower, they send them some flower.
They don't give the freedom, yeah they're so coward...
Flowers won't do it, mercy won't do it.
Don't wait for the writ, why don't you just quit...

Half the world is full of them, still they need to be endowed.
You got to be kidding me, the other half is still so proud...
Stop this nuisance, don't do this show off.
This ill faced society is getting into trough...

We still have time to rectify this blunder, to stop the plunder.
Oh dear boy wonder, open your eyes, and see the torn asunder...
Don't allow them, permit them or show mercy.
They're the ladies, they've the right for their own Jersey...

None is greater, monk or the priest.
For if they care,  they do that the least...
Everyone has to feel it, the equality of the half.
God's not gonna come and do it in your behalf...

Let them free, and fly to the sky.
They're the birds, they know to go high...
They'll be proud, you'll be proud.
And then won't be anyone to defy...

"Equality is not given, it's felt within... 
Once you feel it, it begin... "

Tuesday, June 9, 2015

CONTROLLED LED GLOW USING SWITCH

CONTROLLED LED GLOW USING SWITCH

The aim of the program is to make you familiar with :
1. basic commands
2. Interrupts
3. switches on developer board

OUTCOME

The outcome of the program will be like when you press button1 First Time at P4.5 LED 1 will GLOW and LED 0 will be OFF. When pressed again LED glowing reverses. The later button 2 at P1.0 works as a switch for the whole process of the glowing. If button 2 is once pressed the button 1 works , i.e. switching the glowing of LEDs at each press, and if button 2 is pressed again, button 1 becomes ineffective.

WORKING

The prime background working of this program is Interrupt Service Subroutine. MSP430FR5969 is a Ultra Low Power device. Running a program and checking the pin status always continously takes energy. So its wise to use interrupts instead. Interrupt is enabled at each button press and work is done accordingly.
Work of BUTTON 2 is to enable or disable BUTTON 1. So we make the value of a our main variable to TURNED OFF situation (here COUNT=2 ). And BUTTON 1 keeps increasing the value of COUNT at each Interrupt generation. When reached 3, it's reset to 0 (this is done since two LEDs are used. You can use many more LEDs and so let count reach a higher value accordingly).

POINTS TO EMPHASIZE

Command: WDTCTL = WDTPW + WDTHOLD

This command disables WATCHDOG TIMER.
Now what is this Whatchdog Timer. Allow me to explain this crucial point. It is a control that helps to prevent the code being stuck at a place where it shouldn't be like an infinite loop. If the control gets stuck in an infinite loop, it checks that the control hasn't come out of the loop in a certain time. Then it resets the device to free up all the memories and start over again.

We in this case don't want this to happen. Instead we have deliberately introduced an infinite loop.

Command : PM5CTL0 &= ~LOCKLPM5

This command disables the GPIO power on default high impedance state. In simpler language, it enables new code to be written on the controller each time we burn the code. Without this line program doesn't gets into memory and we would get worried that some logical or hardware error must have happened.


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                                                 PROGRAM STARTS FROM HERE
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include

#define LED_0 BIT0
#define LED_1 BIT6
#define BUTTON BIT5
#define BUTTON2 BIT1

unsigned int count = 2;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void main(void)
{
WDTCTL = WDTPW + WDTHOLD;              // Stop watchdog timer
PM5CTL0 &= ~LOCKLPM5;                          // Disable the GPIO power-on default high-impedance                                                                           //mode to activate previously configured port settings
P1DIR |= (LED_0 + LED_1);                         // Set P1.0 and P1.6 to output direction
P1OUT &= ~(LED_0 + LED_1);                    // Set the LEDs off


P4REN |= BUTTON;                                         //Enables a puller-Resistor on the button-pin
P4OUT |= BUTTON;                                    //Writes a "1" to the portpin, tellling the resistor to pullup
P4IES |= BUTTON;                                   //Triggers when you PRESS the button :: Pick one
//P1IES &= ~BUTTON;                        // Triggers when you RELEASE the button :: or pick the other
P4IE |= BUTTON;                  //Enables the selector-mask for generating interrupts on the relevant pin


P1REN |= BUTTON2;                                      //Enables a puller-Resistor on the button-pin
P1OUT |= BUTTON2;                                 //Writes a "1" to the portpin, tellling the resistor to pullup
P1IES |= BUTTON2;                                //Triggers when you PRESS the button :: Pick one...
//P1IES &= ~BUTTON;                     // Triggers when you RELEASE the button :: ...or pick the other
P1IE |= BUTTON2;                //Enables the selector-mask for generating interrupts on the relevant pin

P1IFG &= ~BUTTON2;                                             //~~~~~~~~~ P1.1 IFG cleared
P4IFG &= ~BUTTON;                                               //~~~~~~~~~P4.5 IFG cleared

/* Clearing of (IFG) Interrupt Flag is important. If not done it will take any random value, may get triggered without button pressed at the first time and generate undesired value.*/


__enable_interrupt();                              // Interrupts get enabled *here* - they were disabled thus far..

for (;;)
{

if (count == 0)                                                       // Even button Press condition
{

       P1OUT |= (LED_0);                                        // led 0 is ON
       P1OUT &= ~(LED_1);                              // led 1 os OFF
}
else if (count == 1)                                                 // Odd button Press condition
{

P1OUT |= (LED_1);                                // led 1 is ON
P1OUT &= ~(LED_0);                             // led 0 is OFF
}
else                                                                           // Default Case..... (both LEDs OFF)
{
P1OUT &= ~(LED_0);                             // led 0 is OFF
P1OUT &= ~(LED_1);                             // led 1 is OFF
}
}
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                                                 MAIN PROGRAM ENDS ABOVE
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


// Port 4 interrupt service routine

#pragma vector=PORT4_VECTOR
__interrupt void Port_4(void)
{
count++;                                                            //The value of count is increased on each interrupt
P4IFG &= ~BUTTON;                                             // P4.5 IFG cleared
if (count > 2)
{
count = 0;                                                         // count is reset when count =3

}

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// Port 1 interrupt service routine

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1IFG &= ~BUTTON2;                                               // P1.1 IFG cleared
   count = 2;
}

Monday, June 8, 2015

MSP430FR5969

About the Device
The MSP430™ ultra-low-power (ULP) FRAM (Ferromagnetic RAM) platform combines uniquely embedded FRAM and a holistic ultra-low-power system architecture, allowing innovators to increase performance at lowered energy budgets. FRAM technology combines the speed, flexibility, and endurance of SRAM with the stability and reliability of flash at much lower power.
The MSP430 ULP FRAM portfolio consists of a diverse set of devices featuring FRAM, the ULP 16-bit MSP430 CPU, and intelligent peripherals targeted for various applications. The ULP architecture showcases seven low-power modes, optimized to achieve extended battery life in energy-challenged applications.
All these may attract you as an embedded design developer. And as a starter, everyone faces some challenges.
TI has provided ample support for this kit, but the support is not device specific. I faced a lots of problems in running few simple codes on the MSP430 FR5969 kit at starting. And the learning process is still on. RISC architecture of MSP430 makes it complicated to program and difficult to remember its diverse coding possibilities.
But gradually with practice one be familiar with all normally used functions of this kit. 
The programs I upload are first tested by me. The Software used and difficult conditions arisen are mentioned in the comments. Half of the solutions to our problem are mentioned in comments only. so please go through them at once.
So, lets start taking dips in the vast ocean of opportunities with MSP430 FR5969.