The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers.    


Datasheet Search Engine   
 
Part # or Description: • 5V RS232 Driver • 2SC5066* • "Real Time Clock" • "USB connector" • "blue led" 5mm • 10 watt zener diode • 2N3055* motorola
 
Search Tip: Try entering the part number only. Include a wildcard (eg. lm317* or 1n4148*)

 

 

AN017704-0504 This publication subject replacement later edition.


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet



Page-EEPROM Interface Using eZ80F91 Server
AN017704-0504
This publication subject replacement later edition. determine whether later edition exists, request copies publications, contact: ZiLOG Worldwide Headquarters
Race Street Jose, 95126 Telephone: 408.558.8500 Fax: 408.558.8300 www.zilog.com
ZiLOG registered trademark ZiLOG Inc. United States other countries. other products and/or service names mentioned herein trademarks companies with which they associated.
Information Integrity
information contained within this document been verified according general principles electrical mechanical engineering. applicable source code illustrated document either written authorized ZiLOG employee licensed consultant. Permission these codes form, besides intended application, must approved through license agreement between both parties. ZiLOG will responsible code(s) used beyond intended application. Contact local ZiLOG Sales Office obtain necessary license agreements.
Document Disclaimer
©2004 ZiLOG, Inc. rights reserved. Information this publication concerning devices, applications, technology described intended suggest possible uses superseded. ZiLOG, INC. DOES ASSUME LIABILITY PROVIDE REPRESENTATION ACCURACY INFORMATION, DEVICES, TECHNOLOGY DESCRIBED THIS DOCUMENT. ZiLOG ALSO DOES ASSUME LIABILITY INTELLECTUAL PROPERTY INFRINGEMENT RELATED MANNER INFORMATION, DEVICES, TECHNOLOGY DESCRIBED HEREIN OTHERWISE. Except with express written approval ZiLOG, information, devices, technology critical components life support systems authorized. licenses other rights conveyed, implicitly otherwise, this document under intellectual property rights.
AN017704-0504
Application Note Page-EEPROM Interface Using eZ80F91 Server
Table Contents
List Figures Abstract ZiLOG Product Overview eZ80Acclaim!MCU Family Overview ZiLOG TCP/IP Software Suite Overview Discussion Developing Page-EEPROM Interface Application Page-EEPROM Interface HTML Files Application-Specific Functions EEPROM APIs Adding Integrating Application-Specific Files Demonstration Requirements Setup Settings Procedure Observations Summary Appendix A-Reference Appendix B-Source Code Files Header Files
AN017704-0504
Table Contents
Application Note Page-EEPROM Interface Using eZ80F91 Server
List Figures
Figure General Data Communication Path Figure Machine Control Demo Page
AN017704-0504
List Figures
Application Note Page-EEPROM Interface Using eZ80F91 Server
Abstract
This Application Note describes develop page interface transfer data from/to peripheral hardware device EEPROM this case) using server capabilities offered eZ80F91 conjunction with ZiLOG's software. page interface provides communication interface between page EEPROM device peripheral eZ80F91 MCU. Using HTTP-specific APIs stack on-chip peripheral, data received from page stored EEPROM and, upon request received from page, stored data retrieved displayed page. AN0177-SC01.zip file contains source code associated with this Application Note available ZiLOG website.
ZiLOG Product Overview
This section contains brief overviews ZiLOG products used this Application Note, which includes award-winning eZ80Acclaim!microcontrollers full-feature ZiLOG TCP/IP software suite.
eZ80Acclaim!MCU Family Overview
eZ80Acclaim!family microcontrollers includes Flash non-Flash products. Flash-based eZ80Acclaim!MCUs, device numbers eZ80F91, eZ80F92, eZ80F93, exceptional value customers designing high performance embedded applications. With speeds 50MHz on-chip Ethernet (eZ80F91 only), designers have performance necessary execute complex applications supporting networking functions quickly efficiently. Combining on-chip Flash SRAM, eZ80Acclaim!devices provide memory required implement communication protocol stacks achieve flexibility when performing in-system updates application firmware. ZiLOG also offers eZ80Acclaim!devices without Flash memory: eZ80L92 eZ80190 microprocessors.
ZiLOG TCP/IP Software Suite Overview
ZiLOG TCP/IP Software Suite (ZTP) integrates rich networking services with efficient real-time operating system (RTOS). operating system compact preemptive multitasking, multithreaded kernel with inter-process communications (IPC) support soft real-time attributes. Table lists standard network protocols implemented part embedded TCP/IP protocol stack ZTP.
AN017704-0504
Abstract
Application Note Page-EEPROM Interface Using eZ80F91 Server
Table Standard Network Protocols HTTP DHCP ICMP TFTP IGMP SMTP TIMEP Telnet SNMP RARP
Many TCP/IP application protocols designed using client-server model. final stack size link time configurable determined protocols included build.
Discussion
Figure depicts general data communication path using eZ80F91 Development with EEPROM device, ZPAKII, Ethernet Hub. With this hardware, eZ80F91 ready used efficient server when ZiLOG's software downloaded provides software drive hardware used TCP/IP connections. hardware comprises SERIAL1 (UART1) port connections Ethernet Media Access Controller (EMAC) Ethernet connections.
eZ80F91 Development (eZ80F910200ZC0) RS-232 ZPAK eZ80 Development Platform Ethernet Ethernet
Ethernet
Port
Ethernet
EEPROM
LAN/WAN/INTERNET
Figure General Data Communication Path
ZiLOG TCP/IP Software Suite (ZTP) contains libraries that implement embedded TCP/IP stack includes pre-emptive, multi-tasking kernel.
AN017704-0504
Discussion
Application Note Page-EEPROM Interface Using eZ80F91 Server
Applications Programming Interface (API) allows programmers using member eZ80® family microprocessors/controllers rapidly develop Internet-ready applications with minimal effort. Because common members eZ80® family, applications targeting processor easily ported other eZ80® devices. HTTP Functions Embedded systems typically contain file system. Lack file system implies that embedded systems cannot save scripts separate *.cgi files. Instead saving scripts separate *.cgi files, uses function calls, collectively called functions. When function called, generates HTML page that sent browser. these function calls that programmer writes code read information sent form browser. This information then processed required application. provides following functions user.
http_output_reply(http_request *request, reply) char *http_find_argument (http_request *request, char *arg) _http_write (http_request *request, char *buff, count)
each function, pointer request structure used keep requests from different clients separate. function http_output_reply() used return acknowledgement browser that made request. http_find_argument function used extract parameters from received data parsed browser request. macro _http_write used return data browser that sent request that invoked function. detailed information protocols used ZTP, refer Programmer's Guide Reference Manual (RM0008), available with software.
Developing Page-EEPROM Interface Application
This section discusses APIs, EEPROM APIs, HTML pages functions, includes section interface application-specific files standard ZTP. peripheral eZ80F91 used communicate with EEPROM. data received from page stored EEPROM upon request same information data retrieved from EEPROM displayed page.
AN017704-0504
Developing Page-EEPROM Interface Application
Application Note Page-EEPROM Interface Using eZ80F91 Server
Page-EEPROM Interface HTML Files
Figure screen shot Machine Control Demo page (mcd.htm) that contains columns: Write Data column Read Data column. Write Data column allows users submit data programmed into EEPROM memory, while Read Data column allows users read data obtained from EEPROM memory.
Figure Machine Control Demo Page
Write Data Read Data columns contain three buttons each, enabling user write read from three memory blocks EEPROM. These memory blocks referred Machine-1, Machine-2 Machine-3. Writing Data EEPROM Device clicking button (Machine-1) Write Data column, pop-up window opens with HTML submission form that used obtain user input. This instance static page. achieve this functionality, JavaScript method
AN017704-0504
Developing Page-EEPROM Interface Application
Application Note Page-EEPROM Interface Using eZ80F91 Server
pop-up window called within mcd.htm file. wm1() function presented below example:
function wm1() popup
When form with user input submitted, hidden variable with value equal sent write data Machine-1 memory block. mcd.htm file, three such methods (wm1(), wm2(), wm3()) implemented three memory blocks EEPROM. JavaScript function checks input fields values entered. values according specification, then alert sent Browser window display error message. JavaScript also checks that none fields left blank throws error null value field found. Reading Data from EEPROM Device clicking button (Machine-1) Read Data column, pop-up window opens displaying data retrieved from EEPROM memory block Machine-1. This instance dynamic page. JavaScript function calls i2cread_cgi() function which responsible reading data from appropriate memory block this case Machine-1 memory block). read1() function presented below example:
Function read1() popup top=250");
above script, value identifying clicked button sent along with read request. value hidden=1 identifies that read request generated reading values from Machine-1 memory block EEPROM. read2() read3()functions also call i2cread_cgi() function. values hidden indicating that read requests were generated reading values from Machine-2 Machine-3 memory blocks EEPROM.
AN017704-0504
Developing Page-EEPROM Interface Application
Application Note Page-EEPROM Interface Using eZ80F91 Server
Application-Specific Functions
Page-EEPROM Interface application functions, i2cread_cgi() i2cwrite_cgi(), used. These functions available i2c_cgi.c file. These functions call HTTP functions order read user input from HTML form display information fetched from EEPROM page. section HTTP Functions page i2cwrite_cgi() function, invoked when button Write Data column clicked, structured follows:
i2cwrite_cgi(struct http_request *request)
This function calls HTTP function, http_output_reply(), send acknowledgement client browser. http_find_argument() function called fetch user input data from HTML form. This user input data then transferred over EEPROM using APIs, input data written specified memory block EEPROM using EEPROM-specific APIs. macro _http_write used write success message, which displayed page. i2c_read_cgi() function, invoked when button Read Data column clicked, structured follows:
i2cread_cgi(struct http_request *request)
i2c_read_cgi() function first calls HTTP function, http_output_reply(), send acknowledgement client browser. http_find_argument()function called next determine from which memory block data must read. EEPROM APIs then called read from specified memory block EEPROM. Finally, macro _http_write used write retrieved data pop-up window.
EEPROM APIs
Controller eZ80F91 controls WRITE READ operations EEPROM. APIs re-entrant. Therefore, while process executing, next process queue executes only after first completes. Semaphores used maintain process synchronization. These semaphores created handled within application-specific functions. file, i2c.c, contains APIs specific peripheral eZ80F91 MCU.
AN017704-0504
Developing Page-EEPROM Interface Application
Application Note Page-EEPROM Interface Using eZ80F91 Server
eeprom.c file contains APIs perfom READ WRITE operations EEPROM. These APIs called within application-specific functions write read from EEPROM device.
Adding Integrating Application-Specific Files
Page-EEPROM Interface application described this Application Note requires eZ80® Development Platform that contains EEPROM device eZ80F91 with ZiLOG TCP/IP stack (ZTP). executing application, files specific application must added integrated stack before downloaded onto eZ80F91 eZ80® Development Platform. This section contains details adding application-specific files stack. Page-EEPROM Interface files that must added project files AN0177-SC01.zip file available ZiLOG website. application-specific files following types:
(*.c) files Header (*.h) files HTML (*.htm) files
stack available ZiLOG website downloaded with user registration key. installed location specified user; default location C:\Program Files\ZiLOG. Perform following steps integrate application files stack: Download ZTP, browse location where downloaded, open \website.Acclaim folder. Download AN0177-SC01.zip file extract contents folder your (this folder referred \Webpage_Interface folder rest Application Note). Notice extracted folders within \WebPage_Interface folder:
\WP_Demo \WP_Website.Acclaim
Select copy *.htm files \WebPage_Interface \WP_Website.Acclaim folder paste them into .\ZTP\website.Acclaim folder. Select copy *.c, files located \WebPage_Interface\WP_Demo folder paste them into .\ZTP\Demo directory.
AN017704-0504
Developing Page-EEPROM Interface Application
Application Note Page-EEPROM Interface Using eZ80F91 Server
Launch ZDSII eZ80Acclaim! open project file, website.pro located path: .\ZTP\website.Acclaim. *.htm files located .\website.Acclaim folder project, using sequence steps: Project Files. *.htm files added listed below:
Wm1.htm Wm2.htm Wm3.htm Mcd.htm Mcdf.htm
Open website.c file from within ZDSII, enter following prototype declarations into
extern struct staticpage mcd_htm; extern struct staticpage mcdf_htm; extern struct staticpage wm1_htm; extern struct staticpage wm2_htm; extern struct staticpage wm3_htm; extern i2cwrite_cgi (struct http_request *request); extern i2cread_cgi (struct http_request *request);
website.c file contains array, Webpage website[], with information HTML pages. Replace last line array, NULL, NULL, NULL with following lines:
{HTTP_PAGE_STATIC,"/mcd.htm", "text/html", &mcd_htm {HTTP_PAGE_STATIC, "/mcdf.htm", "text/html", &mcdf_htm}, &wm1_htm}, &wm2_htm}, &wm3_htm {HTTP_PAGE_DYNAMIC, staticpage*)i2cwrite_cgi {HTTP_PAGE_DYNAMIC, "/cgi-bin/i2cread", "text/html", (struct staticpage*)i2cread_cgi
AN017704-0504
Developing Page-EEPROM Interface Application
Application Note Page-EEPROM Interface Using eZ80F91 Server
NULL, NULL, NULL
From within ZDSII, open left.htm file under \Web Files. Search Calculator locate following line:
&nbsp;&nbsp; href="cgif.htm" target="_top">CGI Calculator</a></font><p><font face="Verdana" size="1"><b>Site Info
Enter following peice HTML code below code presented above, create link from eZ80Acclaim!home page Machine Control Demo page.
Machine Ctrl Demo&nbsp;&nbsp; href="mcdf.htm" target="_top">Machine Control</a>
Build website.pro project obtain library file, Acclaim_website.lib. Copy this library file path: .\ZTP\libs.
Note: Please note that .ZTP\libs folder already contains Acclaim_website.lib file must replaced with newly generated file. Click replace file. Close website.pro project. ZDSII, open AcclaimDemo.pro file available path: .\ZTP\Demo. files located .\WebPage_Interface\WP_Demo folder project, using sequence steps: Project Files. files added listed below:
eeprom.c i2c.c i2c_cgi.c
Open main.c file AcclaimDemo project following include file:
#include<eeprom.h>
AN017704-0504
Developing Page-EEPROM Interface Application
Application Note Page-EEPROM Interface Using eZ80F91 Server
main.c file, observe following BootInfo structure definition:
struct BootInfo Bootrecord "192.168.1.1",/* Default address "192.168.1.4",/* Default Gateway "192.168.1.5",/* Default Timer Server "192.168.1.6",/* Default File Server "192.168.1.7",/* Default Name Server 0xffffff00UL/* Default Subnet Mask
Bootrecord variable contains network parameters settings four-octet dotted decimal format) that specific local area network ZiLOG default. Modify above structure definition with appropriate addresses within your local area network. main.c file, following function prototypes global variables:
//global declarations extern SemaphoreID;
//prototype functions char load_init_value_eeprom (void);
main.c file, locate function open (SERIAL0, 0,0); following piece code above
SemaphoreID screate (1); if(SemaphoreID NULLPTR) kprintf(" Semaphore created");
Adding this code creates semaphore, which used controlling reentrancy issues associated with APIs.
AN017704-0504
Developing Page-EEPROM Interface Application
Application Note Page-EEPROM Interface Using eZ80F91 Server
main() function, just before return(OK); line code, following function call:
load_init_value_eeprom
main.c file, following function definition after main() function.
char load_init_value_eeprom() unsigned char load; unsigned char unsigned char *ptr1 (unsigned char*)0x0000; unsigned char *ptr2 (unsigned char*)0x0100; unsigned char *ptr3 (unsigned char*)0x0200; EEPROM_Open(); EEPROM_Write( ptr1, (unsigned char*)init_value,40); EEPROM_Write( ptr2, (unsigned char*)init_value,40); EEPROM_Write( ptr3, (unsigned char*)init_value,40); EEPROM_Close();
Open eZ80_HW_Config.c file change default address (provided ZTP) such that each eZ80® Development Platform contains unique address. example:
Const BYTEf91_mac_addr [EP_ALEN] {0x00, 0x90, 0x23, 0x00, 0xDF, 0x91};
6-byte address shown above, first three bytes must modified; last three bytes used assign unique address eZ80® Development Platform.
AN017704-0504
Developing Page-EEPROM Interface Application
Application Note Page-EEPROM Interface Using eZ80F91 Server
Open ipw_ez80.c file. this application, Dynamic Host Configuration Protocol (DHCP) disabled; therefore, ensure following:
b_use_dhcp FALSE
Save files close AcclaimDemo project.
Demonstration
This section contains requirements instructions PageEEPROM Interface demo
Requirements
requirements classified under hardware software. Hardware
Setup
eZ80F91 Development (eZ80F910200ZCO) with EEPROM device with Internet Browser HyperTerminal
Software ZiLOG Developer Studio ZiLOG ZDSII eZ80Acclaim! ZiLOG's TCP/IP stack (ZTP)
basic setup assemble Page-EEPROM Interface demo illustrated Figure page This setup illustrates connections between LAN/WAN/Internet eZ80F91 Development Kit.
Settings
HyperTerminal Settings
HyperTerminal 57.6 Kbps Baud 8-N-1, with flow control
Jumper Settings eZ80® Development Platform
AN017704-0504
J11, J20, J21, J14, connect
Demonstration
Application Note Page-EEPROM Interface Using eZ80F91 Server
J19, MEM_CEN1 CS_EX_IN, MEM_CEN2, MEM_CEN3
eZ80F91 Module eZ80® Development Platform
Procedure
procedure build Page-EEPROM Interface demo described this section. Ensure that required Page-EEPROM Interface demo files added integrated before proceeding. section Adding Integrating Application-Specific Files page details. Make connections Figure Follow jumper settings provided section Jumper Settings above. Connect 5-volt power supply ZPAKII 7.5-volt power supply Ethernet HUB. Launch HyperTerminal follow settings provided HyperTerminal Settings section page From within HyperTerminal, press repeatedly, then press reset button ZPAKII view menu ZPAKII address. Enter display help menu, follow menu instructions obtain address ZPAKII order download Demo file. This ZPAKII address must entered ZDSII. Launch ZDSII eZ80Acclaim! open Page-EEPROM Interface demo project file (AcclaimDemo.pro) located path: .\ZTP\Demo. Open main.c file. Ensure that BootInfo structure contains information that relevant your network configuration. address structure browse Internet view PageEEPROM Interface demo pages. Build project download resulting file eZ80F91 Module eZ80® Development Platform, using ZDSII. Page-EEPROM Interface demo. Refer Running Page-EEPROM Interface Demo section below.
AN017704-0504
Demonstration
Application Note Page-EEPROM Interface Using eZ80F91 Server
Running Page-EEPROM Interface Demo Launch Internet Browser Enter address specified
main.c. Index.html page displayed.
Click Machine control link located left pane. Machine Control Demo page displayed. Click Machine-1 button under Write Data column. Write data pop-up window opens displaying submission form. submission form consists Temperature, Temperature, Voltage Voltage fields.
Note: Enter values between 99.99. enter characters; only integers floating-point values accepted. value field limited integers with between represent floating-point value. Entries complying with these specifications cause error message displayed. maximum minimum temperature voltage values Machine-1. Click Submit button submit data. status pop-up window displayes that data successfully stored EEPROM. Repeat steps using Machine-2 Machine-3 buttons under Write Data column values those machines. back Machine Control Demo page clicking Machine control link left pane. Click Machine-1 button under Read Data column. Read data pop-up window displays values Machine-1. read values Machine-2 Machine-3, click Machine-2 Machine-3 buttons under Read Data column.
Observations
values machines were successfully written EEPROM device page interface I2C. This confirmed comparing data read from EEPROM device.
Summary
This Application Note demonstrates method capturing user input data from page storing external device, further displaying stored data page upon user request.
AN017704-0504
Summary
Application Note Page-EEPROM Interface Using eZ80F91 Server
This application further extended used industrial server, where server connected different machines control equipments that monitored controlled through intranet Internet.
AN017704-0504
Summary
Application Note Page-EEPROM Interface Using eZ80F91 Server
Appendix A-Reference
Further details about eZ80F91 found references listed Table
Table List References Topic eZ80F91 Document Name eZ80F91 Development User Manual (UM0142) eZ80F91 Flash with Ethernet Product Specifications (PS0192) eZ80F91 Module Product Specifications (PS0193) ZiLOG's TCP/IP Software Suite Programmer's Guide Reference Manual (RM0008)
AN017704-0504
Appendix A-Reference
Application Note Page-EEPROM Interface Using eZ80F91 Server
Appendix B-Source Code
This appendix provides listing source code Webpage-EEPROM Interface application. source code file AN0177-SC01.zip available along with Application Note ZiLOG website.
Files
following files listed this section:
eeprom.c I2C.c I2C_cgi.c
File: eeprom.c Description: This file contains implementations I2C-EEPROM
routines. This contains implementations that specific EEPROM device, which makes I2C.c protocol.
Copyright 2004 ZiLOG Inc. RIGHTS RESERVED. source code this file written authorized ZiLOG employee licensed consultant. source code been verified fullest extent possible. Permission this code granted royalty-free basis. However users cautioned authenticate code contained herein. ZiLOG DOES GUARANTEE VERACITY SOFTWARE. #include <ez80F91.h> #include "eeprom.h" initialize eZ80 device; perform polling just ensure target device exists
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
UINT EEPROM_Open( VOID initialize eZ80 device I2C_Init() return EEPROMERR_SUCCESS EEPROM_Open()
close EEPROM device UINT EEPROM_Close( VOID close eZ80 device return I2C_Close() }/** EEPROM_Close()
Write more bytes into eeprom device sends 'device addressing' beginning every block/page then sends data bytes write. This routine implements both 'byte write' 'page write' operations eeprom device UINT EEPROM_Write( BYTE* address, BYTE* buffer, UINT16 count UINT16 index UINT status BYTE *ptr send start condition, configure slave address, send memory address bytes, then followed data bytes data bytes sent
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
transmit data for( index=0,ptr=address; index<count; index++,ptr++ initiate 'device addressing' before sending byte sending bytes positioned beginning pages if(( ((UINT32)ptr EEPROM_PAGESIZE) 0)||( index==0 perform polling before sending page EEPROM_AckPolling() device addressing status EEPROM_DeviceAddressing( ptr, I2CMODE_MASTERTRANSMIT 'device addressing' failed status EEPROMERR_SUCCESS return status 'initiate device addressing' send byte status I2C_TransmitDataByte( buffer[ index status EEPROM_GetError( status 'send byte' failed status EEPROMERR_SUCCESS return status send STOP last byte buffer/page
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
(UINT32)(ptr+1)%EEPROM_PAGESIZE 0/** last byte page*/ OR*/ (index+1) count) last byte buffer I2C_SendStop()
}/** for:'transmit data' return EEPROMERR_SUCCESS }/** EEPROM_Write()
Read more bytes from eeprom device -set eeprom device address pointer with 'address' then perform read 'count' number times This routine implements only 'sequential read' operation eeprom device UINT EEPROM_Read( BYTE* address, BYTE* buffer, UINT16 count UINT16 index UINT status VOID *ptr BYTE databyte BYTE temp
perform polling EEPROM_AckPolling()
eeprom device address pointer with value 'address' performing dummy write operation device
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
address address pointer -'device addressing' will this status EEPROM_DeviceAddressing( ptr, I2CMODE_MASTERTRANSMIT status EEPROM_GetError( status 'device addressing' failed status EEPROMERR_SUCCESS return status
device addressing master receive status EEPROM_DeviceAddressing( ptr, I2CMODE_MASTERRECEIVE status EEPROM_GetError( status 'device addressing' failed status EEPROMERR_SUCCESS return status that eeprom device ready transmit, perform reads for( index=0; index<count; index++ clear iflag receive data bytes from slave this byte last read (index+1) count 'not ack' sent receiving this byte reset clear iflag I2C_ResetAAKClearIFlag() else
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
'ack' sent receiving this byte -set clear iflag I2C_SetAAKClearIFlag( temp receive data byte status I2C_ReceiveDataByte( &databyte
data byte received -read validate status before reading data bytes received (index+1) count 'not ack' transmitted status I2CERR_DATABYTERXDMMODE_ACKTXD status EEPROMERR_FAILURE break }/** 'not transmitted' }/** 'not bytes received' else bytes received transmitted status I2CERR_DATABYTERXDMMODE_NACKTXD status EEPROMERR_FAILURE break }/** 'ack transmitted'
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
send STOP I2C_SendStop() }/** 'all bytes received' read data into buffer buffer[ index databyte status EEPROM_GetError( status }/** 'for'
back I2C_SetAAK()
return status }/** EEPROM_Read()
eeprom supporting functions acknowledge polling UINT EEPROM_AckPolling( VOID UINT status UINT32 send START, send write control byte, then poll typical timeout for(i=0;i<0xffff;i++) status status EEPROMERR_SUCCESS
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
break return status
}/** EEPROM_AckPolling()
send START, then followed control byte write UINT VOID return EEPROM_SLVADD, I2CMODE_MASTERTRANSMIT
sends START, control byte, address high byte, then address byte UINT EEPROM_DeviceAddressing(VOID* address, I2CENUM_ModeMask modemask) UINT status send start condition, configure slave address, send memory address bytes send start condition, control byte -configure slave address status I2C_ConfigSlaveAddress( EEPROM_SLVADD, modemask status EEPROM_GetError( status 'config slave address' failed status EEPROMERR_SUCCESS return status
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
eZ80 receive mode, return status from here modemask I2CMODE_MASTERRECEIVE return status
send address high byte status I2C_TransmitDataByte( (BYTE)((UINT16)address>>8) status EEPROM_GetError( status 'send address high byte' failed status EEPROMERR_SUCCESS return status now, send address byte status I2C_TransmitDataByte( (BYTE)address status EEPROM_GetError( status return status EEPROM_DeviceAddressing() Translates error codes corresponding eeprom error codes higher layers application. This routine enhanced widen error interpretation higher layers application
UINT EEPROM_GetError( UINT status switch( status case I2CERR_SUCCESS: case I2CERR_DATABYTERXDMMODE_ACKTXD:
success data byte received master mode, transmitted data byte received master mode, transmitted
case
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
status EEPROMERR_SUCCESS break case I2CERR_STARTFAIL: fail send start case I2CERR_ARBLOST: arbitration lost case arbitration lost, slave address received, transmitted case arbitration lost, slave address received, transmitted case arbitration lost, general call address received, transmitted case I2CERR_SLAWTXD_ACKNRXD: slave address transmitted, acknowledge received case I2CERR_SLARTXD_ACKNRXD: slave address transmitted, received case data byte transmitted master mode, received status EEPROMERR_BUSERROR break case I2CERR_TIMEOUT: status EEPROMERR_TIMEOUT break break unkown error/status case I2CERR_FAILURE: default: status EEPROMERR_FAILURE break }/** 'switch' timeout occurred
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
return status }/** EEPROM_GetError()
*********************** file
File: i2c.c Description: This contains implementations protocol Copyright 2004 ZiLOG Inc. RIGHTS RESERVED. source code this file written authorized ZiLOG employee licensed consultant. source code been verified fullest extent possible. Permission this code granted royalty-free basis. However users cautioned authenticate code contained herein. ZiLOG DOES GUARANTEE VERACITY SOFTWARE.
#include <ez80F91.h> #include "i2c.h" Initialize VOID I2C_Init( VOID I2C_SRR I2C_SRESET clock register configuring sampling frequency (Fsamp) clock output frequency (Fscl)
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
Fsamp should least 1MHz (for 100kbps) (for 400kbps) Fsamp=50 MHz, would result Fscl=416 turns M=11. Register: field -0(1):M(11):N(0) value -0:1011:000 0x58 I2C_CCR 0X58; I2C_CTL 0x44 return
enab
I2C_Init() Configure slave address with user given value master transmit receive mode UINT I2C_ConfigSlaveAddress( BYTE slave_address, I2CENUM_ModeMask modemask BYTE ctlbyte UINT status UINT count status I2C_SendStart() send start condition begin transaction status I2CERR_SUCCESS I2C_SendStop() fail!!! I2C_Init() soft reset return status 'start failed' ctlbyte slave_address modemask frame control byte I2C_DR ctlbyte load control byte transmitted I2C_ClearIFlag() clear iflag transmit control byte I2C_POLL_IFLG( count, COUNT_POLL_IFLG poll iflag I2C_CTL I2CMASK_GET_IFLG iflag status I2CERR_FAILURE ;/** default status failure
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
switch( I2C_SR )/** check status slave address transmitted successfully slave address transmitted, received case I2CSTAT_SLAWTXD_ACKRXD: modemask I2CMODE_MASTERTRANSMIT status I2CERR_SUCCESS break slave address transmitted, received case I2CSTAT_SLARTXD_ACKRXD: modemask I2CMODE_MASTERRECEIVE status I2CERR_SUCCESS break slave address transmitted, received case I2CSTAT_SLAWTXD_ACKNRXD: status I2CERR_SLAWTXD_ACKNRXD break slave address transmitted, received case I2CSTAT_SLARTXD_ACKNRXD: status I2CERR_SLARTXD_ACKNRXD break
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
arbitration lost case I2CSTAT_ARBLOST: status I2CERR_ARBLOST break arbitration lost, slave address received, transmitted case I2CSTAT_ARBLOST_SLAWRXD_ACKTXD: status I2CERR_ARBLOST_SLAWRXD_ACKTXD break arbitration lost, slave address received, transmitted case I2CSTAT_ARBLOST_SLARRXD_ACKTXD: status I2CERR_ARBLOST_SLARRXD_ACKTXD break arbitration lost, general call address received, transmitted case status I2CERR_ARBLOST_GLCLADRXD_ACKTXD break 'switch' 'iflag set' timeout else status I2CERR_TIMEOUT
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
'timeout' return status I2C_ConfigSlaveAddress()
Send START condition return status caller UINT I2C_SendStart( VOID UINT count UINT status BYTE temp Enter master transmit mode: send start condition begin transmission temp I2C_CTL temp temp I2CMASK_SET_STA temp temp I2CMASK_CLR_IFLG I2C_CTL temp
I2C_POLL_IFLG( count, COUNT_POLL_IFLG poll iflag I2C_CTL I2CMASK_GET_IFLG iflag START repeated START transmitted if((I2C_SR I2CSTAT_STARTTXD)||(I2C_SR I2CSTAT_RPTDSTARTTXD)) status I2CERR_SUCCESS else status I2CERR_STARTFAIL START fail 'iflag set'
else status I2CERR_TIMEOUT timeout 'timeout'
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
return status I2C_SendStart()
VOID I2C_SendStop( VOID BYTE temp temp I2C_CTL temp temp I2CMASK_SET_STP temp temp I2CMASK_CLR_IFLG I2C_CTL temp return I2C_SendStop()
send stop condition
Close communication soft-resetting setup
UINT I2C_Close( VOID I2C_SRR I2C_SRESET
soft reset
Make sure reset happened checking STA, IFLG bits zeros I2C_CTL I2CMASK_SRESET_CONFIRM return I2CERR_CLOSEFAIL return I2CERR_SUCCESS I2C_Close()
transmits given data byte over UINT I2C_TransmitDataByte( BYTE data UINT count UINT status
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
I2C_DR data
place data byte transmitted data register clear iflag transmit data byte
I2C_ClearIFlag()
poll iflag data byte transfer complete I2C_POLL_IFLG( count, COUNT_POLL_IFLG iflag I2C_CTL I2CMASK_GET_IFLG switch( I2C_SR case status I2CERR_SUCCESS break case status I2CERR_DATABYTETXDMMODE_ACKNRXD break case I2CSTAT_ARBLOST: status I2CERR_ARBLOST break default: status I2CERR_FAILURE break 'switch' 'iflag set'
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
timeout else status I2CERR_TIMEOUT 'timeout' return status I2C_TransmitDataByte()
receives data byte over UINT I2C_ReceiveDataByte( BYTE *data UINT count UINT status poll iflag I2C_POLL_IFLG( count, COUNT_POLL_IFLG iflag I2C_CTL I2CMASK_GET_IFLG while((I2C_SR I2CSTAT_SLARTXD_ACKRXD) (count COUNT_POLL_SR) count++ read data *data I2C_DR data byte received, transmitted I2C_SR I2CSTAT_DATABYTERXDMMODE_ACKTXD status I2CERR_DATABYTERXDMMODE_ACKTXD 'data received, transmitted' data byte received, transmitted
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
else I2C_SR status I2CERR_DATABYTERXDMMODE_NACKTXD 'data received, transmitted arbitration lost else I2C_SR I2CSTAT_ARBLOST status I2CERR_ARBLOST 'arb lost' unknown error else status I2CERR_FAILURE 'unknown' error 'iflag set'
timeout else status I2CERR_TIMEOUT 'timeout' return status I2C_ReceiveDataByte()
************************ file
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
File: i2c_cgi.c Description: This file contains functions invoking write read device. Copyright 2004 ZiLOG Inc. RIGHTS RESERVED. source code this file written authorized ZiLOG employee licensed consultant. source code been verified fullest extent possible. Permission this code granted royalty-free basis. However users cautioned authenticate code contained herein. ZiLOG DOES GUARANTEE VERACITY SOFTWARE. #include #include #include #include <stdlib.h> <http.h> <httpd.h> <eeprom.h> MACHINE
#define MACHINE11 #define MACHINE22 #define MACHINE33 extern extern extern extern
UINT EEPROM_Open(VOID); UINT EEPROM_Close(VOID); UINT EEPROM_Write( BYTE* address, BYTE* buffer, UINT16 count UINTEEPROM_Read( BYTE* address, BYTE* buffer, UINT16 count
char i2c_done[] {"<html><title>Update Status</title><body bgcolor=\"#D2C87B\"><p align \"left\"><font face=\"arial\" color=\"black\" size=\"2\">DATA UPDATED SUCCESSFULLY EEPROM</ font></body></html>"}; char body_tag[] {"<html><head></head><body bgcolor=\"#D2C87B\"><div width=\"330\" border=\"0\" ><td><font face=\"arial\" color=\"black\" size=\"2\">"};
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
char body_tag1[] char read_m1[] {"<body topmargin=\"0\"><p align=\"center\"><font face=\"arial\" size=\"3\" color=\"red\"><strong>Reading Machine Data</strong></font></body>"}; char read_m2[] {"<body topmargin=\"0\"><p align=\"center\"><font face=\"arial\" size=\"3\" color=\"red\"><strong>Reading Machine Data</strong></font></body>"}; char read_m3[] {"<body topmargin=\"0\"><p align=\"center\"><font face=\"arial\" size=\"3\" color=\"red\"><strong>Reading Machine Data</strong></font></body>"}; SemaphoreID; This function reads input variables from page write data appropriate location EEPROM i2cwrite_cgi(struct http_request *request) short machine_no; char *machine_id; max_temp char*)"mat"); min_temp char*)"mit"); max_voltage char*)"mav"); min_voltage char*)"miv"); machine_id char*)"hidden"); machine_no atoi(machine_id); wait( SemaphoreID if(machine_no MACHINE1) unsigned char *ptr (unsigned char*)0x0000 WRITE DATA FROM LOCATION 0X0000 EEPROM_Open(); EEPROM_Write( ptr,(unsigned char*) max_temp, EEPROM_Write( ptr+6, (unsigned char*)min_temp, EEPROM_Write( ptr+12, (unsigned char*)max_voltage, EEPROM_Write( ptr+18, (unsigned char*)min_voltage,
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
EEPROM_Close() else if(machine_no MACHINE2) unsigned char *ptr (unsigned char*)0x0100;// WRITE DATA FROM LOCATION 0x0100 EEPROM_Open(); EEPROM_Write( ptr,(unsigned char*) max_temp, EEPROM_Write( ptr+6, (unsigned char*)min_temp, EEPROM_Write( ptr+12, (unsigned char*)max_voltage, EEPROM_Write( ptr+18, (unsigned char*)min_voltage, EEPROM_Close() else if(machine_no MACHINE3) unsigned char *ptr (unsigned char*)0x0200;// WRITE DATA FROM LOCATION 0x0200 EEPROM_Open(); EEPROM_Write( ptr, (unsigned char*)max_temp, EEPROM_Write( ptr+6, (unsigned char*)min_temp, EEPROM_Write( ptr+12, (unsigned char*)max_voltage, EEPROM_Write( ptr+18,(unsigned char*) min_voltage, EEPROM_Close(); signal( SemaphoreID
i2cread_cgi(struct http_request *request) char m_temp1[100]={" temp Deg.C machine1: char m_temp2[100]={" temp Deg.C machine2: char m_temp3[100]={" temp Deg.C machine3: char low_temp1[100] ={"The temp Deg.C machine1: char low_temp2[100] ={"The temp Deg.C machine2: char low_temp3[100] ={"The temp Deg.C machine3:
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
char m_voltage1[100] ={"The voltage machine1: char m_voltage2[100] ={"The voltage machine2: char m_voltage3[100] ={"The voltage machine3: char low_voltage1[100]={"The voltage machine1: char low_voltage2[100]={"The voltage machine2: char low_voltage3[100]={"The voltage machine3:
short machine_no; char *machine_id;
machine_id char*)"hidden"); machine_no atoi(machine_id); wait( SemaphoreID if(machine_no MACHINE1) unsigned char *ptr (unsigned char*)0x0000 Read DATA FROM LOCATION 0X0000 EEPROM_Open(); EEPROM_Read( ptr,(unsigned char*) max_temp, EEPROM_Read( ptr+6, (unsigned char*)min_temp, EEPROM_Read( ptr+12, (unsigned char*)max_voltage, EEPROM_Read( ptr+18, (unsigned char*)min_voltage, EEPROM_Close() strcat(m_temp1,max_temp); strcat(low_temp1,min_temp); strcat(m_voltage1,max_voltage);
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
else if(machine_no MACHINE2) unsigned char *ptr (unsigned char*)0x0100;// Read DATA FROM LOCATION 0x0100 EEPROM_Open(); EEPROM_Read( ptr,(unsigned char*) max_temp, EEPROM_Read( ptr+6, (unsigned char*)min_temp, EEPROM_Read( ptr+12, (unsigned char*)max_voltage, EEPROM_Read( ptr+18, (unsigned char*)min_voltage, EEPROM_Close() strcat(m_temp2,max_temp); strcat(low_temp2,min_temp); strcat(m_voltage2,max_voltage); else if(machine_no MACHINE3) unsigned char *ptr (unsigned char*)0x0200;// Read DATA FROM LOCATION 0x0200 EEPROM_Open(); EEPROM_Read( ptr, (unsigned char*)max_temp, EEPROM_Read( ptr+6, (unsigned char*)min_temp, EEPROM_Read( ptr+12, (unsigned char*)max_voltage, EEPROM_Read( ptr+18,(unsigned char*) min_voltage, EEPROM_Close();
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
strcat(m_temp3,max_temp); strcat(low_temp3,min_temp); strcat(m_voltage3,max_voltage); signal( SemaphoreID ************************* file
Header Files
following Header files presented this section:
eeprom.h I2C.h
File: eeprom.h Description: Header file Copyright 2004 ZiLOG Inc. RIGHTS RESERVED. source code this file written authorized ZiLOG employee licensed consultant. source code been verified fullest extent possible. Permission this code granted royalty-free
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
basis. However users cautioned authenticate code contained herein. ZiLOG DOES GUARANTEE VERACITY SOFTWARE. #include <i2c.h> #define EEPROM_PAGESIZE #define EEPROM_SLVADD prototypes UINT UINT UINT UINT UINT UINT UINT UINT EEPROM_Open( VOID EEPROM_Close( VOID EEPROM_Write( BYTE*, BYTE*, UINT16 EEPROM_Read( BYTE*, BYTE*, UINT16) EEPROM_AckPolling( VOID EEPROM_GetError( UINT EEPROM_DeviceAddressing( VOID*, I2CENUM_ModeMask VOID 0xA0
enum eeprom_errors EEPROMERR_SUCCESS, EEPROMERR_BUSERROR, EEPROMERR_TIMEOUT, EEPROMERR_FAILURE ************************* file File: i2c.h Description: Header file Copyright 2004 ZiLOG Inc. RIGHTS RESERVED.
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
source code this file written authorized ZiLOG employee licensed consultant. source code been verified fullest extent possible. Permission this code granted royalty-free basis. However users cautioned authenticate code contained herein. ZiLOG DOES GUARANTEE VERACITY SOFTWARE. #include "basetypes.h" masks #define #define #define #define #define #define #define #define I2CMASK_SRESET_CONFIRM I2CMASK_SET_STA I2CMASK_SET_STP I2CMASK_SET_AAK I2CMASK_CLR_AAK I2CMASK_GET_IFLG I2CMASK_CLR_IFLG I2CMASK_CLR_IFLGAAK 0x38 0x20 0x10 0x04 0xFB 0x08 0xF7 0xF3
macros #define COUNT_POLL_IFLG #define COUNT_POLL_SR #define I2C_SRESET 500//5000 0x00FFFF 0x12
arbitrary value
specific #defineI2C_POLL_IFLG( )while( (!(I2C_CTL I2CMASK_GET_IFLG)) #defineI2C_SetAAK()I2C_CTL I2C_CTL I2CMASK_SET_AAK #defineI2C_ResetAAK()I2C_CTL I2C_CTL I2CMASK_CLR_AAK #define I2C_ClearIFlag()I2C_CTL I2C_CTL I2CMASK_CLR_IFLG #define I2C_ResetAAKClearIFlag()I2C_CTL I2C_CTL I2CMASK_CLR_IFLGAAK #define I2C_SetAAKClearIFlag( I2C_CTL I2CMASK_SET_AAK
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
I2CMASK_CLR_IFLG \I2C_CTL
cetain typedefs typedef void typedef unsigned VOID UINT
status codes -for within layer only enum i2c_status I2CSTAT_BUSERROR I2CSTAT_STARTTXD I2CSTAT_RPTDSTARTTXD I2CSTAT_SLAWTXD_ACKRXD I2CSTAT_SLAWTXD_ACKNRXD I2CSTAT_DATABYTETXDMMODE_ACKRXD I2CSTAT_ARBLOST I2CSTAT_SLARTXD_ACKRXD I2CSTAT_SLARTXD_ACKNRXD I2CSTAT_DATABYTERXDMMODE_ACKTXD I2CSTAT_ARBLOST_SLAWRXD_ACKTXD I2CSTAT_ARBLOST_SLARRXD_ACKTXD
0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x40, 0x48, 0x50, 0x58, 0x68, 0x78, 0xb0
error codes -for outside layer enum i2c_errors I2CERR_SUCCESS, I2CERR_TIMEOUT, I2CERR_STARTFAIL, I2CERR_CLOSEFAIL, status
AN017704-0504
Appendix B-Source Code
Application Note Page-EEPROM Interface Using eZ80F91 Server
I2CERR_SLAWTXD_ACKNRXD, I2CERR_SLARTXD_ACKNRXD, I2CERR_DATABYTERXDMMODE_ACKTXD, I2CERR_ARBLOST, I2CERR_ARBLOST_SLAWRXD_ACKTXD, I2CERR_ARBLOST_SLARRXD_ACKTXD, I2CERR_FAILURE //I2C modes typedef enum I2CENUM_ModeMask_t I2CMODE_MASTERTRANSMIT 0x00, I2CMODE_MASTERRECEIVE 0x01, I2CMODE_SLAVETRANSMIT, I2CMODE_SLAVERECEIVE I2CENUM_ModeMask //function prototypes VOID UINT UINT VOID UINT UINT UINT UINT I2C_Init( VOID I2C_ConfigSlaveAddress( BYTE, I2CENUM_ModeMask I2C_SendStart( VOID I2C_SendStop( VOID I2C_Close( VOID I2C_Stop( VOID I2C_TransmitDataByte( BYTE data I2C_ReceiveDataByte( BYTE *data
************************ file
AN017704-0504
Appendix B-Source Code

Other recent searches


TC7MH540 - TC7MH540   TC7MH540 Datasheet
TC7MH540FK - TC7MH540FK   TC7MH540FK Datasheet
TC7MH541FK - TC7MH541FK   TC7MH541FK Datasheet
STX817 - STX817   STX817 Datasheet
Si4430BDY - Si4430BDY   Si4430BDY Datasheet
Si4430DY - Si4430DY   Si4430DY Datasheet
Si4430BDY-T1-E3 - Si4430BDY-T1-E3   Si4430BDY-T1-E3 Datasheet
Si4430DY-T1-E3 - Si4430DY-T1-E3   Si4430DY-T1-E3 Datasheet
AM15E-CZ - AM15E-CZ   AM15E-CZ Datasheet
AD10265 - AD10265   AD10265 Datasheet
AD10242 - AD10242   AD10242 Datasheet
AD6640 - AD6640   AD6640 Datasheet
ACT3215A - ACT3215A   ACT3215A Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive