#include const int buffer_line_to_leds [8] = {0x0380,0x0240,0x9f20,0x9910,0x9f08,0x4904,0x0d02,0x4101}; //0xff80,0xaa80,0xaa80,0xaa80,0xaa80};0x00ff,0x00ff,0x00ff,0x00ff,0x00ff}; //0xaa01,0xaa01,0xaa01,0xaa01,0xaa01,0xaa01}; //0xc080,0x4040,0xf920,0x9910,0xAFf08}; // "0.014r" on the screen. Firsf byte - image, second - position void push_16bit_to_display (int); //Subprogram to push 16 bit to 74hc273 (one car.+position) via 'data' & 'clock' lines int bit, position_on_screen; int main(void) { // Set int. clock to 8 MHz to prevent flicker BCSCTL1 = CALBC1_8MHZ; // Set pre-calibrated 'range' for 8MHz DCOCTL = CALDCO_8MHZ; // Set pre-calibrated 'DCO step + modulation' for 8MHz WDTCTL = WDT_MDLY_8; //Set WDT as interrupt source (8ms/8(MHz)=1ms or 1000/sec. IE1 |= WDTIE; // Enable WDT interrupt P1DIR |= 0x0E; // Set P1.1,2,3 to output direction __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt return 0; } // Next, executed every time when interrupt occurred. 8msec==125 time per sec. At 8 MHz => 1000 times per sec. #pragma vector=WDT_VECTOR __interrupt void watchdog_timer(void) { push_16bit_to_display (buffer_line_to_leds [position_on_screen]); //Call to subprogram. position_on_screen++; //upd. position for the next call if(position_on_screen == 8) position_on_screen=0; //if pos. is 5 (all showed) - start from 0 } void push_16bit_to_display (int Data) { for (bit = 0; bit < 16; bit++) // Loop 16 bits to write to 74hc273 { P1OUT = 0x00; // Set 'data' (P1.3) 'low' if((Data >> bit) & 0x01) P1OUT |= 0x04; // If ==1 then 'data' (P1.3) bit is a 'hi' P1OUT |= BIT3; // Set 'clock' (P1.4) 'hi' P1OUT &= ~BIT3; // Set 'clock' (P1.4) 'low' } P1OUT |= BIT1; // Set 'clock' (P1.2) 'hi' P1OUT &= ~BIT1; // Set 'clock' (P1.2) 'low' }