Hot!write code in non-volatile memory of MCP2221

Author
noel_t
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2011/07/12 05:30:33
  • Location: 0
  • Status: offline
2018/10/12 21:19:38 (permalink)
0

write code in non-volatile memory of MCP2221

I need help on how to write a very small program to turn the GPI 0 of MCP2221 ON in power up by default.
 
MCP2221 has two memories. #1SRAM, #2Flash (Non-volatile)
 
In order to have the power-up default, the program needs to be sitted in the flash and I do not know how to do it.
 
I prefer to write that program in C#.
 
#1

6 Replies Related Threads

    qhb
    Superb Member
    • Total Posts : 9625
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: write code in non-volatile memory of MCP2221 2018/10/12 21:57:42 (permalink)
    4 (1)
    What makes you think you can put your own program into the device's FLASH?
    There are some power up setting saved in FLASH, but you set them via code running on your PC.
    The datasheet is at http://ww1.microchip.com/downloads/en/DeviceDoc/20005292C.pdf
     
    #2
    Jim Nickerson
    User 452
    • Total Posts : 5842
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: write code in non-volatile memory of MCP2221 2018/10/13 06:49:46 (permalink)
    4 (1)
    The utility from this page (documents ) seems to have this feature https://www.microchip.com...21#additional-features
    [edit] link did not point to documents tab
    post edited by Jim Nickerson - 2018/10/13 06:53:50
    #3
    noel_t
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2011/07/12 05:30:33
    • Location: 0
    • Status: offline
    Re: write code in non-volatile memory of MCP2221 2018/10/15 20:24:44 (permalink)
    0
    Let me clarify a little bit more,
     
    I want to turn on the GP2 and GP3 high immediately when MCP2221 powered up. That's why I need to hold it in the non-volatile memory. I know with the program with C# I can do it. But, I want it on power up.
     
    Thanks!
    #4
    qhb
    Superb Member
    • Total Posts : 9625
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: write code in non-volatile memory of MCP2221 2018/10/15 20:32:20 (permalink)
    4 (1)
    noel_t
    I want to turn on the GP2 and GP3 high immediately when MCP2221 powered up.

    Did you read the datasheet I linked to?
    That is controlled by registers GPSETTING2, and GPSETTING3
    "GPIO output" and "Default output level=1" are the factory default settings, but "GPDES" defaults to "Dedicated function operation" and you need to change it to "GPIO operation".
     
    post edited by qhb - 2018/10/15 20:34:05
    #5
    Jim Nickerson
    User 452
    • Total Posts : 5842
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: write code in non-volatile memory of MCP2221 2018/10/16 06:57:48 (permalink)
    4 (1)
    I congratulate the instructor on choosing an assignment for which the answer is not available online.
    #6
    noel_t
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2011/07/12 05:30:33
    • Location: 0
    • Status: offline
    Re: write code in non-volatile memory of MCP2221 2018/10/18 17:26:49 (permalink)
    0
    I am trying to get the GPIO settings first. (Page 58 of DLL user manual). Then, I can write to GPIOSETTINGS. Please check if my approach is correct.
     
     
    static void GPIOSettings()
    {
    bool errorOccurredMCP = false;


    MCP2221.M_Mcp2221_GetGpioSettings(Device, WRITE_TO_FLASH, pinFunctions, pinDirections, outputValues);
    errorOccurredMCP = CheckForError();
    Console.WriteLine("Pin Functions value for GP0 {0}", outputValues[0]);


    pinFunctions[3] = 1;
    Console.WriteLine(pinFunctions[3]);
    //pinFunctions[0] = bitmask;
    // x = pinFunctions[0] & Convert.ToByte(bitmask);
    Console.WriteLine("Value of bit 4 is", x);
    MCP2221.M_Mcp2221_SetGpioSettings(Device, WRITE_TO_FLASH, pinFunctions, pinDirections, outputValues);

    errorOccurredMCP = CheckForError();
    if (!errorOccurredMCP)
    Console.WriteLine("Operation successful");
    else
    Console.WriteLine("Operation unsuccessful");
    }
    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5