Flash programing in 33fj series

Status
Not open for further replies.

embeddedpower1

Newbie level 3
Joined
May 24, 2019
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
45
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
 

Hi,

please read forum rules.
A forum is not meant that other write code for you or do an internet search for you.

A forum is meant that members help you to rectifiy the problems with your code.
Thus provide your code, your test setup, maybe schematic...
Tell us your expectation and what you see instead.

Klaus
 

I presume you are referring to "self-programming" of dspic33 flash during program execution, used by a boot loader or e.g. EEPROM emulation. The algorithm is briefly explained in the device datasheet, for some applications, example code is also available from Microchip.

To get help with your specific problem, you should tell what you are trying to achieve and how you did it.
 

This is the code that i have written. Please give me suggestion if am wrong somewhere


//////////////

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();
     
 
    
}

 

Attachments

  • samp.txt
    1.6 KB · Views: 41
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…