We use cookies to provide our visitors with an optimal site experience. View our privacy notice and cookie notice to learn more about how we use cookies and how to manage your settings. By proceeding on our website you consent to the use of cookies.
Hi sir, I tested the file…its working…I want to change parameter individually…when I write parameter[1]
All parameter is changing…but parameter[1] value is same what I have written …but other value is changing…can you help me…
When looking at Kevin’s posted code: (programParameters), it is specifically tuned for 3 integers, did you extend this code when you changed it to an array of 8?
/********************************************************************************
* programParameters()
*
* Prototype: int programParameters(unsigned int, unsigned int, unsigned int)
* Passed arguments: unsigned int param1, unsigned int param2, unsigned int param3
* Return value: none
* Dependencies: INTERRUPTS MUST be DISABLED prior to calling this routine.
*
* Description: Erase block of NVM and write data to FLASH memory
********************************************************************************/
void programParameters(unsigned int param1, unsigned int param2, unsigned int param3)
{
unsigned int tbloffset;
//Erase one page of FLASH memory
NVMCON = 0x4042; // Setup NVMCON for Block Erase operation (512 instructions)
TBLPAG = __builtin_tblpage(&iParameters[0]); // Load upper FLASH address
tbloffset = __builtin_tbloffset(&iParameters[0]); // Offset within page
__builtin_tblwtl(tbloffset, 0xFFFF); // Dummy write to select the page
FLASHWrite(); // low level erase/write command sequence
// write single word, param1, to FLASH
// In this case the Page hasn't changed so don't have to load the table
// page register again.
tbloffset = __builtin_tbloffset(&iParameters[0]); // offset within page
__builtin_tblwtl(tbloffset, param1); // load the write buffer
NVMCON = 0x4003; // Setup NVMCON for Single Word Write operation
FLASHWrite(); // low level erase/write command sequence
// write single word, param2, to FLASH
tbloffset = __builtin_tbloffset(&iParameters[1]); // offset within page
__builtin_tblwtl(tbloffset, param2); // load the write buffer
NVMCON = 0x4003; // Setup NVMCON for Single Word Write operation
FLASHWrite(); // low level erase/write command sequence
// write single word, param3, to FLASH
tbloffset = __builtin_tbloffset(&iParameters[2]); // offset within page
__builtin_tblwtl(tbloffset, param3); // load the write buffer
NVMCON = 0x4003; // Setup NVMCON for Single Word Write operation
FLASHWrite(); // low level erase/write command sequence
return;
}