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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [xilinx_avnet_lx9microbard/] [software/] [leds/] [main.c] - Rev 202

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

#include "hardware.h"
#include "7seg.h"
 
/**
Delay function.
*/
void delay(unsigned int c, unsigned int d) {
  volatile int i, j;
  for (i = 0; i<c; i++) {
    for (j = 0; j<d; j++) {
      nop();
      nop();
    }
  }
}
 
/**
This one is executed onece a second. it counts seconds, minues, hours - hey
it shoule be a clock ;-)
it does not count days, but i think you'll get the idea.
*/
volatile int irq_counter, offset;
 
wakeup interrupt (WDT_VECTOR) INT_Watchdog(void) {
 
  irq_counter++;
  if (irq_counter == 300) {
    irq_counter = 0;
    offset = (offset+1) % 20;
  }
  DispStr  (offset, "OPENMSP430 IN ACTION    ");
}
 
 
/**
Main function with some blinking leds
*/
int main(void) {
 
    int o = 0;
    irq_counter = 0;
    offset      = 0;
 
    WDTCTL = WDTPW | WDTHOLD;          // Disable watchdog timer
 
    P1OUT  = 0x00;                     // Port data output
    P2OUT  = 0x00;
 
    P1DIR  = 0x00;                     // Port direction register
    P2DIR  = 0xff;
 
    P1IES  = 0x00;                     // Port interrupt enable (0=dis 1=enabled)
    P2IES  = 0x00;
    P1IE   = 0x00;                     // Port interrupt Edge Select (0=pos 1=neg)
    P2IE   = 0x00;
 
    //WDTCTL = WDTPW | WDTTMSEL | WDTCNTCL;// | WDTIS1  | WDTIS0 ;          // Configure watchdog interrupt
 
    //IE1 |= 0x01;
    //eint();                            //enable interrupts
 
    if (CPU_NR==0x0100) { 
      delay(0x000f, 0xffff);
    } 
 
    while (1) {                         // Main loop, never ends...
 
      P2OUT = 0x00;
      delay(0x000f, 0xffff);
 
      P2OUT = 0x01;
      delay(0x000f, 0xffff);
 
      P2OUT = 0x02;
      delay(0x000f, 0xffff);
 
      P2OUT = 0x03;
      delay(0x000f, 0xffff);
 
      P2OUT = 0x02;
      delay(0x000f, 0xffff);
 
      P2OUT = 0x01;
      delay(0x000f, 0xffff);
 
    }
}
 
 

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

powered by: WebSVN 2.1.0

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