Peripheral Logic Board Version: 1 - GOAL...

33
1| Page An ISO 9001-2008 Certified Company Goal Technologies -4 th Floor, Oberle Tower Balmatta .Mangalore www.goaltechnologies.in [email protected] 0824-4261407/4251407 Peripheral Logic Board Version: 1.0

Transcript of Peripheral Logic Board Version: 1 - GOAL...

Page 1: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

1 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e d C o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Peripheral Logic Board

Version: 1.0

Page 2: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

2 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e d C o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

J1 : 12V DC POWER SUPPLY

J2 : AN0- AN5 Analog input pins

J3 : RB0 – RB7 LCD display pins

J8 : RC0&RC5 I2C pins , RC1& RC2 PWM pins, RC3&RC4 RTC, External EEPROM pins RC6&RC7 UART

J9 : I/O pins

J10 : UART TTL output

P2 : UART RS232 output

J11 : GND

J12 : 5V power supply

J13: 12v power supply

POW: power supply part

Page 3: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

3 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e d C o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Peripheral Logic Board V1.0

Page 4: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

4 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e d C o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

One of the latest innovations in the domain of Electronics and Communication by the pioneers in

technology, Peripheral Logical Board is designed in compliance with the latest industrial standards

facilitating feature rich options implemented using the I2C protocol.

The main advantage of this board is Simplicity in programming and also compliments the existing

Microcontroller/Microprocessor boards as a daughter board to enhance the functionalities. This board

supports 5 channels ADC, 2 channels PWM, UART, LCD, RTC, Internal EEPROM ,External EEPROM ,Touch

screen , 1 ports (8bit) I/O with inbuilt function to ease programming.

Goal Technologies continues to maintain product excellence and performance by introducing innovative

Cost effective solutions to cater the needs of students who dream to innovate and excel in the field of

Electronics and Engineering- thus supporting an array of domains in real time, providing solutions you

can count on.

Introduction to I2c ProtocolSCL (Serial Clock Input) – SCL is used to synchronize data movement on the serial interface.

SDA (Serial Data Input/Output) – SDA is the input/output pin for the 2-wire serial interface.The SDA pin is open drain which requires an external pull up resistor.

Bus not busy: Both data and clock lines remain HIGH.

Start data transfer: A change in the state of the data line, from HIGH to LOW, while the clockis HIGH, defines a START condition.

Stop data transfer: A change in the state of the data line, from LOW to HIGH, while the clockline is HIGH, defines the STOP condition.

Page 5: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

5 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e d C o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Acknowledge: Each receiving device, when addressed, is obliged to generate an acknowledgeafter the reception of each byte. The master device must generate an extra clock pulse which isassociated with this acknowledge bit. A device that acknowledges must pull down the SDA lineduring the acknowledge clock pulse in such a way that the SDA line is stable LOW during theHIGH period of the acknowledge related clock pulse. Of course, setup and hold times must betaken into account. A master must signal an end of data to the slave by not generating anacknowledge bit on the last byte that has been clocked out of the slave. In this case, the slavemust leave the data line HIGH to enable the master to generate the STOP condition.

DATA TRANSFER ON 2-WIRE SERIAL BUS

1. Data transfer from a master transmitter to a slave receiver. The first bytetransmitted by the master is the slave address. Next follows a number of data bytes.The slave returns an acknowledge bit after each received byte. Data is transferred with themost significant bit (MSB) first.

2. Data transfer from a slave transmitter to a master receiver. The first byte (the slaveaddress) is transmitted by the master. The slave then returns an acknowledge bit. This isfollowed by the slave transmitting a number of data bytes. The master returns anacknowledge bit after all received bytes other than the last byte. At the end of the lastreceived byte, a “not acknowledge” is returned.

Page 6: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

6 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e d C o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

The master device generates all of the serial clock pulses and the START andSTOP conditions. A transfer is ended with a STOP condition or with a repeated STARTcondition. Since a repeated START condition is also the beginning of the next serial transfer,the bus will not be released. Data is transferred with the most significant bit (MSB) first.

DATA WRITE - SLAVE RECEIVER MODE

s 1001000 0 A XXXXXXXX A XXXXXXXX A XXXXXXXX A P

Slave address

DATA READ - SLAVE TRANSMITTER MODE

s 1001000 1 A XXXXXXXX A P

Slave address

Slave receiver mode ( write mode):

R/W

S STARTA ACKNOWLEGEP STOP

Word address

R/W

S STARTA ACKNOWLEGEP STOP

Data

Data/address Data

Page 7: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

7 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e d C o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Serial data and clock are received through SDA and SCL. After each byte isreceived an acknowledge bit is transmitted. START and STOP conditions are recognizedas the beginning and end of a serial transfer. Address recognition is performed byhardware after reception of the slave address and *direction bit (See Figure above). Theaddress byte is the first byte received after the start condition is generated by the master. Theaddress byte contains the 7 bit IC( ) address, which is 1001000, followed by the *directionbit (R/ W ) which, for a write, is a 0. After receiving and decoding the address byte the deviceoutputs an acknowledge on the SDA line. After the IC( )acknowledges the slave address + writebit, the master transmits a register address to the IC( ) This will set the register pointer on theIC() The master will then begin transmitting each byte of data with the IC() acknowledging eachbyte received. The master will generate a stop condition to terminate the data write.

Slave transmitter mode (read mode):

The first byte is received and handled as in the slave receiver mode. However, in this mode,the *direction bit will indicate that the transfer direction is reversed. Serial data is transmittedon SDA by the IC() while the serial clock is input on SCL. START and STOP conditions arerecognized as the beginning and end of a serial transfer (See Figure above). Theaddress byte is the first byte received after the start condition is generated bythe master. The address byte contains the 7-bit IC() address, which is 1001000,followed by the *direction bit (R/ W ) which, for a read, is a 1. After receiving anddecoding the address byte the device inputs an acknowledge on the SDA line. The IC()then begins to transmit data starting with the register address pointed to by the registerpointer. If the register pointer is not written to before the initiation of a read mode the firstaddress that is read is the last one stored in the register pointer. The IC( )must receive a “notacknowledge” to end a read.

Page 8: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

8 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e d C o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

SLN.O PIN WORD ADDRESS ADDRESS COMMAND

1 AN0 ADC1 0X01

2 AN1 ADC2 0X02

3 AN2 ADC3 0X03

4 AN3 ADC4 0X04

5 AN4 ADC5 0X05

6 RC2 PWM1 0X06

7 RC1 PWM2 0X07

8 EEPROM WRITE 0X08

9 EEPROM READ 0X09

10 UART WRITE 0X10

11 UART READ COUNT 0X11 0XED

12 UART READ CLEARCOUNT

0X11 0XEE

13 UART READ 0X11

14 LCD WRITE 0X12 DATA

15 LCD 1ST LINE 0X12 0XEA

16 LCD 2ND LINE 0X12 0XEB

17 LCD CLEAR SCREEN 0X12 0XEC

Page 9: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

9 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e d C o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

18 EXTERAL EEPROM WRITE 0X13

19 EXTERAL EEPROM READ 0X14

20 RTC WRITE 0X15

21 RTC READ 0X16

18 I/O PINS INIT 0X17 1=INPUT ,0=OUTPUT

19 1 PIN OUPUT 0X18 1=1ST PIN, 8=EIGHT PIN0=OFF,0XFF=1

20 ALL PIN OUTPUT 0X19 8BIT DATAD0..D7

21 I PIN INPUT 0X20 1=1ST PIN, 8=EIGHT PIN1=OFF,255=1

SDA RC0

SCL RC5

Page 10: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

10 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Page 11: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

11 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

ADC

8 bit unsigned value read from the specified channel

Parameter channel represents the channel from which the analog value is to be acquired. Refer to theappropriate datasheet for channel-to-pin mapping

Note: Address to select ADC show in table 1.

Page 12: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

12 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Example program :

1) Interfacing to 8051 value of ADC1 is received from i2c protocol and transmitted to PC using RS232

#include "reg51.h" //header file

#include <intrins.h>

#include<i2c.h>

void main()

{ unsigned char i,ch;

delay_loop(600); //delay

TMOD=0X20;

TH1=0XFD; // serial init

SCON=0X50;

TR1=1;

for(i=0;i<55;i++)

{

delay_loop(600); //delay

delay_loop(600);

}

TRANSMIT("ADC"); //transmit “ADC” serial

transmit_byte(0X0A); //transmit 10,13 ENTER serial

transmit_byte(0X0D);

delay_loop(600);

while(1)

{

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x01); // select the ADC = ADC1

delay();

start_bit();

slave_add(0x91); //send byte via I2C read

ch=data_rd_display(); // Read the DATA

TRANSMIT("ADC1 = "); //send string serial “ADC1=”

display(ch); //convert to dec & send serially

transmit_byte(0X0D);

}

}

Page 13: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

13 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

PWM

Sets PWM duty ratio. Parameter duty takes values from 0 to 255, where 0 is 0%, 127 is 50%,and 255 is 100% duty ratio. Other specific values for duty ratio can be calculated as(Percent*255)/100.

EX:

Set duty ratio to 75%:

slave_add(0XC0); Note: Address to select PWM show in table 1.

Page 14: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

14 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Example program :

1) Interfacing to 8051 from I2c protocol to generated PWM1=50% and PW2=100%.

#include "reg51.h" //header file

#include <intrins.h>

#include<i2c.h>

void main()

{ unsigned char i,ch;

delay_loop(600); //delay

for(i=0;i<55;i++)

{

delay_loop(600); //delay

delay_loop(600);

}

delay_loop(600);

while(1)

{

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x06); // select the PWM = PWM1

slave_add(0x7F); // Sets PWM duty ratio 7F=50%

delay();

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x07); // select the PWM = PWM2

slave_add(0xFF); // Sets PWM duty ratio FF=100%

delay();

}

}

Page 15: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

15 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

INTERNAL EEPROM

Writes data to specified address. Parameter address is MCU dependent

Reads data from specified address. Parameter address is MCU dependent

Note: Address to select EEPROM show in table 1.

Page 16: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

16 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Example program :

Interfacing to 8051 from I2c protocol store char ‘A’ in EEPROM and read it transmit it to RS232

#include "reg51.h" //header file

#include <intrins.h>

#include<i2c.h>

void main()

{ unsigned char i,ch;

delay_loop(600); //delay

TMOD=0X20;

TH1=0XFD; // serial init

SCON=0X50;

TR1=1;

for(i=0;i<55;i++)

{

delay_loop(600); //delay

delay_loop(600);

}

TRANSMIT("INTERNAL EEPROM"); //transmit “INTERNAL EEPROM”

transmit_byte(0X0A); //transmit 10,13 ENTER serial

transmit_byte(0X0D);

delay_loop(600);

while(1)

{

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x08); // select the INTERNAL EEPROM to write

slave_add(0x10); //send byte (address of EEPROM location)

slave_add('A'); // send data (data to be written)

delay();

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x09); // select the INTERNAL EEPROM to Read

slave_add(0x10); //send byte (address of EEPROM location)

slave_add(0x91); //send byte via I2C read

ch=data_rd_display(); // Read the DATA

TRANSMIT("INTERNAL EEPROM = "); //send string serial

transmit_byte(ch); //transmit the data serially

transmit_byte(0X0D);

}

}

Page 17: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

17 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

SERIAL

Page 18: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

18 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Note: Address to select serial write, Read is show in table 1.

Example program :

Interfacing to 8051 from I2c protocol char ‘A’,’B’,’C’ is transmit to RS232

#include "reg51.h" //header file

#include <intrins.h>

#include<i2c.h>

void main()

{ unsigned char i,ch;

delay_loop(600); //delay

TMOD=0X20;

TH1=0XFD; // serial init

SCON=0X50;

TR1=1;

for(i=0;i<55;i++)

{

delay_loop(600); //delay

delay_loop(600);

}

TRANSMIT("serial write"); //transmit “serial write”

transmit_byte(0X0A); //transmit 10,13 ENTER serial

transmit_byte(0X0D);

delay_loop(600);

while(1)

{

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x10); // select the serial to write

slave_add('A');

slave_add('B'); // write the data

slave_add('c');

stop_bit(); //issue I2C stop signal

delay();

}

}

Page 19: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

19 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Example program :

Interfacing to 8051 from I2c protocol to received data from RS232

#include "reg51.h" //header file

#include <intrins.h>

#include<i2c.h>

void main()

{ unsigned char i,ch;

delay_loop(600); //delay

TMOD=0X20;

TH1=0XFD; // serial init

SCON=0X50;

TR1=1;

for(i=0;i<55;i++)

{

delay_loop(600); //delay

delay_loop(600);

}

TRANSMIT("serial read"); //transmit “serial read”

transmit_byte(0X0A); //transmit 10,13 ENTER serial

transmit_byte(0X0D);

delay_loop(600);

while(1)

{

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x11); // select the SRIAL DATA Read

slave_add(0x01); // select the DATA location

delay();

start_bit();

slave_add(0x91); //send byte via I2C read

ch=data_rd_display(); // Read the DATA

transmit_byte (ch); //send data serially

transmit_byte(0X0D);

}

}

Page 20: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

20 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

LCD

Note: Address to select LCD write, Read is show in table 1.

Page 21: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

21 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Example program :

Interfacing to 8051 from I2c protocol to display char ‘A’ in 1st line and char ‘B’ in 2nd line.

#include "reg51.h" //header file

#include <intrins.h>

#include<i2c.h>

void main()

{ unsigned char i,ch;

delay_loop(600); //delay

for(i=0;i<55;i++)

{

delay_loop(600); //delay

delay_loop(600);

}

while(1)

{

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x12); // select the lcd

slave_add(0XEA); // select the 1ST LINE

slave_add('A'); // write the data

slave_add(0XEB); // select the 2ND LINE

slave_add('B'); // write the data

stop_bit(); //issue I2C stop signal

delay();

}

}

Page 22: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

22 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

EEPROM

Note: Address to select EXTERNAL EEPROM write, Read is show in table 1.

Page 23: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

23 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Interfacing to 8051 from I2c protocol store char ‘A’ in EEPROM and read it transmit it to RS232

RTC

#include "reg51.h" //header file

#include <intrins.h>

#include<i2c.h>

void main()

{ unsigned char i,ch;

delay_loop(600); //delay

TMOD=0X20;

TH1=0XFD; // serial init

SCON=0X50;

TR1=1;

for(i=0;i<55;i++)

{

delay_loop(600); //delay

delay_loop(600);

}

TRANSMIT("EXTERNAL EEPROM"); //transmit “EXTERNAL EEPROM”

transmit_byte(0X0A); //transmit 10,13 ENTER serial

transmit_byte(0X0D);

delay_loop(600);

while(1)

{

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x13); // select the EXTERNAL EEPROM to write

slave_add(0x10); //send byte (address of EEPROM location)

slave_add('A'); // send data (data to be written)

delay();

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x14); // select the EXTERNAL EEPROM to Read

slave_add(0x10); //send byte (address of EEPROM location)

slave_add(0x91); //send byte via I2C read

ch=data_rd_display(); // Read the DATA

TRANSMIT("EXTERNAL EEPROM = "); //send string serial

transmit_byte(ch); //transmit the data serially

transmit_byte(0X0D);

}

}

Page 24: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

24 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

RTC

Page 25: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

25 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

#include "reg51.h" //header file

#include <intrins.h>

#include<i2c.h>

void main()

{ unsigned char i,ch;

delay_loop(600); //delay

TMOD=0X20;

TH1=0XFD; // serial init

SCON=0X50;

TR1=1;

for(i=0;i<55;i++)

{

delay_loop(600); //delay

delay_loop(600);

}

TRANSMIT("EXTERNAL EEPROM"); //transmit “EXTERNAL EEPROM”

transmit_byte(0X0A); //transmit 10,13 ENTER serial

transmit_byte(0X0D);

delay_loop(600);

rtc_init();

while(1)

{ TRANSMIT("Time");

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x16); // select the RTC to write

slave_add(0x02); // select the address of hour

start_bit(); //issue I2C start signal

slave_add(0x91); //send byte via I2C read

ch=data_rd_display(); // Read the DATA

display_asi(ch); //convert to asci & send serially

transmit_byte(':');

delay_loop(400);

start_bit();

slave_add(0x90);

slave_add(0x16);;

slave_add(0x01); // select the address of minutes

start_bit();

slave_add(0x91);

ch=data_rd_display();

display(ch);

transmit_byte(':');

delay_loop(400);

start_bit();

slave_add(0x90);

slave_add(0x16);

slave_add(0x00); //// select the address of seconds

display(ch);

Page 26: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

26 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

start_bit();

slave_add(0x91);

ch=data_rd_display();

display(ch);

transmit_byte(‘ ’);

TRANSMIT("Date");

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x16); // select the RTC to write

slave_add(0x04); // select the address of hour

start_bit(); //issue I2C start signal

slave_add(0x91); //send byte via I2C read

ch=data_rd_display(); // Read the DATA

display_asi(ch); //convert to asci & send serially

transmit_byte('-');

delay_loop(400);

start_bit();

slave_add(0x90);

slave_add(0x16);;

slave_add(0x05); // select the address of minutes

start_bit();

slave_add(0x91);

ch=data_rd_display();

display(ch);

transmit_byte(':');

delay_loop(400);

start_bit();

slave_add(0x90);

slave_add(0x16);

slave_add(0x06); //// select the address of seconds

start_bit(); //issue I2C start signal

slave_add(0x91); //send byte via I2C read

ch=data_rd_display(); // Read the DATA

display_asi(ch); //convert to asci & send serially

transmit_byte(0X0D);

}

}

void display_asi(unsigned char a1)

{

unsigned char b1;

b1=(a1 & 0x0f0);

b1=(b1>>4)+0x30;

transmit_byte(b1);

b1=(a1 & 0x0f);

b1=b1+0x30;

transmit_byte(b1);

}

Page 27: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

27 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

void rtc_init()

{ start_bit();

slave_add(0x90);

slave_add(0x15);

slave_add(0x00); //SEC address

slave_add(0x00); // SEC

start_bit();

slave_add(0x90);

slave_add(0x15);

slave_add(0x01); //Min’ address

slave_add(0x00); //min

start_bit();

slave_add(0x90);

slave_add(0x15);

slave_add(0x02); //hr address

slave_add(0x06); //hr

start_bit();

slave_add(0x90);

slave_add(0x15);

slave_add(0x04); //date address

slave_add(0x02); //date

delay123();

start_bit();

slave_add(0x90);

slave_add(0x15);

slave_add(0x05); // month address

slave_add(0x06]); //month

start_bit();

slave_add(0x90);

slave_add(0x15);

slave_add(0x06); //year address

slave_add(0x12); //year

}

Page 28: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

28 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

I/O PORT

Page 29: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

29 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

#include "reg51.h" //header file

#include <intrins.h>

#include<i2c.h>

void main()

{ unsigned char i,ch;

delay_loop(600); //delay

TMOD=0X20;

TH1=0XFD; // serial init

SCON=0X50;

TR1=1;

for(i=0;i<55;i++)

{

delay_loop(600); //delay

delay_loop(600);

}

TRANSMIT("I/O"); //transmit “I/O” serial

transmit_byte(0X0A); //transmit 10,13 ENTER serial

transmit_byte(0X0D);

delay_loop(600);

// OUTPUT FOR ONE PIN “D0”

while(1)

{

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x17); // select the I/O PIN INTIT ..

slave_add(0xFE); // 1 =input,0=output pin, FE=”1111 1110”

delay();

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x18); // select the I/O PIN INTIT ..

slave_add(0x01); // select the 1st pin

slave_add(0x00); // select the 0= off 1= on

}

}

Page 30: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

30 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

// OUTPUT FOR ALL PINS OF PORTD”

while(1)

{

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x17); // select the I/O PIN INTIT ..

slave_add(0x00); // 1 =input,0=output pin, 00=”0000 0000”

delay();

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x19); // select the I/O PIN INTIT ..

slave_add(0x84); // select the 0= off 1= on 84=”1000 0100” D7 –D0

}

}

// input FOR D7 PINS OF PORTD”

while(1)

{

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x17); // select the I/O PIN INTIT ..

slave_add(0x80); // 1 =input,0=output pin, 80=”1000 0000”

delay();

start_bit(); //issue I2C start signal

slave_add(0x90); //send byte via I2C write

slave_add(0x20); // select the Input PIN INTIT ..

slave_add(0x08); // status of D7 pin

delay();

start_bit();

slave_add(0x91); //send byte via I2C read

ch=data_rd_display(); // Read the DATA

TRANSMIT("pin= "); //send string serial “pin” 255 id high, 1 is low

display(ch); //convert to dec & send serially

transmit_byte(0X0D);

}

}

Page 31: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

31 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

Note: Program I2c .h

sbit sda=P1^1;

sbit scl=P1^0;

void delay();

void start_bit();

void stop_bit();

void slave_add(unsigned char);

unsigned char data_rd_display();

void display(unsigned char);

void delay_loop(unsigned int);

void transmit_byte(unsigned char );

void TRANSMIT(unsigned char *);

void start_bit() //Start bit condition

{ scl=1;

sda=1;

_nop_();

_nop_();

_nop_();

_nop_();

sda=0;

_nop_();_nop_(); _nop_();

scl=0;

}

void stop_bit() //Stop bit condition

{ sda=0;

_nop_();

_nop_();

scl=1;

_nop_();

_nop_();

_nop_(); _nop_();

sda=1;

_nop_();

_nop_();

_nop_();

scl=0;

}

void slave_add(unsigned char add)

{ unsigned char t,i;

t=add;

sda=1;

for(i=0;i<8;i++)

{

scl=1;

_nop_();

_nop_();

_nop_();

delay_loop (800);

scl=0;

t=(t&0x80);

if(t!=0)

sda=1;

else

sda=0;

t=add<<1;

add=t;

}

sda=1;

scl=1;

_nop_();

_nop_(); _nop_();

delay_loop(400);

scl=0;

}

Page 32: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

32 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

unsigned char data_rd_display()

{ unsigned char i,x=0,y=0;

sda=1;

for(i=0;i<8;i++)

{

scl=0;

_nop_();

_nop_(); _nop_();

delay_loop(800);

scl=1;

_nop_();

scl=0;

delay123();

if(sda==1)

x=x|0x01;

y=x;

x=x<<1;

}

sda=1;

scl=1;

_nop_();

_nop_(); _nop_();

delay_loop(400);

scl=0;

return(y);

}

void delay()

{

unsigned char z;

for(z=250;z>0;z--);

}

void delay_loop(unsigned int x)

{ while(x--);

}

void transmit_byte(unsigned char byte)

{

SBUF=byte;

while(!TI);

TI=0;

}

void TRANSMIT(unsigned char *string)

{

while(*string)

transmit_byte(*string++);

}

void display(unsigned char d)

{

unsigned char dig1,dig2,dig3,dig[3];

unsigned char x;

unsigned char temp;

temp=d;

temp=temp/10;

dig1=d%10;

dig2=temp%10;

dig3=temp/10;

dig[0]=dig3;

dig[1]=dig2;

dig[2]=dig1;

for(x=0;x<3;x++)

{

temp=dig[x]|0x30;

transmit_byte(temp);

}

}

Page 33: Peripheral Logic Board Version: 1 - GOAL TECHNOLOGIESgoaltechnologies.in/.../uploads/2012/08/Peripheral-Logic-Board_89S52.pdf · Peripheral Logic Board V1.0. 4 | P a g e A n I S O

33 | P a g e A n I S O 9 0 0 1 - 2 0 0 8 C e r t i f i e dC o m p a n y

Goal Technologies -4th Floor, Oberle Tower Balmatta .Mangalorewww.goaltechnologies.in [email protected] 0824-4261407/4251407

GOAL TECHNOLOGIES®

I N S T I T U T E F O R I N T E R N A T I O N A L L E A R N I N G S O L U T I O N S

4th FLOOR, OBERLE TOWERS 4th Floor, RAAJ Tower

BALMATTA, MANGALORE-575002 City BUS Stand UDUPI

P: 0824 4251407, 4261407 P: 820 4296777, 4293444

E: [email protected] www.goaltechnologies.in