embeddedpower1
Newbie level 3
I am trying to write code for flash programming in dspic 33fj64gs610. Writing is not happening in that. Can anybody share any sample codes for 33fj series
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 while() { unsigned int MyRowDataInRam[64]= { 0,1,2,3,4,5,6,7,8,9.10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30, 31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; TBLPAG = __builtin_tblpage(&MyRowData2InFlash[0]); tbloffset = __builtin_tbloffset(&MyRowData2InFlash[0]); programErase(); programWrite(); programParametersRead(); DATA0= lowWord[0]; DATA1= lowWord[0]; DATA2= lowWord[2]; DATA3= lowWord[3]; /// DATA61= lowWord[61]; DATA62= lowWord[62]; DATA63= lowWord[63]; } void programParametersRead() { TBLPAG =__builtin_tblpage(&MyRowData2InFlash[0]); tbloffset = __builtin_tbloffset(&MyRowData2InFlash[0]); for (i = 0; i <= 64; i++) { high_Word[i] = __builtin_tblrdh(tbloffset); lowWord[i] = __builtin_tblrdl(tbloffset); tbloffset += 1; } return; } void programWrite() { unsigned int tbloffset,i; NVMCON = 0x4001; // Row programming TBLPAG = __builtin_tblpage(&MyRowData2InFlash[0]); tbloffset = __builtin_tbloffset(&MyRowData2InFlash[0]); for (i = 0; i <= 64; i++) { __builtin_tblwtl(tbloffset ,MyRowDataInRam[i] ); tbloffset += 1; } __builtin_disi(5); __builtin_write_NVM(); } void programErase() { NVMCON = 0x4042; __builtin_tblwtl(tbloffset , 0X0000); TBLPAG = __builtin_tblpage(&MyRowData2InFlash[0]); tbloffset = __builtin_tbloffset(&MyRowData2InFlash[0]); __builtin_tblwtl(tbloffset, 0xFFFF);// Dummy Write __builtin_disi(5); __builtin_write_NVM(); }