2011-12-28 90 views
0

我有一个数组向下跌破如何将内存中的内容写入数组?

unsigned char pat6[8] = {0x3C,0xFF,0xC3,0xC3,0xC3,0xC3,0xFF,0x3C,}; 

我怎样才能填补的内存,我从这里阅读内容的阵列?

unsigned char read_byte()   //reading from EEPROM serially 
{ 
    unsigned int i; 
    sda=1; 
    reead=0; 
    for(i=0;i<8;i++) 
    { 
     reead=reead<<1; 
     scl=1; 
     _nop_(); 
     _nop_(); 
     if(sda==1) 
      reead++; 
     scl=0; 
    } 
    sda=0; 
    return reead;    //Returns 8 bit data here 
}  

由于

void display_clear(unsigned char pattern[])//, int num) 

{ 
    unsigned int cnt, col, row; //, num ; 


    row = 1; 
      //for (cnt = num*8 ; cnt < (num*8+8) ; cnt ++) //display pattern each character 
      for (cnt = 0 ; cnt < 8 ; cnt ++) //display pattern each character 
      { 
       P3 = ~pattern[cnt]; 
       P1 = ~row; 

       delay_ms(100) ; // delay of 1 ms 
       row = row<<1; 


      } 

     row = 0x00; 

} 

朋友,上述函数,我用于显示阵列..... 我想从串行存储器

我填写数组中的数据试图这样做:

//begin of read 2048 byte from serial memory AT24C16 

    for (i=0;i<2048;i++) 
     { 
      j[i]=read_byte(); 
      aknowledge(); 
     } 

    //end of read 2048 byte from serial memory AT24C16 

并得到错误:

24C16_RW.C(229):错误C216:在非数组或维度太多

是否有任何其他方式标?

感谢

+1

什么是'scl'?它在哪里宣布? – 2011-12-28 08:15:28

回答

0

我不知道如果我理解正确你的问题,但我认为有一个for语句会工作。

for (i=0, i<8,i++) 
pat6[i]=read_byte(); 

什么我不明白是读功能怎么会知道如何按顺序读取。我认为在这个实现中,整个数组将被填充相同的字节。

+0

亚,我怎么read_byte并按顺序放入数组? – 2011-12-28 09:32:33

0

请按照下面的伪代码。

function write_into_array() 
{ 
    for i=0 to 8 { 
     array[i] = value-to-be-stored; 
    } 
} 

但是在你的代码中,scl变量在哪里声明?或者它是一个全局变量,就像pat6[]数组?

OTOH,你应该在最后摆脱额外的,

unsigned char pat6[8] = {0x3C,0xFF,0xC3,0xC3,0xC3,0xC3,0xFF,0x3C,}; 
相关问题