Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

microblaze c code for nexys2.

Status
Not open for further replies.

phoenixx

Newbie level 2
Joined
May 21, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,290
i want use seven segment with microblaze. can anyone send me an example c code?
 

i want use seven segment with microblaze. can anyone send me an example c code?

/*

(blink.c)

- Short program showing how to use simple memory-mapped I/O
- Implements a counter on the 7-segment displays by...
- Generating a new piece of data to display through table lookup
- Displaying that piece of data for a visible amount of time

*/


// Located in: microblaze_0/include/xparameters.h
#include "xparameters.h"
#include "mb_interface.h"
#include "stdio.h"
#include "xutil.h"

//====================================================

int main (void) {


// Base address of register that controls LED output
volatile int* regLED = (int*)0x40020000;

// Values... 0 1 2 3 4 5 6 7 8 9
const int lookupTable [] = {(0x02),(0x9E),(0x24),(0x0C),(0x98),(0x48),(0x40),(0x1E),(0x00),(0x18)};

// Loop variables
int a, x, counter = 0;

// "Value" to display on LEDs
int val;

print("**** BEGIN ****\r\n");

// Number of times to loop through display sequence
while(counter < 10){

// Increment counter
counter++;

// Count from 0 to 9 on the LEDs
x = 0;
for (x=0; x < 10; x++){

// Change the displayed value
val = lookupTable[x] << 4;

xil_printf("Current Value = **0x%x**\r\n",val);

// Hold a value for a visible amount of time
for (a=0; a < 5000000; a++){
*regLED = val;
}
}

}

*regLED = 0xFE << 4;

print("**** END ****\r\n");
return 0;
}


-- Hope this helps...
 

thanks. it works but it doesn't count. all digits are zeros.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top