I2C Interface Connects Compact

i2c interface connects compact flash card to microcontroller
abstract:this application note explains how to use an i²c i/o extender to connect a compact-flash (cf) card to the i²c interface of a microcontroller. the software commands for reading and writing data are explained. the max7311 i/o port extender is featured in the design circuit.
this design idea appeared in the september 1, 2006 issue of edn magazine.
data logging usually requires considerable memory for storing the measured data, especially when the number of monitored channels is large. as a further complication, the limited internal data memory (ram and eeprom) of small microcontrollers and their lack of address and data ports often precludes the addition of external memory. the figure 1 circuit uses a 16-bit i²c i/o extender (u1, the max7311) to connect a compact-flash (cf) card to the i²c interface of a microcontroller. the i²c interface is a logical choice, because many circuits already use it for connecting external adcs, dacs, real-time clocks, and other components.
figure 1. this circuit employs a 16-bit i/o extender (the max7311) to connect a compact flash connector to the i²c bus of a microcontroller.
the cf card is controlled in memory-mapped mode with an 8-bit-wide data bus. the max7311's port 1 (i/o lines 0–7) connects to the data bus of the cf card; port 2 connects to the address and control signals. the cf card's data registers can be read and written with the input and output registers of port 1. port 2 addresses the correct register and generates the read and write signals.
to write to a specific register, you first write the data to port 1, configured as an output. next, you write to port 2 three consecutive times with the same data, except for the wrn pin which generates the write signal by toggling from 1 to 0 to 1. the address bits a2–a0 indicate the register to be written. a low on ce while rdn is high enables the cf card. a similar procedure lets you read from a specific register. port 1 is used as an input port, to be read after three writes to port 2, where the rdn pin generates read signals by toggling from 1 to 0 to 1. after the three writes, the circuit reads port 1 and makes the data available. the three address bits let you read, write, and address eight internal registers:
address register address register
0x00 data 0x04 cylinder low
0x01 error/features 0x05 cylinder high
0x02 sector count 0x06 select card/head
0x03 sector number 0x07 status/command
register 0x00 is used for data exchange between the host and the cf card. registers 0x03, 0x04, 0x05, and 0x06 are used to specify the track for reading or writing data. each track contains 512 data bytes. the processor indicates reading/writing tracks and other functions by writing to the command register. you can read the status and error registers to obtain status (busy, data ready, etc.) and error conditions.
the two unused pins on port 2 (i/os 10 and 11) can be used to drive leds showing circuit activity, or to read a jumper (set by the user) that instructs the processor to use or not use the card. if a second cf card is connected with a second max7311, the processor can switch from one card to the next; the user can unplug the card and process data on it without disturbing the data-logging process. the card is hot-pluggable when using a special cf connector. in that case, the max7311's interrupt output should be connected to an interrupt input on the microcontroller. thus, an interrupt generated by placing or removing the jumper can be used to trigger the processor to switch to another card.
software two i²c functions enable the microcontroller to read and write. if it has a hardware i²c interface, the functions can be quite simple. first, two functions are required for reading and writing to a max7311 port: write_max7311(slv,prt,dat) this procedure starts the i²c bus and sends data byte dat to port prt on the max7311 with slave address slv. read_max7311(slv,prt) this procedure starts the i²c bus and reads a data byte from port prt on the max7311 with slave address slv.the functions above are used to create two other functions, which read and write to the cf card registers: write_cf_reg(reg,dat) this procedure uses write_max7311 to place the data dat on port 1. the same procedure is used to place the register address reg on port 2, together with the other control signals. the write is executed three times (toggling wrn) to generate the write signal.
read_cf_reg(reg) this procedure uses write_max7311 to address the cf-card register and generate the read signal. the read_max7311 procedure then reads the data from the register. the functions available for reading and writing the card registers can now be used to create functions for accessing the cf-card sectors: write_cf(cyl,head,sec) this procedure uses write_cf_reg to designate the target cylinder, head, and sector (registers 0x03 to 0x06) in a write operation. the cf card is then configured for data writing by writing 0x30 to the command register. write_cf_reg is then executed 512 times to write the data (stored in a global array) to the data register. the cf card automatically adds this data to the current track.
read_cf(cyl,head,sec) this procedure uses write_cf_reg to designate the target cylinder, head, and sector in a read operation. the cf card is then configured for data reading by writing 0x20 to the command register. read_cf_reg is then executed 512 times to read all 512 bytes from the track through the data register, and to place the data in a global array.
爱芯元智上榜“中国AI芯片企业”先锋企业TOP 30
未来的人工智能,不一定都是善意的
嵌入式智能技术算不算超前的技术
隆利科技Mini背光模组厂募资3亿再扩张
常见的几款LED数显驱动芯片简介规格:VK16K33/VK1640B/VK1S68C
I2C Interface Connects Compact
中国超算有多厉害?国家超算天津中心首席专访
受日本禁令冲击,三星晶圆代工恐难如期交货
巨头扎堆布局VR生态 盘点2023 CESVR产品
荣耀5G双模手机性能分析,超高跑分的旗舰机
YOGO Robot推出智能配送站 机器人覆盖无人化配送流程
大圆柱电池对宝马的电动汽车有什么好处
诺基亚6后置指纹全面屏_诺基亚10配置怎么样?骁龙845加持!
启动视觉系统算法开发工作需要考虑的因素
电压互感器的容量分为哪几种?有什么区别
78%的硬件失效罪魁祸首是它
电池保护板如何测试好坏?有哪些注意事项?
汽车排气管三维扫描3D逆向建模设计服务解决方案
诺基亚5G创纪录,Meta加速元宇宙
智能手表销量下滑的背后 统一规则与差异化发展