Skip to content

Commit 5ece3d5

Browse files
CITD-425:code-examples
1 parent 5f2025c commit 5ece3d5

File tree

29 files changed

+5643
-0
lines changed

29 files changed

+5643
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"metaDataVersion":"1.0.0",
3+
"category":"com.microchip.ide.project",
4+
"content":{
5+
"metaDataVersion":"1.3.0",
6+
"name":"com.microchip.mplabx.project.dspic33e-rtsp-from-aux-flash",
7+
"version":"0.1.0",
8+
"displayName":"RTSP of Primary Flash Memory from Auxiliary Flash Memory",
9+
"projectName":"dspic33e-rtsp-from-aux-flash",
10+
"shortDescription":"RTSP of Primary Flash Memory from Auxiliary Flash Memory",
11+
"ide":{
12+
"name":"MPLABX",
13+
"semverRange":">=5.50.0"
14+
},
15+
"compiler":{
16+
"name":"XC16",
17+
"semverRange":"^2.00"
18+
},
19+
"dfp":{
20+
"name":"dsPIC33E-GM-GP-MC-GU-MU_DFP",
21+
"semverRange":"^1.3.85"
22+
},
23+
"device":{
24+
"metaDataVersion":"1.0.0",
25+
"category":"com.microchip.portal.contentRef",
26+
"content":{
27+
"metaDataVersion":"1.0.0",
28+
"category":"com.microchip.device",
29+
"name":"dsPIC33EP512MU810",
30+
"versionRange":"*"
31+
}
32+
},
33+
"peripherals":[
34+
],
35+
"keywords":[
36+
]
37+
}
38+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
![image](../images/microchip.jpg)
2+
3+
## RTSP OF PRIMARY FLASH MEMORY FROM AUXILIARY FLASH MEMORY
4+
5+
## Description:
6+
7+
This code example demonstrates how user code running from Auxiliary Flash Program Memory
8+
can perform Run-Time Self-Programming (RTSP) of the Primary Flash Program Memory. Note
9+
that the user code does not get stalled when the Primary Flash RTSP operation is in progress.
10+
In this example, a page-sized array of data has been initialized and defined as a Primary Flash
11+
constant array using the space(prog) attribute of the compiler, whereas the subroutines that
12+
perform the RTSP operations have been located in an Auxiliary Flash Program Memory code section
13+
using the 'auxflash' attribute of the assembler. Then, the user code erases the entire page in Primary
14+
Flash Program Memory and modifies the contents of one of the rows in the page using RTSP.
15+
Subsequently, the user code reads back the contents of the page into an array called 'pageMirrorBuff'.
16+
Verify that the specified row (row 7) now contains the modified data and the remaining rows are in
17+
their original state.
18+
19+
20+
## Hardware Used
21+
22+
- Explorer 16/32 Development Board (https://www.microchip.com/DM240001-2)
23+
- dsPIC33EP512MU810 PIM (https://www.microchip.com/MA330025-1)
24+
25+
26+
## Software Used
27+
28+
- MPLAB® X IDE v5.50 or newer (https://www.microchip.com/mplabx)
29+
- MPLAB® XC16 v1.70 or newer (https://www.microchip.com/xc)
30+
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*******************************************************************************
2+
ce475 RTSP API header file
3+
4+
Company:
5+
Microchip Technology Inc.
6+
7+
File Name:
8+
rtsp_api.h
9+
10+
Summary:
11+
Flash API function definitions.
12+
13+
Description:
14+
This file consists of the definitions for the Flash erase,
15+
Flash read, Flash page modify and the Flash program fucntions
16+
that are called in the main.c.
17+
*******************************************************************************/
18+
/*******************************************************************************
19+
Copyright (c) 2012 released Microchip Technology Inc. All rights reserved.
20+
21+
Microchip licenses to you the right to use, modify, copy and distribute
22+
Software only when embedded on a Microchip microcontroller or digital signal
23+
controller that is integrated into your product or third party product
24+
(pursuant to the sublicense terms in the accompanying license agreement).
25+
26+
You should refer to the license agreement accompanying this Software for
27+
additional information regarding your rights and obligations.
28+
29+
SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
30+
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
31+
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
32+
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
33+
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
34+
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
35+
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
36+
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
37+
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
38+
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
39+
*******************************************************************************/
40+
#ifndef _RTSPAPI_H
41+
#define _RTSPAPI_H
42+
43+
// *****************************************************************************
44+
// *****************************************************************************
45+
// Section: Included Files
46+
// *****************************************************************************
47+
// *****************************************************************************
48+
#include <stdint.h>
49+
50+
#ifdef __cplusplus // Provide C++ Compatability
51+
extern "C"
52+
{
53+
#endif
54+
55+
// *****************************************************************************
56+
// *****************************************************************************
57+
// Section: Interface Routines
58+
// *****************************************************************************
59+
// *****************************************************************************
60+
/* Flash Memory is organised into ROWs of 64 instructions or 192 bytes.
61+
RTSP allows the user to erase a PAGE of memory which consists of EIGHT ROWs
62+
(512 instructions or 1536byts) at a time.
63+
RTSP allows the user to program a ROW (64 instructions or 192 bytes) at a
64+
time
65+
*/
66+
/******************************************************************************
67+
* Function: int16_t FlashPageErase(uint16_t nvmAdru, uint16_t nvmAdr);
68+
*
69+
* PreCondition: None
70+
*
71+
* Input: nvmAdru - Selects the upper 8bits of the location to program or erase
72+
in program flash memory
73+
74+
nvmAdr - Selects the location to program or erase in program flash
75+
memory. It must be aligned to 512 instruction boundary,
76+
LSB 10bits of address must be zero
77+
78+
*
79+
* Output: None
80+
*
81+
* Side Effects: None
82+
*
83+
* Overview: This function provides the interface to erase the flash.
84+
*****************************************************************************/
85+
int16_t FlashPageErase( uint16_t nvmAdru, uint16_t nvmAdr );
86+
87+
/******************************************************************************
88+
* Function: int16_t FlashPageRead(uint16_t nvmAdru, uint16_t nvmAdr, int16_t *pageBufPtr);
89+
*
90+
* PreCondition: None
91+
*
92+
* Input: nvmAdru - Selects the upper 8bits of the location to program or erase
93+
in program flash memory
94+
95+
nvmAdr - Selects the location to program or erase in program flash
96+
memory. It must be aligned to 512 instruction boundary,
97+
LSB 10bits of address must be zero
98+
pageBufPtr- Pointer to the data array in which read data will be stored
99+
100+
*
101+
* Output: Function returns ERROREE (or -1), if it is not successful,
102+
Function return ZERO, if successful
103+
*
104+
* Side Effects: None
105+
*
106+
* Overview: This function provides the interface to read the flash.
107+
*****************************************************************************/
108+
int16_t FlashPageRead( uint16_t nvmAdru, uint16_t nvmAdr, int16_t *pageBufPtr );
109+
110+
/******************************************************************************
111+
* Function: int16_t FlashPageModify(uint16_t row, uint16_t size, int16_t *rowBuf, int16_t *pageBufPtr);
112+
*
113+
* PreCondition: None
114+
*
115+
* Input: nvmAdru- Selects the upper 8bits of the location to program or erase
116+
in program flash memory
117+
118+
nvmAdr- Selects the location to program or erase in program flash
119+
memory. It must be aligned to 512 instruction boundary,
120+
LSB 10bits of address must be zero
121+
122+
rowBuf- Selects the location to read in program flash memory
123+
124+
pageBufPtr- Pointer to the data array in which read data will be stored
125+
126+
*
127+
* Output: Function returns ERROREE (or -1), if it is not successful,
128+
Function return ZERO, if successful
129+
*
130+
* Side Effects: None
131+
*
132+
* Overview: This function provides the interface to modify the flash.
133+
*****************************************************************************/
134+
int16_t FlashPageModify( uint16_t row, uint16_t size, int16_t *rowBuf, int16_t *pageBufPtr );
135+
136+
/******************************************************************************
137+
* Function: int16_t FlashPageWrite(uint16_t nvmAdru, uint16_t nvmAdr, int16_t *pageBufPtr);
138+
*
139+
* PreCondition: None
140+
*
141+
* Input: nvmAdru- Selects the upper 8bits of the location to program or erase
142+
in program flash memory
143+
144+
nvmAdr- Selects the location to program or erase in program flash
145+
memory. It must be aligned to 512 instruction boundary,
146+
LSB 10bits of address must be zero
147+
148+
pageBufPtr- Pointer to the data array in which read data will be stored
149+
150+
* Output: Function returns ERROREE (or -1), if it is not successful,
151+
Function return ZERO, if successful
152+
*
153+
* Side Effects: None
154+
*
155+
* Overview: This function provides the interface to write the flash.
156+
*****************************************************************************/
157+
int16_t FlashPageWrite( uint16_t nvmAdru, uint16_t nvmAdr, int16_t *pageBufPtr );
158+
159+
#ifdef __cplusplus // Provide C++ Compatibility
160+
}
161+
162+
#endif
163+
#endif /* _RTSPAPI_H */
164+
165+
/*******************************************************************************
166+
End of File
167+
*/

0 commit comments

Comments
 (0)