Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

assignment: Analyze and modify the MSP430 source code in the next page to output

ID: 2085442 • Letter: A

Question

assignment:

Analyze and modify the MSP430 source code in the next page to output the last three digits of your home street address using a unary number representation. For convenience, your design must replace, i.e., display, each tally mark with an LED blink. Your modification of the source code example must introduce a C function that will display a single decimal digit in the unary system in such a way that it must be easy to tell marks and digits apart.

the last three digits of my home street adress is: 110

(Next page):

for (;;)

{

}

}

Explanation / Answer

#include "msp430g2231.h"

void delay_ms(unsigned int ms )
{
    unsigned int i;
    for (i = 0; i<= ms; i++)
    __delay_cycles(500);
}

void light_number(int position_number)
{
switch (position_number)
{
case 10:   
P1OUT = 0x88;
break;   
case 20:
    P1OUT = 0x08;   
break;
case 11:
    P1OUT = 0xfc;
break;
case 21:
    P1OUT = 0x7c;
break;
case 12:
    P1OUT = 0xa2;
break;
case 22:
    P1OUT = 0x22;
break;
case 13:
    P1OUT = 0xe0;
break;
case 23:
    P1OUT = 0x60;
break;
case 14:
    P1OUT = 0xd4;
break;
case 24:
    P1OUT = 0x54;
break;
case 15:
    P1OUT = 0xc1;
break;
case 25:
    P1OUT = 0x41;
break;
case 16:
    P1OUT = 0x81;
break;
case 26:
    P1OUT = 0x01;
break;
case 17:
    P1OUT = 0xf8;
break;
case 27:
    P1OUT = 0x78;
break;
case 18:
    P1OUT = 0x80;
break;
case 28:
    P1OUT = 0x00;
break;
case 19:
    P1OUT = 0xc0;
break;
case 29:
    P1OUT = 0x40;
break;
default: break;
}
}

int main( void )
{
    WDTCTL = WDTPW + WDTHOLD; // Disable Watchdog Timer
    BCSCTL1 = CALBC1_1MHZ;    // Set range
    DCOCTL = CALDCO_1MHZ;     // Set DCO step + modulation
    P1DIR = 0xff;             // P1.X output

    while(1)
    {
    int cnt=0;
    do{
    int number1 = cnt/10;
    int number2 = cnt%10;
    int cnt2 = 0;
    do{
    light_number(20+(number2));
    delay_ms(10);
    light_number(10+(number1));
    delay_ms(10);
    cnt2++;
    }while(cnt2<30);
   
    cnt++;
    }while(cnt<100);
}
}