|
今天在测试加紧CPU中的SDRAM模块,然后在NIOS软件中写了
#include
#include "system.h"
#include
#include "altera_avalon_pio_regs.h"
//#include "altera_avalon_timer_regs.h"
#include "alt_types.h"
void delay10us(unsigned int i);/*延时函数*/
const alt_u32 LED_g_TBL[]={ //全部熄灭,再全部点亮
0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00 //依次逐个点亮
//从两边叠加后分开
};
main()
{
unsigned int key_state;
unsigned int data;
unsigned int i=0;
// delay10us(10);
while(1)
{
key_state = IORD_ALTERA_AVALON_PIO_DATA(SWITCH_0_BASE);
printf("key_state=%x\n",key_state);
IOWR(SDRAM_0_BASE,i,LED_g_TBL);
i++;
data= IORD(SDRAM_0_BASE, key_state);
printf("data=%x\n",data);
IOWR(ADD_BASE,0,data);
}
return 0;
}
void delay10us(unsigned int i)
{
for(;i>0;i--);
}
这个代码
但是程序运行后,打印了一行key_state的值之后就不动了,感觉就是跑死了,这是什么原因也?
|
|