123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #include <msp430g2553.h>
- #include "char.c"
- // 74HC Pins
- #define DATA BIT0 //DS 1.0
- #define CLOCK BIT4 // SH_CP 1.4
- #define LATCH BIT5 // ST_CP 1.5
- //4017 Pins
- #define CLOCKCP BIT6 // Clock 1.2
- #define RESET BIT3 // Reset 1.3
- //Declaration des prototypes de fonctions
- void pushRegister(int val);
- void pinWrite(int bit, int val);
- void clearAll(void);
- //Declaration des vaiables
- unsigned int DisplayBuffer[]={0,0,0,0,0,0,0,0};
- unsigned int speed;
- short i, l, k, ShiftAmount, scroll, temp, shift_step=1;
- char message[]="Powered by MSP430";
- char index;
- void clearAll(void) {
- int i;
- P1OUT |= RESET;
- P1OUT &= ~RESET;
- P1OUT &= ~LATCH;
- for(i=0; i<8; i++) {
- pinWrite(DATA, 0);
- P1OUT |= CLOCK;
- P1OUT &= ~CLOCK;
- }
- P1OUT |= LATCH;
- }
- void main(void) {
- WDTCTL = WDTPW + WDTHOLD; //stop watchdog
- P1DIR |= (DATA + CLOCK + LATCH + CLOCKCP + RESET); //mise en sortie
- clearAll();
- while(1) {
- for(k=0; k<strlen(message); k++) {
- for(scroll=0; scroll<(8/shift_step); scroll++) {
- for(ShiftAmount=0; ShiftAmount<8; ShiftAmount++) {
- index = message[k];
- temp = CharData[index-32][ShiftAmount];
- DisplayBuffer[ShiftAmount] = (DisplayBuffer[ShiftAmount] << shift_step) | (temp >> ((8-shift_step)-scroll*shift_step));
- }
- speed = 15;
- for(l=0; l<speed; l++) {
- for(i=0; i<8; i++) {
- pushRegister(DisplayBuffer[i]);
- }
- P1OUT |= RESET;
- P1OUT &= ~RESET;
- }
- }
- }
- }
- }
- void pushRegister(int val) {
- P1OUT &= ~LATCH;
- int i;
- for(i=8; i>0; i--) {
- pinWrite(DATA, (val & (1 << i)));
- P1OUT |= CLOCK; //clock 74HC
- P1OUT &= ~CLOCK;
- }
- P1OUT |= LATCH;
- P1OUT &= ~LATCH;
-
- for(i=0; i<8; i++) {
- pinWrite(DATA, 0);
- P1OUT |= CLOCK; //clock 74hc
- P1OUT &= ~CLOCK;
- }
- P1OUT |= LATCH;
- P1OUT |= CLOCKCP; //clock 4017
- P1OUT &= ~CLOCKCP;
- }
- void pinWrite(int bit, int val) {
- if(val) P1OUT |= bit;
- else P1OUT &= ~bit;
- }
|