infineon4engi@twitter infineon@linkedin infineon4engineers infineon@youtube
twitter Facebook Linkedin Youtube

Banner_Aurix_Competition Banner_AURIX_Security-Solution Banner_AURIX_Safety_Products ShieldBuddy TC275 Banner_AURIX_OnzerOS Banner_AURIX_DevelopmentStudio


+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 28

Thread: TC399 Flash sequence for write pflash & dflash

  1. #1
    Beginner Beginner kfir is on a distinguished road
    Join Date
    Mar 2020
    Posts
    27
    Points
    190

    TC399 Flash sequence for write pflash & dflash

    Hi,

    I cannot find anywhere the correct sequence for writing the flash in the different regions:
    1. pflash
    2. dflash

    Can anyone assist on this matter?

  2. #2
    Advanced Advanced cwunder will become famous soon enough
    Join Date
    Feb 2015
    Location
    USA
    Posts
    198
    Points
    3927.5
    Have you looked at this post to see if this helps you?
    https://www.infineonforums.com/threa...7-Memory-Flash

  3. #3
    Beginner Beginner kfir is on a distinguished road
    Join Date
    Mar 2020
    Posts
    27
    Points
    190
    Thanks cwunder.

    I'm trying to write to address 0x80001000

    So it, and followed it in writing my code:
    Code:
        /*  Write either 32 bytes or 256 bytes per page. */
        uint16 password = IfxScuWdt_getSafetyWatchdogPassword();
        uint32 j = 0;
    
        IfxFlash_clearStatus(0);
        IfxFlash_enterPageMode(dest);
        // Check for Page Mode status bit or error
        while (!DMU_HF_STATUS.B.PFPAGE )
        {
            if (DMU_HF_ERRSR.B.SQER == 1 || DMU_HF_ERRSR.B.PROER == 1)
                return 1;
        }
    
        for (j= 0; j < size; j++)
        {
           IfxFlash_loadPage2X32(0x0, *((uint64*) dest), ((uint64*)src)[j]);
           *((uint64*) dest) = ((uint64*)src)[j];
        }
        IfxScuWdt_clearSafetyEndinitInline(password);
        IfxFlash_writePage(dest);
        // Check for Program status bit or error
        while (!DMU_HF_OPERATION.B.PROG)
        {
            if (DMU_HF_ERRSR.B.SQER == 1 || DMU_HF_ERRSR.B.PROER == 1)
                return 1;
        }
        IfxScuWdt_setSafetyEndinitInline(password);
        IfxFlash_waitUnbusy(0, IfxFlash_FlashType_P0);
    although flash does not enter page mode.
    Click image for larger version

Name:	Capture.PNG
Views:	3
Size:	108.2 KB
ID:	4590
    and is stuck on the first while loop.
    Last edited by kfir; Mar 30th, 2020 at 10:17 PM.

  4. #4
    Beginner Beginner kfir is on a distinguished road
    Join Date
    Mar 2020
    Posts
    27
    Points
    190
    OK, understood the mirroring issue.

    now can write to that region by writing to 0xa0000000.

    just need to understand how to create the delay:
    /*Wait for 2*1/fFSI ns (DFlash) or 3*1/fFSI + 8*1/fSRI ns (PFlash). */

  5. #5
    Advanced Advanced cwunder will become famous soon enough
    Join Date
    Feb 2015
    Location
    USA
    Posts
    198
    Points
    3927.5
    just need to understand how to create the delay:
    /*Wait for 2*1/fFSI ns (DFlash) or 3*1/fFSI + 8*1/fSRI ns (PFlash). */
    You can issue a simple for loop for the instruction cycles needed.

    For A2G:
    You need to review your PLL and CCUCONx settings.
    Basically the maximum frequency of the FSI is 100 MHz, the maximum frequency for the SRI is 300 MHz.
    Taking these values you need to delay 20ns for the DFlash or 6 cpu cycles, with the PFlash you need to delay 56.7ns or 17 cpu cycles.

    You can just implement something like this in C and double check your execution time.
    Code:
      for (volatile uint32 delay=10; delay--; )

  6. #6
    Beginner Beginner kfir is on a distinguished road
    Join Date
    Mar 2020
    Posts
    27
    Points
    190
    Adding a big loop after the while wait:
    Code:
     
    while (!DMU_HF_OPERATION.B.PROG)
    		{
    			if (DMU_HF_ERRSR.B.SQER == 1 || DMU_HF_ERRSR.B.PROER == 1)
    				return 1;
    		}
    		for (delay=100000; delay > 0; delay-- ) 
    		{ __asm__ volatile ("nop"); }
    I'm getting an exception:
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	42.3 KB
ID:	4592

    Just to point out, that if I'm debugging line by line it works without exception.
    Last edited by kfir; Apr 1st, 2020 at 03:08 AM.

  7. #7
    Advanced Advanced cwunder will become famous soon enough
    Join Date
    Feb 2015
    Location
    USA
    Posts
    198
    Points
    3927.5
    Adding a big loop after the while wait:
    Why? You only need to wait nanoseconds... For the BUSY bit to set before checking it.

    What are your Watchdog timeouts?
    In your code is the SAFETY ENDINIT open while you are performing the delay as it should not be

    Realize that your delay is more than the "nop" instruction you also need to account for all of the other instructions to construct this delay loop.

    Here is code I have tried for programming a "Program" flash page
    Code:
    /* TC38x delays are just to make sure the maximum times are satisfied
      * They are not for optimal performance 
      */
    #define FLASH_PROG_PAGE_DELAY 34500
    #define FLASH_EVENT_DELAY 100
    #define FLASH_BUSY_DELAY 10
    #define FLASH_PROG_PAGE_SIZE 4
    
    
     /*! \fn  uint8 Flash_WriteProgPage(uint64 *dst, uint64 *src, uint8 pxBusy)
      *  \brief write program flash page (64 bytes in PFlash)
      *  \param *dst: Address to write to NVM memory (start of the page)
      *  \param *src: Address to read data to be written to NVM memory
      *  \param *pxBusy: page write operation occurs on this PFlash block
      *  \return error: E_OK for no faults, E_NOT_OK when a timeout or error occurred
      ******************************************************************************/
     __attribute__((asection(".cpu0_psram", "a=4", "f=xwc0")))
      uint8 Flash_WriteProgPage(uint64 *dst, uint64 *src, uint8 pxBusy)
     {
       uint16 password = IfxScuWdt_getSafetyWatchdogPassword();
       volatile uint32 timeout;
       uint8 error = E_OK;
    
    
       IfxFlash_clearStatus(IFXFLASH_NUM_MODULES);
       IfxFlash_enterPageMode((uint32) dst);
    
    
       timeout = FLASH_EVENT_DELAY;
       while (--timeout && !DMU_HF_STATUS.B.PFPAGE)
       {
           if ((1 == DMU_HF_ERRSR.B.SQER) || (1 == DMU_HF_ERRSR.B.PROER))
           {
             error = E_NOT_OK;
             continue;
           }
       }
    
    
       if ((E_OK == error) && timeout)
       {
         for (uint32 j = 0; j < FLASH_PROG_PAGE_SIZE; j++)
         {
          /* loadPage 64 bits at a time  */
           *(uint64 *) (0xAF0055F0) = *src++;
           __dsync();
         }
    
    
         IfxScuWdt_clearSafetyEndinitInline(password);
         IfxFlash_writePage((uint32) dst);
         IfxScuWdt_setSafetyEndinitInline(password);
    
    
         /* Check for Program status bit or error */
         timeout = FLASH_EVENT_DELAY;
         while (--timeout && !DMU_HF_OPERATION.B.PROG)
         {
           if ((1 == DMU_HF_ERRSR.B.SQER) || (1 == DMU_HF_ERRSR.B.PROER))
           {
             error = E_NOT_OK;
             continue;
           }
         }
    
    
         /* no need to wait on a failure or timeout */
         if ((E_OK == error) && timeout)
         {
           for (timeout=FLASH_BUSY_DELAY; timeout--; )
           {
             ;
             /* Wait for 2*1/fFSI ns (DFlash) or 3*1/fFSI + 8*1/fSRI ns (PFlash)
              * fFSI = 100MHz, fSRI =300MHz
              * then DFlash needs 6 cpu cycles, PFlash needs 17 cpu cycles)
              * delay before checking the busy bit
              */
           }
    
    
           /* wait until HF_STATUSx.BUSY = 0*/
           timeout = FLASH_PROG_PAGE_DELAY;
           while (--timeout && (DMU_HF_STATUS.U & (1 << pxBusy)))
           {
             if (1 == DMU_HF_ERRSR.B.OPER)
             {
               error = E_NOT_OK;
               continue;
             }
           }
         }
    
    
         if ((1 == DMU_HF_ERRSR.B.PVER) || (0 == timeout))
         {
           error = E_NOT_OK;
         }
       }
       else
       {
         error = E_NOT_OK;
       }
    
    
       return error;
     }
    Last edited by cwunder; Apr 1st, 2020 at 06:54 AM.

  8. #8
    Beginner Beginner kfir is on a distinguished road
    Join Date
    Mar 2020
    Posts
    27
    Points
    190
    Hi,

    Thanks for the reply, it might be the watchdog, and if so, why does it work on debug line by line?

    doesn't IfxScuWdt_clearSafetyEndinitInline disable the wdt?

    your driver also gets an exception, same as mine. :/

  9. #9
    Advanced Advanced cwunder will become famous soon enough
    Join Date
    Feb 2015
    Location
    USA
    Posts
    198
    Points
    3927.5
    doesn't IfxScuWdt_clearSafetyEndinitInline disable the wdt?
    Only for a short period to of time. This allows you a "window of time" to write SAFETY ENDINIT protected registers. Please review section "9.4.4 The Endinit Functions" in the AURIXTC3XX_UM_v1.4.pdf for more information on this.

    Concerning an exception I would need to know what Trap you are entering and the relative details.

    The code I posted does run without issues in my setup for a TC389. I am writing to PFlash 0
    Code:
         flashStatus = Flash_WriteProgPage((uint64 *)0xA0038000, (uint64 *)&testArray[0], IfxFlash_FlashType_P0);
    Here is the screenshot from the debugger
    Click image for larger version

Name:	2020_04_01_11_35_28_TRACE32_PowerView_for_TriCore_0_Power_Debug_PRO_.png
Views:	6
Size:	777.7 KB
ID:	4595

  10. #10
    Advanced Advanced UC_wrangler will become famous soon enough
    Join Date
    Jun 2019
    Posts
    258
    Points
    5380
    Note that the AURIX does not support writing to PFLASH while anything is reading from the same PFLASH bank - including the CPU. If you want to write to PFLASH0, that means you either need to execute from some other PFLASH bank, or from RAM.

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.