??? 04/19/10 11:59 Read: times |
#175119 - Some Important Things to Consider Responding to: ???'s previous message |
Sandu:
Some things to consider.... 1) What is the nature of how you do the interface on the I2C bus? Are you doing this by bit bang? You should gather some information on how fast you are able to communicate to the I2C memory module. 2) You mention the use of a miniOS. You should clarify just what this means. If you are actually using a formalized multi-tasking structure for this simple application you may want to reconsider this decision. It is so easy to build up embedded applications where you schedule most of your real time activities from timer interrupt triggers that the overhead of some formalized OS structure may be just too high of performance price to pay. 3) If you are interfaced to the I2C memory module at an interface rate of 100kHz, the standard full speed of the I2C bus, my rough calculation shows that such 256 byte page writes are going to take about 25 to 28 milliseconds to complete the raw data transfer. You then have the write pulse time of the memory to consider on top of that if you are using non-volatile type memory such as a serial EEPROM. You did not tell us how often you try to do this page write so it is hard to give much specific guidance. You should maybe consider using a memory module that could support a 400kHz or faster serial interface rate on the I2C interface. Take a serious look at an 8052 derivative that has an onboard I2C peripheral and use that to get as fast as possible transfer rate. Also consider looking at some memory technology that may not have the write pulse delay penalty like EEPROM has. Look into serial FLASH or FRAM. 4) You did not tell us how the sensor is interfaced to the MCU. If that is also interfaced via I2C and you are reading the sensor on a periodic basis then maybe that activity is colliding with the time span it takes to write the blocks of data to the I2C memory module. In this case you may need to consider using a sensor that interfaces in a different way. Consider a SPI device or a sensor that uses an on-board A/D converter of the microcontroller. 5) It seems to me that you have to evaluate carefully how much time the sensor activity and the page write activity are actually taking in your specific system. You should deploy two spare port pins and set one high at the beginning of each of these two activities and then back low as the respective activity completes. You can then evaluate the system timing performance on an oscilloscope. Sometimes this can be quite enlightening as to what your code actually is doing. 6) Lastly there is a possibility that the memory buffer pool structure that you are using may not be a safe design from the aspect of two processes accessing control variables, indexes, or pointers at the same time. Look carefully at this and think through what can happen if one task is in the midst of using/updating a multi-byte control variable or pointer whilst the other task comes along and changes it. Sometimes it is necessary to use queues that have separate input and output mechanisms to prevent collisions. Other times it is as simple as disabling interrupts around certain critical code sections. Michael Karas |
Topic | Author | Date |
I2C page write and interrupts | 01/01/70 00:00 | |
Some Important Things to Consider | 01/01/70 00:00 | |
Re: Some Important Things to Consider | 01/01/70 00:00 | |
You just buffer things | 01/01/70 00:00 | |
ISR + superloop normally enough | 01/01/70 00:00 | |
A Quick Reply | 01/01/70 00:00 | |
Re: A Quick Reply | 01/01/70 00:00 | |
Confirmation | 01/01/70 00:00 | |
The Atmel Scheduler | 01/01/70 00:00 | |
Re: The Atmel Scheduler | 01/01/70 00:00 | |
Your times seem quite long | 01/01/70 00:00 | |
Re: Your times seem quite long | 01/01/70 00:00 | |
The problem seems to be different | 01/01/70 00:00 | |
Time to closely read data sheet. | 01/01/70 00:00 | |
Re: Time to closely read data sheet. | 01/01/70 00:00 | |
Write a generic function.![]() | 01/01/70 00:00 | |
Paged operation very common | 01/01/70 00:00 |