Skip to content

Commit 4338150

Browse files
Nathaniel ThompsonNathaniel Thompson
authored andcommitted
MPAE-15256: Minor change to write enable and rdsr function descriptions for clarity and added image from datasheet.
1 parent 3b447a5 commit 4338150

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void eepromWriteEnable(void)
104104
return;
105105
}
106106
```
107-
Before any write can be initiated with the 25CSM04 EEPROM, a Write Enable Opcode must be sent over the Serial Data Out (SDO) line to the device. This function sends that opcode, then uses the readStatusRegister() function to check the EEPROM STATUS register for a successful write enable. This function is automatically called in both write functions used for this demo.
107+
Before any write can be initiated with the 25CSM04 EEPROM, the write operation must be enabled. This is done in a two step process where first a Write Enable Opcode must be sent over the Serial Data Out (SDO) line to the device, then the EEPROM's status register is checked to ensure the write enable command has executed successfully. This function sends that opcode, then uses the readStatusRegister() function shown below to check the EEPROM STATUS register for a successful write enable operation. This function is automatically called in both write functions used for this demo.
108108

109109
#### readStatusRegister()
110110
```C
@@ -119,7 +119,7 @@ uint16_t readStatusRegister(void)
119119
return RDSR;
120120
}
121121
```
122-
This function sends the RDSR_OPCODE through the MSSP and returns the status register. It's polled automatically in eepromWriteEnable() to check for a successful write enable operation and polled after every write operation for the completion of that operation. This instruction may be bypassed in favor of a 5 ms delay between write operations, however polling the STATUS register will always be either quicker or equal to the 5 ms delay.
122+
The STATUS register in the EEPROM device is used to check the status after a write enable command and after any write. This function sends the RDSR_OPCODE through the MSSP and returns the STATUS register. It's polled automatically in eepromWriteEnable() to check for a successful write enable operation and polled after every write operation for the completion of that operation. This instruction may be bypassed in favor of a 5 ms delay between write operations, however polling the STATUS register will always be either quicker or approximately equal in time to the 5 ms delay.
123123
124124
#### eepromWriteByte()
125125
```C
@@ -144,9 +144,11 @@ void eepromWriteByte (uint24_t address, uint8_t data)
144144
return;
145145
}
146146
```
147-
![MCHP](images/WriteDiagram.png)
147+
![Write Diagram](images/WriteDiagram.png)
148148

149-
The eepromWriteByte() function takes the desired address and data from the user and writes that data to that address. This function starts by internally calling eepromWriteEnable() at the beginning. Then it fills an array with the WRITE_OPCODE, the EEPROM address, and finally the desired byte of data. The SPI1_BufferExchange() is then used to transfer the data, and lastly readStatusRegister is used to check for the write command's completion.
149+
The eepromWriteByte() function takes the desired address and data from the user and writes that data to that address. This function starts by internally calling eepromWriteEnable() at the beginning. Then it fills an array with the WRITE_OPCODE, the EEPROM address, and finally the desired byte of data. The SPI1_BufferExchange() is then used to transfer the data, and lastly readStatusRegister is used to check for the write command's completion. An excerpt from the 25CSM04's datasheet has been included below to show the order of this data transfer.
150+
151+
![BYTE WRITE SEQUENCE](images/BYTE_WRITE_SEQUENCE.png)
150152

151153
#### eepromWriteBlock()
152154
```C
@@ -176,7 +178,7 @@ void eepromWriteBlock (uint24_t address, uint8_t *block,int blockSize)
176178
return;
177179
}
178180
```
179-
The eepromWriteBlock() function follows the same principle as eepromWriteByte(), but writes multiple bytes. Note that this EEPROM segments its memory into 256-byte pages, and a block of data larger than a page will not be written properly. When a block write command reaches the end of a page, the address will wrap around to the beginning of a page, so any data written past 256 bytes in a single block write will overwrite the data written at the beginning of that write. If more than 256-bytes need to be sent at once, the user can split the data into smaller blocks and use multiple write commands.
181+
The eepromWriteBlock() function follows the same principle as eepromWriteByte(), but writes multiple bytes. Note that this EEPROM segments its memory into 256-byte pages, and a block of data larger than a page will not be written properly. When a block write command reaches the end of a page, the address will wrap around to the beginning of a page, so any data written past 256 bytes in a single block write will overwrite the data written at the beginning of that write. If more than 256-bytes need to be sent at once, the user can split the data into smaller blocks and use multiple write commands.
180182
181183
#### eepromReadByte()
182184
```C

images/BYTE_WRITE_SEQUENCE.png

48.4 KB
Loading

0 commit comments

Comments
 (0)