<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > AVR單片機(jī)Atmega128外擴(kuò)RAM

          AVR單片機(jī)Atmega128外擴(kuò)RAM

          作者: 時(shí)間:2013-12-12 來(lái)源:網(wǎng)絡(luò) 收藏

          void writeram(unsigned int iaddr, unsigned char ctemp)
          {
          //unsigned char caddl,caddh;
          unsigned char cdatatemp=0;
          RDH;
          WRH;
          ALEH;
          DDRA = 0xFF;
          DDRC = 0xFF;
          PORTC=iaddr>>8;
          PORTA=(unsigned char)iaddr;
          ALEL;//鎖存A0-A7
          WRL;
          PORTA=ctemp;
          asm("nop;");
          WRH;
          ALEH;
          return;
          }

          #endif

          #define RAMSTARTADDR 0X1100
          #define RAMENDADDR 0X90FF
          #define RAMLEN 32768
          // 測(cè)試32KRAM 用的是UT62256和74HC573

          int main(void)
          {
          unsigned int k=0;
          unsigned int i=0,j=0;
          unsigned char DATA,u;

          init_devices();

          MCUCR = 0x80; // 允許外部并行擴(kuò)展接口
          XMCRA = 0x00; //0x00 external memory

          XMCRB = 0x01; // 釋放PC7,作為通用I/O引腳使用
          DDRC = 0xff; // PC7,PC6用于輸出,(不影響PC0-PC6地址線)
          PORTC = 0x00; // PC7,PC6輸出0,(不影響PC0-PC6地址線)
          //由于是32KB所以PC7用作62256片選使能,可以釋放P7為普通IO使用,輸出低電平使能62256
          sendstring1("init system ok!");
          sendstring1("now test system-ram all is 32k !");

          sendstring1("----now write ram");
          _delay_ms(1300);
          #if 1
          for(i=0;i32768;i++)
          {
          if(i%2)
          *(p+i)=(unsigned char)(p+i);
          else
          *(p+i)=0xff;
          _delay_us(10);
          }
          // #else
          sendstring1("----write ok");
          sendstring1("----now check write");
          sendstring1("----now read ram");
          for(i=0;i32768;i++)
          {
          DATA = *(p+i);
          sendstring1("addr=");
          sendinthex1((unsigned int)(p+i));
          sendstring1("=");
          sendinthex1(DATA);
          sendstring1("");
          }
          #endif
          sendstring1("---- test system-ram end!");
          }


          上一頁(yè) 1 2 3 4 下一頁(yè)

          關(guān)鍵詞: AVR單片機(jī) Atmega128 外擴(kuò)RAM

          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();