You are on page 1of 2

#include "unistd.

h"
#include"system.h"
#include"io.h"
#include"altera_avalon_pio_regs.h"
int main()
{
int i,key,data;
while(1)
{
key=IORD(SW_BASE,0);
if(key & 0x02)
{data=0x01;
for (i=0;i<8;i++)
{
IOWR(LEDR_BASE,0,data);
usleep(1000000);
data<<=1;}}
else{ data=0x80;
for(i=0;i<8;i++)
{ IOWR(LEDR_BASE,0,data);
usleep(1000000);
data>>=1;
}
}
}
}

#include "unistd.h"
#include"system.h"
#include"io.h"
#include"altera_avalon_pio_regs.h"
int main(void)
{
alt_u8 counter ;
alt_u8 segments[16]={0x01,0x4F ,0x12, 0x06,0x4C,0x24
,0x20,0x0F,0x00,0x04,0x08,0x60,0x31,0x42,0x30,0x38};
while(1)
{
if(counter<15)
counter=counter+1;
else
counter=0;
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE,counter);
IOWR_ALTERA_AVALON_PIO_DATA(OUTPUT0_BASE,segments[counter]);
usleep(1000000);

}
return 0;
}
#include "unistd.h"
#include"system.h"
#include"io.h"
#include"altera_avalon_pio_regs.h"
int alt_main(void)
{
alt_u16 counter ;
alt_u16 segments[16]={0x0101,0x014F ,0x0112, 0x0106,0x014C,0x0124
,0x0120,0x4F01,0x4F4F,0x4F12,0x4F06,0x4F4C,0x4F24};
while(1)
{
if(counter<15)
counter=counter+1;
else
counter=0;
// IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE,counter);
IOWR_ALTERA_AVALON_PIO_DATA(OUTPUT0_BASE,segments[counter]);
usleep(1000000);

}
return 0;
}

You might also like