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 162

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
 
63
    while (1) {                         // Main loop, never ends...
64
 
65
      P2OUT = 0x01;
66
      delay(0x0007, 0xffff);
67
 
68
      P2OUT = 0x02;
69
      delay(0x0007, 0xffff);
70
 
71
      P2OUT = 0x06;
72
      delay(0x0007, 0xffff);
73
 
74
      P2OUT = 0x04;
75
      delay(0x0007, 0xffff);
76
 
77
      P2OUT = 0x08;
78
      delay(0x0007, 0xffff);
79
 
80
      P2OUT = 0x09;
81
      delay(0x0007, 0xffff);
82
 
83
    }
84
}
85
 

powered by: WebSVN 2.1.0

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