Skip to content

Commit 86a2cd2

Browse files
Nathaniel ThompsonNathaniel Thompson
authored andcommitted
MPAE-15256: Grammar fixes in readme
1 parent 4197480 commit 86a2cd2

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,48 @@
44

55
# How to Write and Read to an External EEPROM with a PIC16F18076
66

7-
This example will explain how to read and write both a single byte and array of memory from a PIC16F18076 microcontroller to an external EEPROM device. A curiosity nano development board will be used with an external 25CSM04 EEPROM device on a Mikroe EEPROM 7 click board. Additionally, MPLAB Code Configurator with its MSSP SPI peripheral will be used to handle communication between the microcontroller and the EEPROM device. MCC will also be used to setup the microcontroller's pins and basic configurations and the UART peripheral will be configured for debugging and outputing the results of the example's included tests for reading and writing.
7+
This example explains how to read and write both a single byte and an array of memory from a PIC16F18076 microcontroller (MCU) to an external EEPROM device. A Curiosity Nano development board is used with an external 25CSM04 EEPROM device on a Mikroe EEPROM 7 Click board. Additionally, MPLAB® Code Configurator (MCC) with its Host Synchronous Serial Port (MSSP) Serial Peripheral Interface (SPI) peripheral is used to handle communication between the MCU and the EEPROM device. MCC is also used to set up the microcontrollers pins and basic configurations, as well as to configure the Universal Asynchronous Receiver Transmitter (UART) peripheral for debugging and outputing the results of the reading and writing tests included in the example.
88

99
## Related Documentation
1010

11-
- [PIC16F18076 Product Page and Datasheet](https://www.microchip.com/en-us/product/PIC16F18076?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
11+
- [PIC16F18076 Product Page and Data Sheet](https://www.microchip.com/en-us/product/PIC16F18076?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
1212

1313

14-
- [25CSM04 Product Page and Datasheet](https://www.microchip.com/en-us/product/25CSM04?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
14+
- [25CSM04 Product Page and Data Sheet](https://www.microchip.com/en-us/product/25CSM04?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
1515

1616
## Software Used
1717

18-
- MPLAB® X IDE 6.0.5 or newer [(MPLAB® X IDE 6.0)](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_MPAE_Examples&utm_content=pic16f18076-read-write-external-memory-github)
19-
- MPLAB® XC8 2.40.0 or newer compiler [(MPLAB® XC8 2.40)](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_MPAE_Examples&utm_content=pic16f18076-read-write-external-memory-github)
20-
- MPLAB® Code Configurator (MCC) 5.2.2 or newer [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/en-us/tools-resources/configure/mplab-code-configurator?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
21-
- MPLAB® Code Configurator (MCC) Device Libraries PIC10 / PIC12 / PIC16 / PIC18 MCUs [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/en-us/tools-resources/configure/mplab-code-configurator?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
22-
- Microchip PIC16F1xxxx_DFP Series Device Support (1.15.191) or newer [(packs.download.microchip.com/)](https://packs.download.microchip.com/)
18+
- MPLAB® X IDE [6.0.5 or newer](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_MPAE_Examples&utm_content=pic16f18076-read-write-external-memory-github)
19+
- MPLAB XC8 [2.40.0 or newer](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_MPAE_Examples&utm_content=pic16f18076-read-write-external-memory-github)
20+
- MPLAB Code Configurator (MCC) [5.2.2 or newer](https://www.microchip.com/en-us/tools-resources/configure/mplab-code-configurator?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
21+
- MPLAB Code Configurator (MCC) [Device Libraries](https://www.microchip.com/en-us/tools-resources/configure/mplab-code-configurator?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc) PIC10 / PIC12 / PIC16 / PIC18 MCUs
22+
- Microchip PIC16F1xxxx_DFP Series Device Support [(1.15.191) or newer](https://packs.download.microchip.com/)
2323

2424
## Hardware Used
2525

26-
- [PIC16F18076 Curiosity Nano (EV53Z50A)](https://www.microchip.com/en-us/development-tool/EV53Z50A?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
27-
- [Curiosity Nano Base for Click boards](https://www.microchip.com/en-us/development-tool/AC164162?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
28-
- [EEPROM 7 Click board](https://www.mikroe.com/eeprom-7-click)
29-
- Logic Analyzer such as Salae Logic 8™ or similar (Optional, but highly recommended for debugging)
26+
- [PIC16F18076 Curiosity Nano (EV53Z50A)](https://www.microchip.com/en-us/development-tool/EV53Z50A?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
27+
- [Curiosity Nano Base for Click boards](https://www.microchip.com/en-us/development-tool/AC164162?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic16f18076&utm_content=pic16f18076-eeprom-demo-mplab-mcc)
28+
- [EEPROM 7 Click board](https://www.mikroe.com/eeprom-7-click)
29+
- Logic Analyzer such as [Saleae Logic 8™](https://usd.saleae.com/products/saleae-logic-8) or similar (optional, but highly recommended for debugging)
3030

3131
## Setup
3232

3333
### Hardware Setup
34-
The PIC16F18076 curiosity nano development board is connected to the curiosity nano base board with the Mikroe EEPROM 7 click board placed in mikro BUS 1.
35-
34+
The PIC16F18076 Curiosity Nano development board is connected to the Curiosity Nano base board with the Mikroe EEPROM 7 Click board placed in mikroBUS™ 1.
3635
### MPLAB Code Configurator Setup
3736

3837
### Configuration Bits
3938
![Configuration Bits](images/config_bits.png)
4039

41-
Set External Oscillator Selection bits to "Oscillator Not Enabled" and "Reset Oscillator Selection bits" to "HFINTOSC (32 MHz)".
40+
Set "External Oscillator Selection bits" to "Oscillator Not Enabled" and "Reset Oscillator Selection bits" to "HFINTOSC (32 MHz)".
4241

4342
### Clock Control
4443
![Clock Control](images/clock_control.png)
4544

4645
Set the "Current Oscillator Source Select" to "HFINTOSC_32MHz" and the "HF Internal Clock" to "32_MHz".
4746

4847
### Pins
49-
Configure Pins to the table below:
48+
Configure pins to the table below:
5049

5150
Module | Function | Pin
5251
--- | --- | ---
@@ -59,31 +58,32 @@ Pins | GPIO (output) | RB3/RD3/RD7
5958

6059
![Pin Grid View](images/pin_grid_view.png)
6160

62-
In the "Pins" menu the user should rename pins RB3, RD3, and RD7 to "CS1", "HLD", and "WP" respectively for the function pin names to match the function of the corresponding pins.
61+
In the **Pins** tab, rename pins RB3, RD3, and RD7 to "CS1", "HLD", and "WP" respectively, for the function pin names to match the function of the corresponding pins.
6362
![Pins](images/pins.png)
6463

65-
IMPORTANT NOTE: The user should also disable the Slew Rate for pins SPI Pins: SCK1, SDI1, SDO1 (RB2, RB1, RB0 respectively). Leaving the Slew Rate limit active on the MSSP SPI pins can cause issues with higher MSSP clock frequencies.
64+
**IMPORTANT NOTE:** Disable the Slew Rate for SPI pins: SCK1, SDI1, SDO1 (RB2, RB1, RB0 respectively). Leaving the Slew Rate limit active on the MSSP SPI pins can cause issues with higher MSSP clock frequencies.
6665

6766
### SPI MSSP1
6867
![MSSP SPI](images/mssp_spi.png)
6968

70-
The MSSP SPI should be configured to "Host Mode" in "SPI Mode" should be set to "SPI Mode 0", with the input data sampled in the middle. The "Clock Source Selection" should be set to one of the "FOSC" setting, this example uses "FOSC/4" however "FOSC/16" and "FOSC/64" will work too.
69+
Configure the MSSP1 SPI to "Host Mode" and set "SPI Mode" to "SPI Mode 0", with the input data sampled in the middle. Set the "Clock Source Selection" to one of the "FOSC" settings. This example uses "FOSC/4", but "FOSC/16" and "FOSC/64" will work too.
7170

7271
### UART2
7372
![UART](images/uart.png)
7473

75-
The user may set whatever baud rate they choose. A baud rate of 115200 will be used for this example.
76-
Note: "Redirect Printf to UART" should be enabled for debugging and displaying test results for this demo, however is not necessary if the user only needs to write and read data to the external EEPROM.
74+
The user may set whatever baud rate they choose. A baud rate of 115200 is used for this example.
75+
76+
**Note:** "Redirect Printf to UART" should be enabled for debugging and displaying test results for this demo, however is not necessary if the user only needs to write and read data to the external EEPROM.
7777

7878
### Application Code
7979

80-
Note: For simplicity and readability, the EEPROM OPCODES are defined as shown below and will be identified by their defined names throughout the code. Additionally all printf debug statements have been removed from the code snippets displayed here.
80+
**Note:** For simplicity and readability, the EEPROM OPCODES are defined as shown below and will be identified by their defined names throughout the code. Additionally, all `printf` debug statements have been removed from the code snippets displayed here.
8181

8282
```C
8383
#define WRITE_OPCODE 0x02
8484
#define READ_OPCODE 0x03
8585
#define WRDI_OPCODE 0x04 //Reset Write Enable
86-
#define RDSR_OPCODE 0x05 //Read Status Register OPCODE
86+
#define RDSR_OPCODE 0x05 //Read STATUS Register OPCODE
8787
#define WRITE_ENABLE_OPCODE 0x06
8888
#define WRBP_OPCODE 0x08 //Write Ready/Busy Poll
8989
#define SRST_OPCODE 0x7C //Software device reset OPCODE
@@ -104,22 +104,22 @@ 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 SDO line to the device. This function sends that opcode then uses the eepromReadStatusRegister() function to check the EEPROM's Status Register for a successful write enable. This function is automatically called in both write functions in this demo.
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.
108108

109-
#### eepromReadStatusRegister()
109+
#### readStatusRegister()
110110
```C
111111
uint16_t readStatusRegister(void)
112112
{
113113
uint16_t RDSR = 0x0000;
114114
CS1_SetLow();
115-
SPI1_ByteExchange(RDSR_OPCODE); //Send Read Status Register OPCODE
115+
SPI1_ByteExchange(RDSR_OPCODE); //Send Read STATUS Register OPCODE
116116
RDSR = (uint16_t)SPI1_ByteExchange(0xff); //Read back incoming RDSR Byte 0
117117
RDSR |= ((uint16_t)SPI1_ByteExchange(0xff)) << 8; // Read back incoming RDSR Byte 1
118118
CS1_SetHigh();
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 5ms delay between write operations, however polling the Status Register will always be either quicker or equal to the 5ms delay.
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.
123123
124124
#### eepromWriteByte()
125125
```C
@@ -176,7 +176,7 @@ void eepromWriteBlock (uint24_t address, uint8_t *block,int blockSize)
176176
return;
177177
}
178178
```
179-
The eepromWriteBlock() function follows the same principle as eepromWriteByte(), however it writes multiple bytes. The user should be aware 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 the user desires to send more than 256-bytes at once they should split the data into smaller blocks and use multiple write commands.
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.
180180
181181
#### eepromReadByte()
182182
```C
@@ -197,7 +197,7 @@ uint8_t eepromReadByte (uint24_t address)
197197
return data;
198198
}
199199
```
200-
The eepromReadByte() function fills an array with the READ_OPCODE and specified address then uses SPI1_BufferExchange() to read the data located at the specified address on the external EEPROM.
200+
The eepromReadByte() function fills an array with the READ_OPCODE and specified address, then uses SPI1_BufferExchange() to read the data located at the specified address on the external EEPROM.
201201

202202
#### eepromReadBlock()
203203
```C
@@ -216,7 +216,7 @@ void eepromReadBlock(uint24_t startingAddress, uint8_t *block, int blockSize)
216216
return;
217217
}
218218
```
219-
The eepromReadBlock() function functions just like eepromReadByte(), however reads a specified number of bytes and then stores the returned values at the address for variable "block". Unlike eepromWriteBlock(), a single block read command can continue past the end of a page and read the entire EEPROM if desired. The function will start at the address specified by "startingAddress" and increment upwards with each subsequent clock cycle.
219+
The eepromReadBlock() functions just like eepromReadByte(), but reads a specified number of bytes and then stores the returned values at the address for variable block. Unlike eepromWriteBlock(), a single block read command can continue past the end of a page and read the entire EEPROM, if desired. The function will start at the address specified by startingAddress and increment upwards with each subsequent clock cycle.
220220
221221
#### writeReadByteTest()
222222
```C
@@ -290,7 +290,7 @@ void writeReadBlockTest(uint24_t startingAddress)
290290
291291
This test uses eepromWriteBlock() and eepromReadBlock() to write and read a generated array. A saved copy of the written data is used for comparing with the read data.
292292
293-
Note: Due to eepromWriteBlock() wrapping around the EEPROM's memory pages and eepromReadBlock() continuing to the next page, the starting address of this test should be at the beginning of a page (any valid address that ends with 0x00 should work, eg. 0x123400, 0x000100). Otherwise the address of the written data and read data will differ after the end of a page.
293+
**Note:** Due to eepromWriteBlock() wrapping around the EEPROM's memory pages and eepromReadBlock() continuing to the next page, the starting address of this test needs to be at the beginning of a page. Any valid address that ends with 0x00 is appropriate (e.g., 0x123400, 0x000100). Otherwise, the address of the written data and read data will differ after the end of a page.
294294
295295
#### main()
296296
```C
@@ -323,4 +323,4 @@ The demonstration will automatically run on programming and output the results o
323323

324324
## Summary
325325

326-
This example demonstrates basic read and write functionality using a PIC16F18076 microcontroler and an external 25CSM04 EEPROM device on a Mikroe EEPROM 7 click board.
326+
This example demonstrates basic read and write functionality using a PIC16F18076 microcontroler and an external 25CSM04 EEPROM device on a Mikroe EEPROM 7 Click board.

0 commit comments

Comments
 (0)