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

Subversion Repositories openmsp430

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 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 84 olivier.gi
  volatile int i, j;
9 2 olivier.gi
  for (i = 0; i<c; i++) {
10
    for (j = 0; j<d; j++) {
11 212 olivier.gi
      __nop();
12
      __nop();
13 2 olivier.gi
    }
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 212 olivier.gi
volatile int irq_counter;
23
volatile INT8U offset;
24 2 olivier.gi
 
25
wakeup interrupt (WDT_VECTOR) INT_Watchdog(void) {
26
 
27
  irq_counter++;
28
  if (irq_counter == 300) {
29
    irq_counter = 0;
30
    offset = (offset+1) % 20;
31
  }
32 212 olivier.gi
  DispStr  (offset, (INT8U *) "OPENMSP430 IN ACTION    ");
33 2 olivier.gi
}
34
 
35
 
36
/**
37
Main function with some blinking leds
38
*/
39
int main(void) {
40 212 olivier.gi
 
41
    int i;
42 2 olivier.gi
    int o = 0;
43 212 olivier.gi
 
44 2 olivier.gi
    irq_counter = 0;
45
    offset      = 0;
46
 
47
    WDTCTL = WDTPW | WDTHOLD;          // Disable watchdog timer
48
 
49
    P1OUT  = 0x00;                     // Port data output
50
    P2OUT  = 0x00;
51
 
52
    P1DIR  = 0x00;                     // Port direction register
53
    P2DIR  = 0x00;
54
    P3DIR  = 0xff;
55
 
56
    P1IES  = 0x00;                     // Port interrupt enable (0=dis 1=enabled)
57
    P2IES  = 0x00;
58
    P1IE   = 0x00;                     // Port interrupt Edge Select (0=pos 1=neg)
59
    P2IE   = 0x00;
60
 
61
    WDTCTL = WDTPW | WDTTMSEL | WDTCNTCL;// | WDTIS1  | WDTIS0 ;          // Configure watchdog interrupt
62
 
63 212 olivier.gi
    IE1_set_wdtie();
64 2 olivier.gi
    eint();                            //enable interrupts
65
 
66
 
67 212 olivier.gi
    while (1) {                        // Main loop, never ends...
68
 
69 2 olivier.gi
        for (i=0; i<8; i++, o++) {
70
            P3OUT = (1<<i) | (0x80>>(o&7));
71
            delay(0x0007, 0xffff);
72
        }
73
    }
74 212 olivier.gi
 
75
    return 0;
76 2 olivier.gi
}

powered by: WebSVN 2.1.0

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