+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Newbie level 3
    Points: 51, Level: 1

    Join Date
    May 2019
    Posts
    4
    Helped
    0 / 0
    Points
    51
    Level
    1

    Flash programing in 33fj series

    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

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 77,067, Level: 67
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,616
    Helped
    3557 / 3557
    Points
    77,067
    Level
    67

    Re: Flash programing in 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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 259,261, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,264
    Helped
    13770 / 13770
    Points
    259,261
    Level
    100

    Re: Flash programing in 33fj series

    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.



    •   AltAdvertisement

        
       

  4. #4
    Newbie level 3
    Points: 51, Level: 1

    Join Date
    May 2019
    Posts
    4
    Helped
    0 / 0
    Points
    51
    Level
    1

    Re: Flash programing in 33fj series

    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();
         
     
        
    }
    Last edited by BradtheRad; 6th June 2019 at 06:34. Reason: Put code in formatted window



  5. #5
    Advanced Member level 2
    Points: 5,088, Level: 16
    Achievements:
    7 years registered
    ZASto's Avatar
    Join Date
    Jan 2008
    Location
    Messy Corner, 44°47'31.56"N, 20°28'9.16"E
    Posts
    606
    Helped
    121 / 121
    Points
    5,088
    Level
    16

    Re: Flash programing in 33fj series

    Is this a typo?

    Click image for larger version. 

Name:	Screenshot from 2019-06-06 07-49-46.png 
Views:	8 
Size:	5.7 KB 
ID:	153514

    Same is in your attached file.
    Make no mistake between my personality and my attitude.
    My personality is who I am.
    My attitude depends on who you are.



--[[ ]]--