Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearing JTAGEN bit of FCID when programming PIC32MM #67

Open
lepermunna opened this issue Aug 16, 2020 · 0 comments
Open

Clearing JTAGEN bit of FCID when programming PIC32MM #67

lepermunna opened this issue Aug 16, 2020 · 0 comments

Comments

@lepermunna
Copy link

lepermunna commented Aug 16, 2020

Hi, thanks for this excellent project.

Please note that per section 16.3 of the PIC32MM Families reference (http://ww1.microchip.com/downloads/en/DeviceDoc/60001364d.pdf), special steps are required to clear the JTAGEN bit in the FCID and AFCID configuration words.

The following change to pickit_program_double_word in adapter-pickit2.c seems to work:

    /* Use PE to write flash memory. */
    pickit_send(a, 33, CMD_CLEAR_UPLOAD_BUFFER,
        CMD_EXECUTE_SCRIPT, 29,
            SCRIPT_JT2_SENDCMD, ETAP_FASTDATA,
            SCRIPT_JT2_XFRFASTDAT_LIT,
                0, 0, PE_DOUBLE_WORD_PGRM, 0,
            SCRIPT_JT2_XFRFASTDAT_LIT,
                (unsigned char) addr,
                (unsigned char) (addr >> 8),
                (unsigned char) (addr >> 16),
                (unsigned char) (addr >> 24),
            SCRIPT_JT2_XFRFASTDAT_LIT,
                (unsigned char) word0,
                (unsigned char) (word0 >> 8),
                (unsigned char) (word0 >> 16),
                (unsigned char) (word0 >> 24),
            SCRIPT_JT2_XFRFASTDAT_LIT,
                (unsigned char) word1,
                (unsigned char) (word1 >> 8),
                (unsigned char) (word1 >> 16),
                (unsigned char) (word1 >> 24),
           SCRIPT_JT2_SENDCMD, TAP_SW_MTAP,
           SCRIPT_DELAY_SHORT, 23,
           SCRIPT_JT2_SENDCMD, TAP_SW_ETAP,
           SCRIPT_JT2_GET_PE_RESP,
        CMD_UPLOAD_DATA);

Tested using PicKit3 with PIC32MM0064GPL036

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant