Last active
August 29, 2015 13:57
-
-
Save kizzlebot/9547996 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <msp430fg4618.h> | |
#include <msp430.h> | |
#include "LCD_Ctrl.h" | |
#include "stdio.h" | |
#define GREEN BIT2 | |
#define ORANGE BIT1 | |
#define LCD_SIZE 11 | |
/* Exercises for C-code | |
* 1. Write program to display the number 2 ( segments abdeg ) on the rightmost | |
* seven segment display. | |
* 2. Write program to display the number 2 ( segments abdeg ) on the leftmost | |
* seven segment display. | |
* 3. Write a C-language program that cna display the numbers 0 - 9 and Letters A-F. | |
* Program should count up from 0 to F and then repeat indefinitely | |
* 4. Write a C-language program that counts up from 0 to 999 in decimal and displays this | |
* count every tenth of a second if SW1 is pressed and begin counting down when SW2 is pressed | |
*/ | |
unsigned int characters[] = {0x5f,0x06,0x6b,0x2f,0x36,0x3d,0x7d,0x07,0x7f,0x37,0x77,0x7c,0x59,0x2d,0x79,0x71}; | |
void Init_LCD(void) ; | |
unsigned char *LCDSeg = (unsigned char *) &LCDM3; | |
unsigned int cnts[] = {0,0,0,0,0,0,0} ; | |
unsigned int cnt = 0; | |
int main(void) { | |
volatile unsigned char a; // <Volatile> | |
volatile unsigned int i; // <Volatile> | |
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer | |
// Clock Set up | |
CCTL0 = CCIE; // Set up Timer+Clock | |
TACTL = TASSEL_1 + MC_1; // [timerA -> ACLK][MODE: UP] | |
TACCR0 = 0x7FFE ; // TACCR0 is the upper limit of the timer = 32768 | |
P2DIR |= GREEN+ORANGE; // Set Px as output to be able to turn on LED | |
Init_LCD(); | |
__enable_interrupt(); | |
__bis_SR_register(LPM0 + GIE); // LPM0 with interrupts enabled | |
// "0": 01011111 0x5f | |
// "1": 00000110 0x06 | |
// "2": 01101011 0x6B | |
// "3": 00101111 0x2F | |
// "4": 00110110 0x36 | |
// "5": 00111101 0x3D | |
// "6": 01111101 0x7D | |
// "7": 00000111 0x07 | |
// "8": 01111111 0x7F | |
// "9": 00110111 0x37 | |
// "A": 01110111 0x77 | |
// "b": 01111100 0x7C | |
// "c": 01011001 0x59 | |
// "d": 00101101 0x2D | |
// "e": 01111001 0x79 | |
// "f": 01110001 0x71 | |
} | |
#pragma vector = TIMERA0_VECTOR | |
__interrupt void Timer_A (void){ | |
if ( cnt%2 == 0 ){ | |
P2OUT ^= GREEN; // Toggle P1.0 using exclusive-OR | |
} | |
else P2OUT ^= ORANGE; | |
cnt++ ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment