“使用AT24Cxx扩展C8051F EEPROM”的版本间的差异

来自丢石头百科
(文本替换 - 替换“www.waveshare.net”为“{{SERVERNAME}}”)
(文本替换 - 替换“http://{{”为“https://{{”)
 
第15行: 第15行:
 
<table border="0" cellpadding="0" cellspacing="0" width="120"><tbody><tr><th bgcolor="#698192" class="white_12px_b" height="20" scope="col" style="font-size: 12px; color: rgb(255, 255, 255); line-height: 20px; font-family: Arial, Helvetica, sans-serif;">软件设计</th></tr></tbody></table>
 
<table border="0" cellpadding="0" cellspacing="0" width="120"><tbody><tr><th bgcolor="#698192" class="white_12px_b" height="20" scope="col" style="font-size: 12px; color: rgb(255, 255, 255); line-height: 20px; font-family: Arial, Helvetica, sans-serif;">软件设计</th></tr></tbody></table>
 
下面部分从TXT拷出,拷到网页,代码部分缺省了很多空格,比较凌乱,请谅解!
 
下面部分从TXT拷出,拷到网页,代码部分缺省了很多空格,比较凌乱,请谅解!
I2C(SMBus)详细程序请查看<a class="Blue_2_12px_" href="http://{{SERVERNAME}}/article/C8051F-4-3-4.htm" style="color: rgb(7, 66, 184);" target="_blank">C8051F I2C(SMBus)程序
+
I2C(SMBus)详细程序请查看<a class="Blue_2_12px_" href="https://{{SERVERNAME}}/article/C8051F-4-3-4.htm" style="color: rgb(7, 66, 184);" target="_blank">C8051F I2C(SMBus)程序
 
。 
 
。 
  

2021年6月18日 (五) 18:03的最新版本

<tbody></tbody>
<tbody></tbody>
系统功能

   使用AT24Cxx扩展C8051F EEPROM。


<tbody></tbody>
硬件设计

C8051F 3 5.jpg 使用AT24Cxx扩展C8051F EEPROM电路原理图


<tbody></tbody>
软件设计

下面部分从TXT拷出,拷到网页,代码部分缺省了很多空格,比较凌乱,请谅解! I2C(SMBus)详细程序请查看<a class="Blue_2_12px_" href="https://wiki.diustou.com/article/C8051F-4-3-4.htm" style="color: rgb(7, 66, 184);" target="_blank">C8051F I2C(SMBus)程序 。 

//目标系统: 基于C8051F单片机 //应用软件: Silicon IDE / Keil

/*01010101010101010101010101010101010101010101010101010101010101010101


实验内容: 写入一些测试数据进EEPROM,再读出,使用P2口与LED相连,观测是否与写入一致


硬件连接: 将P2口与8位LED指示灯相连。 DVK501(AT24CxxPrlPort)    F320 EX                            VCC    ---------   VCC                            GND   ---------   GND                            SDA    ---------   P1.0                              SCL    ---------   P1.1


注意事项: (1)若有加载库程序,请将光盘根目录下的“library”下的“C8051F”文件夹拷到D盘 (2)请详细阅读:光盘根目录下的“说明书首页.htm”里的相应产品说明


10101010101010101010101010101010101010101010101010101010101010101010*/

  1. define _DVK501_F320_EX_
  2. include <c8051f320.h>
  3. include <../../../../library/C8051F/ws_clock.h>
  4. include <../../../../library/C8051F/ws_delay.h>
  5. include <../../../../library/C8051F/ws_iic_port.h>
  6. include <../../../../library/C8051F/ws_at24cxx.h>

void main(void) { uchar *pRdDat; PCA0MD &= ~0x40; // Clear watchdog timer enable clock_external(); // Set oscillator in external,the clock is 12M delay_ms(100); Check_SDA();  XBR1 = 0x40; // Enable crossbar and weak pull-ups SMBus_Init(); Enb_Interrupt(); Write_AT24Cxx(0x00,'P'); Read_AT24Cxx(0x00,pRdDat); P2 = *pRdDat;

while(1); } void Write_AT24Cxx(uchar adr,uchar WrData) {  SMBus_Write(0xA0,adr,WrData,2); } void Read_AT24Cxx(uint adr,uchar *RdData) { SMBus_Write(0xA0,adr,0,1); SMBus_Read(0xA1,RdData,1);

}
<tbody></tbody>
系统调试

观察读出的EEPROM数据与写入EERPOM的数据是否一致,用LED作为显示。