Comments (2)
在测试发现AT24C02无法正常写入EEPROM,只能正确写入几个不连续的字节,查看代码发现在写入成功的时候没有延时如下所示 rt_err_t at24cxx_write(at24cxx_device_t dev, uint32_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite) { uint16_t i = 0; rt_err_t result; RT_ASSERT(dev);
if(WriteAddr + NumToWrite > AT24CXX_MAX_MEM_ADDRESS) { return RT_ERROR; } result = rt_mutex_take(dev->lock, RT_WAITING_FOREVER); if (result == RT_EOK) { while (1) //NumToWrite-- { if (at24cxx_write_one_byte(dev, WriteAddr, pBuffer[i]) != RT_EOK) { rt_thread_mdelay(EE_TWR); } else { WriteAddr++; i++; } if (i == NumToWrite) { break; } } } else { LOG_E("The at24cxx could not respond at this time. Please try again"); } rt_mutex_release(dev->lock); return RT_EOK;
}
将这个函数改成下面即可成功写入 rt_err_t at24cxx_write(at24cxx_device_t dev, uint32_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite) { uint16_t i = 0; rt_err_t result; RT_ASSERT(dev);
if(WriteAddr + NumToWrite > AT24CXX_MAX_MEM_ADDRESS) { return RT_ERROR; } result = rt_mutex_take(dev->lock, RT_WAITING_FOREVER); if (result == RT_EOK) { while (1) //NumToWrite-- { if (at24cxx_write_one_byte(dev, WriteAddr, pBuffer[i]) == RT_EOK) { WriteAddr++; } if (++i == NumToWrite) { break; } rt_thread_mdelay(EE_TWR); } } else { LOG_E("The at24cxx could not respond at this time. Please try again"); } rt_mutex_release(dev->lock); return RT_EOK;
}
目前问题依旧,用at24cxx write 后读出只有第一个字节,改为你的每个都延迟后正常。
from at24cxx.
谢谢
from at24cxx.
Related Issues (10)
- 你好,这个 at24cxx 似乎不支持 at24c16 以上的,对嘛。。。 HOT 2
- at24cxx_device_t at24cxx_init(const char *i2c_bus_name) 这个函数参数是一个,源码的这个函数是两个参数,文档不更新? HOT 2
- https://club.rt-thread.org/ask/question/425118.html
- https://club.rt-thread.org/ask/question/f286231c8fe0145e.html HOT 1
- 写函数有问题
- 能不能添加一个例子啊 HOT 1
- How to use the define EE_TYPE
- 增加页写算法
- 关于该软件包在 rt-thread packages 中的索引 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from at24cxx.