OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [xilinx_avnet_lx9microbard/] [software/] [leds/] [main.c] - Blame information for rev 167

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 157 olivier.gi
#include "hardware.h"
2
#include "7seg.h"
3
 
4
/**
5
Delay function.
6
*/
7
void delay(unsigned int c, unsigned int d) {
8
  volatile int i, j;
9
  for (i = 0; i<c; i++) {
10
    for (j = 0; j<d; j++) {
11
      nop();
12
      nop();
13
    }
14
  }
15
}
16
 
17
/**
18
This one is executed onece a second. it counts seconds, minues, hours - hey
19
it shoule be a clock ;-)
20
it does not count days, but i think you'll get the idea.
21
*/
22
volatile int irq_counter, offset;
23
 
24
wakeup interrupt (WDT_VECTOR) INT_Watchdog(void) {
25
 
26
  irq_counter++;
27
  if (irq_counter == 300) {
28
    irq_counter = 0;
29
    offset = (offset+1) % 20;
30
  }
31
  DispStr  (offset, "OPENMSP430 IN ACTION    ");
32
}
33
 
34
 
35
/**
36
Main function with some blinking leds
37
*/
38
int main(void) {
39
 
40
    int o = 0;
41
    irq_counter = 0;
42
    offset      = 0;
43
 
44
    WDTCTL = WDTPW | WDTHOLD;          // Disable watchdog timer
45
 
46
    P1OUT  = 0x00;                     // Port data output
47
    P2OUT  = 0x00;
48
 
49
    P1DIR  = 0x00;                     // Port direction register
50
    P2DIR  = 0xff;
51
 
52
    P1IES  = 0x00;                     // Port interrupt enable (0=dis 1=enabled)
53
    P2IES  = 0x00;
54
    P1IE   = 0x00;                     // Port interrupt Edge Select (0=pos 1=neg)
55
    P2IE   = 0x00;
56
 
57
    //WDTCTL = WDTPW | WDTTMSEL | WDTCNTCL;// | WDTIS1  | WDTIS0 ;          // Configure watchdog interrupt
58
 
59
    //IE1 |= 0x01;
60
    //eint();                            //enable interrupts
61
 
62 167 olivier.gi
    if (CPU_NR==0x0100) {
63
      delay(0x000f, 0xffff);
64
    }
65 157 olivier.gi
 
66
    while (1) {                         // Main loop, never ends...
67
 
68 167 olivier.gi
      P2OUT = 0x00;
69
      delay(0x000f, 0xffff);
70
 
71 157 olivier.gi
      P2OUT = 0x01;
72 167 olivier.gi
      delay(0x000f, 0xffff);
73 157 olivier.gi
 
74
      P2OUT = 0x02;
75 167 olivier.gi
      delay(0x000f, 0xffff);
76 157 olivier.gi
 
77 167 olivier.gi
      P2OUT = 0x03;
78
      delay(0x000f, 0xffff);
79 157 olivier.gi
 
80 167 olivier.gi
      P2OUT = 0x02;
81
      delay(0x000f, 0xffff);
82 157 olivier.gi
 
83 167 olivier.gi
      P2OUT = 0x01;
84
      delay(0x000f, 0xffff);
85 157 olivier.gi
 
86
    }
87
}
88
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.