程序遇到麻烦 请进来看看 指点迷津
编译通过 但出来的结果不是预期的 单步执行发现错误主要是无法进入子程序‘ 程序如下:
#include "stdio.h" #include "system.h" #include "altera_avalon_pio_regs.h" #include "alt_types.h"
char xianshidata[16*6] = {0x02,0x13,0x00,0x10,0x00,0x41, 0x00,0xF8,0x04,0x90,0x00,0x10, 0x02,0x30,0xFF,0x10,0x04,0x42, 0x00,0x40,0xFE,0x90,0x08,0x10, 0x02,0x50,0x00,0x1F,0x42,0x44, 0x04,0x40,0x10,0x90,0x08,0x10, 0xFF,0x90,0x00,0x10,0x43,0x48, 0xFE,0x40,0x90,0x90,0x08,0x20, 0x04,0x10,0x1F,0x00,0x41,0x50, 0x00,0x40,0xD0,0x10,0x08,0x30, 0x04,0x10,0x10,0x00,0x40,0x60, 0x40,0x44,0x90,0x10,0x08,0x48, 0x08,0x17,0x10,0x00,0x40,0x01, 0x40,0xFE,0x90,0x50,0x08,0x84, 0x08,0x10,0x10,0x00,0x40,0x06, 0x50,0x00,0x90,0x20,0x08,0x04 };// char dis_buffer[16*6]; unsigned char *p1,*shouzhi; int hangzifu[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void smalldelay() { volatile int j; for(j=0;j<3;j++); }
void aclkh() { int sclkh; sclkh=0; smalldelay(); sclkh=1; IOWR_ALTERA_AVALON_PIO_DATA(P2_HCLOCK_BASE, sclkh); } void aclk08() { int sclk08;
sclk08=0; smalldelay(); sclk08=1; IOWR_ALTERA_AVALON_PIO_DATA(P2_LSHCLK_BASE, sclk08); } void senddata08(int row) { int sdata0,sdata8; volatile int i,j; unsigned char temp1shang,temp1xia; for(i=0;i<6;i++) { temp1shang=dis_buffer[row*i]; temp1xia=dis_buffer[(row+8)*i]; for(j=0;j<8;j++) { if ((temp1shang & 0x80)==0) sdata0=1; else sdata0=0; IOWR_ALTERA_AVALON_PIO_DATA(P2_R0_BASE, sdata0); if ((temp1xia & 0x80)==0) sdata8=1; else sdata8=0; IOWR_ALTERA_AVALON_PIO_DATA(P2_R1_BASE, sdata8); aclk08(); temp1shang=temp1shang<<1; temp1xia=temp1xia<<1; } } } void senddatahang(int rrr) { int sdatah; unsigned char hangma; volatile int i; hangma=hangzifu[rrr]; for (i=0;i<8;i++) { if ((hangma & 0x08)==0) sdatah=0; else sdatah=1; IOWR_ALTERA_AVALON_PIO_DATA(P2_HDATA_BASE, sdatah); aclkh(); hangma=hangma<<1;
} } //主程序 void main(void)__attribute__((weak,alias("alt_main"))); void alt_main(void) { int gh,suocunh,suocun08; int i; int jjj,aa,bb; gh=0; IOWR_ALTERA_AVALON_PIO_DATA(P2_NE_BASE, gh); shouzhi=&xianshidata[0]; p1=shouzhi; for(i=0;i<16;i++) { for(jjj=0;jjj<6;jjj++) {dis_buffer[i*jjj]=0;} }////初始化 for(aa=0;aa<16;aa++) { for(bb=0;bb<6;bb++) { dis_buffer[aa*bb]=*(p1+aa*6+bb); } } while(1) { for(i=0;i<8;i++) { senddatahang(i); //不进入子程序
senddatahang()执行,而是直接往下执行了,而且下面的 遇到的每一个字函数都是这样的问题????为什么??? senddata08(i); suocunh=0; suocun08=0; smalldelay(); suocunh=1; suocun08=1; IOWR_ALTERA_AVALON_PIO_DATA(P2_HSTOBE_BASE, suocunh); IOWR_ALTERA_AVALON_PIO_DATA(P2_LSTOBE_BASE, suocun08); } } }
|