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 202

Go to most recent revision | 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
      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 84 olivier.gi
volatile int irq_counter, offset;
23 2 olivier.gi
 
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
  int i;
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  = 0x00;
51
    P3DIR  = 0xff;
52
 
53
    P1IES  = 0x00;                     // Port interrupt enable (0=dis 1=enabled)
54
    P2IES  = 0x00;
55
    P1IE   = 0x00;                     // Port interrupt Edge Select (0=pos 1=neg)
56
    P2IE   = 0x00;
57
 
58
    WDTCTL = WDTPW | WDTTMSEL | WDTCNTCL;// | WDTIS1  | WDTIS0 ;          // Configure watchdog interrupt
59
 
60
    IE1 |= 0x01;
61
    eint();                            //enable interrupts
62
 
63
 
64
    while (1) {                         // Main loop, never ends...
65
        for (i=0; i<8; i++, o++) {
66
            P3OUT = (1<<i) | (0x80>>(o&7));
67
            delay(0x0007, 0xffff);
68
        }
69
    }
70
}
71
 

powered by: WebSVN 2.1.0

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