You are on page 1of 3

ECE 381

Lab 6 I2C External SRAM

I2C External SRAM


Objective
Interface two external 256 byte external I2C SRAMs to the PSoC and develop a user interface based on the RS-232 Serial Interface to perform Read and Write operations to the SRAM specified in a command.

Hardware Configuration
Identify the two I2C SRAMs located in your lab kit. Place an I2CHW user module. Note: This module does not require any of the digital blocks in the PSoC. Modify the properties of the I2CHW module so that: o The Read_Buffer_Type is RAM_ONLY o I2C Clock is 100K Standard o I2C Pin is P1[5]-P1[7] After reviewing the datasheet for the I2C SRAM make the appropriate connections from both of them to the PSoC as well as power and ground. Set the selectable (Group 2) I2C address of the first I2C SRAM to [A2 A1 A0] = [0 0 0]. Set the selectable (Group 2) I2C address of the second I2C SRAM to [A2 A1 A0] = [0 0 1]. Find the I2C fixed address (Group 1) of the part in the datasheet and make a note of it. Note: The TEST pin should be fixed to Vss (GND) for normal operation Configure the RS-232 interface on the PSoC the same as used in the previous lab on RS232 interfacing. You are allowed to clone the previous lab since the RS-232 configuration is the same

Requirements
The RS-232 interface will be used for performing all user I/O operations. The user should be given a prompt character of: > Your program should accept all commands on a single line with the end-of-line delineated by a carriage-return (0x0D). Commands should be accepted in both upper- and lower-case The Write command has two forms: o W # XX A Mary had a little lamb ... o W # XX H A0 F1 23 44 7B ... # is the Group 2 address of the external SRAM XX is the SRAM address (in hex) where writes will take place A means the following data is ASCII text H means the following data is ASCII encoded hex bytes o After the write command has finished, it should inform the user, on a single line, of the starting and ending address of the write operation and how many bytes were written. The Read command has two forms: o R # XX A NN

ECE 381 o

Lab 6 I2C External SRAM R # XX H NN # is the Group 2 address of the external SRAM XX is the SRAM address (in hex) where writes will take place A means to output the data as ASCII text H means to output the data as ASCII encoded hex bytes NN is the number of bytes (in hex) to be read from address XX o If the read command is printing hex bytes, they should be separated by spaces. o If the read command is printing ASCII text, it should send each character out to the terminal regardless of whether it is a control character or not. This includes the NULL character. Any line of text entered that does not match one of the formats specified above should produce an error message that shows the possible commands and their format. Lines must be limited to a maximum of 78 characters. Any characters typed after the 80th character should not be accepted and an ASCII BEL character (0x07) should be sent to the terminal. Both the delete key (0x7F) and backspace key (0x08) should delete the previous character from the command line and show this visually on the screen by wiping-out the previous character. All other ASCII control characters should be ignored in a command (i.e. ASCII characters 0x19 or less)

Testing
You must prove that data is actually being read/written from/to the specified I2C SRAM chip at the specified address and in the specified format.

Notes
Upper and lower case letters differ only by only one bit (0x20). For example: N = 0x4E and n = 0x6E An ASCII encoded hex byte consists of two ASCII bytes, each representing the high-nibble and low-nibble, respectively, of a single hex byte. For example: The hex byte 0xF2 is ASCII encoded as [ F 2 ] = [ 0x46 0x32 ]

ECE 381

Lab 6 I2C External SRAM

ASCII Characters in Hexadecimal


00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78 NUL BS DLE CAN SP ( 0 8 @ H P X ` h p x 01 09 11 19 21 29 31 39 41 49 51 59 61 69 71 79 SOH HT DC1 EM ! ) 1 9 A I Q Y a i q y 02 0A 12 1A 22 2a 32 3a 42 4a 52 5a 62 6a 72 7a STX NL DC2 SUB " * 2 : B J R Z b j r z 03 0B 13 1B 23 2b 33 3b 43 4b 53 5b 63 6b 73 7b ETX VT DC3 ESC # + 3 ; C K S [ c k s { 04 0C 14 1C 24 2c 34 3c 44 4c 54 5c 64 6c 74 7c EOT NP DC4 FS $ , 4 < D L T \ d l t | 05 0D 15 1D 25 2d 35 3d 45 4d 55 5d 65 6d 75 7d ENQ CR NAK GS % 5 = E M U ] e m u } 06 0E 16 1E 26 2e 36 3e 46 4e 56 5e 66 6e 76 7e ACK SO SYN RS & . 6 > F N V ^ f n v ~ 07 0F 17 1F 27 2f 37 3f 47 4f 57 5f 67 6f 77 7f BEL SI ETB US ' / 7 ? G O W _ g o w DEL

You might also like