This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129ENCPDT: user register writing

Part Number: TM4C129ENCPDT
Other Parts Discussed in Thread: UNIFLASH

Tool/software:

Hello,

I need a command line to write the user register0 of my TM4C. 

I found this one : 

dslite load --config "C:\[...]\tm4c129encpdt.ccxml" "C:\[...]\data.bin",0x400fe1e0

with "data.bin" a file containig the value i want to write.

This is working but the data are not commited, if i unpower and repower the board, the datas are erased.

how can i fix it? 

Thanks,

Best regards

  • HI,

    dslite load --config "C:\[...]\tm4c129encpdt.ccxml" "C:\[...]\data.bin",0x400fe1e0

    I don't think you can use dslite to program the user0 register. This is normally done as part of the code using FlashUserSave() API or using tool such as LM Flash Programming or Uniflash. See below. I think dslite only programs your desire value to address 0x400fe1e0. Your data.bin file is not a program that will carry out execution to make user0 permanent. You can refer to the FlashUserSave() API source where it writes to the COMIT bit on the FMC register to make the register permanent. The API will wait in a loop until the operation is complete. This is not a just a simple write to a register. This is programming a non-volatile register which is similar to programming a flash memory address where the programming can take up to a few hundreds of uS. 

    int32_t
    FlashUserSave(void)
    {
        //
        // Setting the MSB of FMA will trigger a permanent save of a USER
        // register.  Bit 0 will indicate User 0 (0) or User 1 (1).
        //
        HWREG(FLASH_FMA) = 0x80000000;
        HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
    
        //
        // Wait until the write has completed.
        //
        while(HWREG(FLASH_FMC) & FLASH_FMC_COMT)
        {
        }
    
        //
        // Tell the flash controller to write the USER1 Register.
        //
        HWREG(FLASH_FMA) = 0x80000001;
        HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
    
        //
        // Wait until the write has completed.
        //
        while(HWREG(FLASH_FMC) & FLASH_FMC_COMT)
        {
        }
    
        //
        // Success.
        //
        return(0);
    }

  • Hi, thank you for your answer,

    i forgot to precise that I am using a XDS100V2 to communicate with JTAG.

    The goal of this thing is to make a production bench to write this register automatically with a script.

    Im quite a begginner, how can I use the FlashUserSave you showed me?

    Thanks,

    Best regards

  • Hi,

      I have not used dslite to write USER0 register. You will need to make dslite write to the below three addresses. 

      HWREG(FLASH_USERREG0) = ui32User0;  // Write value ui32User0 to USER0 register at 0x400fe1e0

      HWREG(FLASH_FMA) = 0x80000000;  // Write 0x80000000 to the FMA register


      HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT; // Write 0xA4420000 | 0x9 to permanently commit the USER0 programming

  • Thank you very much for your Help.

    I managed to do this ; 

      HWREG(FLASH_USERREG0) = ui32User0;  // Write value ui32User0 to USER0 register at 0x400fe1e0

      HWREG(FLASH_FMA) = 0x80000000;  // Write 0x80000000 to the FMA register

    but not the last step, i get this message :

    dslite flash --config "C:[...]\configs\tm4c129encpdt.ccxml" "C:\[...]\fmc.bin",0x400fd008
    CORTEX_M4_0: GEL Output:
    Memory Map Initialization Complete
    error: CORTEX_M4_0: File Loader: Verification failed: Values at address 0x400FD008 do not match (expected: 0xA4420009, actual: 0x00000000) Please verify target memory and memory map.
    Failed: File: C:\[...]\fmc.bin: a data verification error occurred, file load failed.

    furthermore, datas are inverted compare to notepad hex editor, for example, in the file i tried to commit above, i had to write this: 

  • Hi,

    error: CORTEX_M4_0: File Loader: Verification failed: Values at address 0x400FD008 do not match (expected: 0xA4420009, actual: 0x00000000) Please verify target memory and memory map.

    According to the datasheet, reading the WRKEY will return 0. Reading a 0 on COMT bit indicates the commit is completed.

    You should do a power cycle and check the USER0 register to see if has your written value. 

    furthermore, datas are inverted compare to notepad hex editor, for example, in the file i tried to commit above, i had to write this: 

    For little endian, 09 is at byte 0, 00 is at byte 1, 42 at byte 2 and a4 at byte 3. They are correct. 

  • ok in fact it was working well!

    i thought 0 was when values where ignored, my mistake.

    Thank you very much for your help! thanks a lot Slight smile