//******************************************************************************
// Demo - MSP430F169, Compute 2-byte checksum for Iridium modem
//
// Description - This program will compute and print the 2-byte checksum of the
// message "hello" required for the Iridium modem.  The hex value of each ASCII
// character will be added to the previous one in addition to being printed.
// Once this is complete the program will print out the high order byte of the
// checksum followed by the low order byte.
//
// Note: This code was taken from the "AT Command Set for Model 9601-D 
// Technical Note" and modified for personal use.
//
// Stefan Gadomski
// UC Santa Cruz
// June 6, 2007
// Senior Design 123B
// Built with IAR Embedded Workbench Version: 3.42A
//******************************************************************************

#include <msp430x16x.h>
#include <stdio.h>

unsigned int checksum = 0;
unsigned char lower;
unsigned int i = 0;
unsigned char c;
char* data = "hello";

void main(void)
{
while (i < 5) 
{
c = data[i];
printf("%x\n",c);        // Print hex value of current ASCII character
checksum += c;           // Add hex value of current ASCII character to previous
i++;
}
printf("\n");

// Now print out the 2 byte checksum

printf("%x\n",checksum >> 8);     // Print high order byte of checksum
lower = checksum;
printf("%x\n",lower);           // Print low order byte of checksum
printf("\n");
}
