Thunderstorm Application (MSP430 Applications C ++)
CREATING THUNDERSTORM WITH USING BIT SHIFTING METHOD
The meaning of thunderstorm is lighting up leds one by one in order. When application is working first time BIT0 PIN 's value is 1 .
P1OUT = P1OUT << 1
Using the bit shift command, we shifted the bits to the left first.We then add a shift right command to this function to get the pattern resembling cumbersome.thunderstorm.
P1OUT = P1OUT >> 1;
Codes that embed into MSP430:
---------------------------------------------
#include <msp430.h>//chosing the library
int a;
void delay(long int ); // We have defined a delay function to see the led is on .
void main(void) {
WDTCTL = WDTPW | WDTHOLD;
BCSCTL1= CALBC1_1MHZ; //DCOCLK 1MHZ is chosed....
DCOCTL = CALDCO_1MHZ;
P1DIR= 0x1F ; //P1.0,P1.1,P1.2,P1.3,P1.4 is chosed!!!!
P1OUT=0x01;//We made the first bit 1 for bitwise shifting.
while (1){ //infinite loop
for ( a=0; a<4; a++)// We wanted to shift 4 times!!
{ P1OUT = P1OUT << 1; // We shift the bits to the left
delay(10000); .
}
for ( a=0; a<4; a++)
{
P1OUT = P1OUT >> 1; // We shift the bits to the right
delay(10000);
}
}}
void delay(long int b ){ // delay function
long int i;
for (i=0;i<b;i++);}
Yorumlar
Yorum Gönder