Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User21784
Level 1
Level 1
First like received
Hi,

I have a range of addresses in PFlash (e.g: A0660000-A066FFFF), and only some part of it from the beginning has written data on it. The rest of the pages are erased. I would like to check the address range which contains valid data. Is there an easy way to do that?
I already have a Pmu_VerifyErase function for DFlash that checks if data and ECC bits are all zero, since Dflash can be read at erased state without ECC trap fails. How can I do the same with PFLash sectors without getting ECC fails?
0 Likes
9 Replies
NeMa_4793301
Level 6
Level 6
10 likes received 10 solutions authored 5 solutions authored
TC2xx or TC3xx?
0 Likes
User21784
Level 1
Level 1
First like received
Sorry, it's TC297
0 Likes
NeMa_4793301
Level 6
Level 6
10 likes received 10 solutions authored 5 solutions authored
Example program:

/*****************************************************
*
* \file TC23x_PFLASH_erase_check.c
*
* \description Demo code to use the flash program interface to check if a PFLASH word line is erased
*
* \copyright Copyright (C) Infineon Technologies AG 2021
*
* Use of this file is subject to the terms of use agreed between (i) you or
* the company in which ordinary course of business you are acting and (ii)
* Infineon Technologies AG or its licensees. If and as long as no such terms
* of use are agreed, use of this file is subject to following:
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated
* by a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/

#include "IfxFlash_reg.h"
#include "IfxScu_reg.h"
#include "stdint.h"
#include "stdbool.h"

bool flash_erased( uint32_t test_address );

volatile uint32_t nonzero_bits;
volatile uint8_t test_blank;

#define FLASH_USER_MARGIN_READ (3U)

// For the ContentVerify we need to calculate
// a) the "base address", which is a multiple of 256kByte
// b) the according WL number
// For that we need following two values for the calculation
//
#define FLASH_VERIFY_CONTENT_SECTOR_SIZE 0x40000 // 256kByte according to ITS
#define FLASH_WORDLINE_SIZE 0x200 // 512 Bytes

#define FLASH_SEQ1 ((*(volatile uint32_t *) 0xAF00AA50u))
#define FLASH_SEQ2 ((*(volatile uint32_t *) 0xAF00AA58u))
#define FLASH_SEQ3 ((*(volatile uint32_t *) 0xAF00AAA8u))


void main( void )
{
test_blank = flash_erased( 0xA0000000 );
test_blank = flash_erased( 0xA0000400 );
test_blank = flash_erased( 0xA0000800 );
test_blank = flash_erased( 0xA0100000 );
test_blank = flash_erased( 0xA01F0400 );

for( ;; )
{
}
}

bool flash_erased( uint32_t test_address )
{
uint32_t wordline_number;
uint32_t base_address;

volatile uint32_t comm1=0;
volatile uint32_t comm2;
uint32_t ucode;

uint32_t testmode_var;
uint32_t current;
uint32_t comm2_bit14_to_bit10_var;
uint32_t wordline_number_comm1_var;
uint32_t wordline_number_comm2_var;
uint32_t comm1_status;
uint32_t comm2_status;

// Wordline and Base Address calculation
// Test is performed on WL number, within a multiple of 256kByte memory range
//
wordline_number = (test_address % FLASH_VERIFY_CONTENT_SECTOR_SIZE) / FLASH_WORDLINE_SIZE;// Calculates the WL number, which is
base_address = (test_address/FLASH_VERIFY_CONTENT_SECTOR_SIZE) * FLASH_VERIFY_CONTENT_SECTOR_SIZE; //Calculate the base address, which is a multiple of 256kByte

// The User Margin Read function requires a current parameter,
// depending on AURIX firmware version
//
ucode = SCU_CHIPID.B.UCODE;
if( ucode >= 0x20 )
{
// In UCODE >= 0x20, the current parameter should be 0.
current = 0;
}
else if( (ucode >= 0x10) && (ucode <= 0x14) )
{
// In versions 0x10 to 0x14, the current should be 5.
current = 5;
}
else
{
// Older UCODE versions don't support User Margin Read
return false;
}

// Prepare arguments, shift to needed position
//
testmode_var = (0x00000003 & FLASH_USER_MARGIN_READ)<<8; // prepared Command test mode
comm2_bit14_to_bit10_var = (0x0000001F & current)<<10; // prepare "reference current" or "control gate voltage" arguments
wordline_number_comm2_var = (0x00000001 & wordline_number) << 15; // Wordline-number bit[0] which is located in COMM2 Register
wordline_number_comm1_var = (0x000001FE & wordline_number) << 7; // Wordline-number bit[8:1] which is located in COMM1 Register

// Write arguments to COMM registers
//
FLASH0_COMM2.U = wordline_number_comm2_var | comm2_bit14_to_bit10_var | testmode_var;
FLASH0_COMM1.U = wordline_number_comm1_var;

// Read registers to make sure store buffers have been flushed
// before starting FLASH command.
//
comm2 = FLASH0_COMM2.U;
comm1 = FLASH0_COMM1.U;
comm1 += comm2;

// Clear flash status
FLASH0_FSR.U = 0xFA;

// Start FLASH Command Sequence
//
FLASH_SEQ1 = base_address;
FLASH_SEQ2 = 1; // verify 1 512 byte word line (sector)
FLASH_SEQ3 = 0x80;
FLASH_SEQ3 = 0x5F;

// Wait the required minimum 23us
// - if this isn't long enough, you'll get a bus error accessing FLASH0_COMM1
//
//wait_x_10ns(2400); //wait 23us + 1 us;
volatile uint32_t i;
for( i=0; i<2000; i++ ) // 148 works at 100 MHz internal oscillator clock
{
}

// Collect the Results from the COMMx Register
// - The result is returned as 13-bit unsigned integer with bits 7:0 in COMM1.STATUS
// and bits 12:8 in COMM2.STATUS bits 4:0
//
comm1_status = FLASH0_COMM1.U & 0x000000FF;
comm2_status = FLASH0_COMM2.U & 0x0000001F;

nonzero_bits = ((comm2_status & 0x1F) << 😎 | comm1_status;

// The word line is erased if the count of non-zero bits is <= 2
//
return( nonzero_bits <= 2 );
}
0 Likes
User9635
Level 4
Level 4
50 replies posted 50 questions asked 25 replies posted
Hello Support,
This code is part of which software bundle release from Infineon?
Is it part of iLLD or MCAL release?
Best Regards
0 Likes
NeMa_4793301
Level 6
Level 6
10 likes received 10 solutions authored 5 solutions authored
This example code is not part of a software bundle.
0 Likes
User9635
Level 4
Level 4
50 replies posted 50 questions asked 25 replies posted
Hello Support,
Can you please provide similar function for TC38x device?
Best Regards
0 Likes

Use the EVER bit in the DMU Error Register for the TC3X to test for successful erasure after calling IfxFlash_eraseVerifySector on the sector under scrutiny.

LordVader_0-1684111706011.png

 

0 Likes
VD00v
Level 1
Level 1
First reply posted Welcome!

Hi, 

Thank you for the post.

Should you not need a code to verify the PFlash, for example for a memory verification without running the code, you can use MEMTOOL too; it is very effective software.

0 Likes
VD00v
Level 1
Level 1
First reply posted Welcome!

Otherwise, you can use OneEye for the same purpose, but you have to run a code with your processor(s) in this case; I could prepare a first OneEye app which helps me download the memory content in a format I can automatically convert to extract the meaning of the recorded values completely. Should you be interested in the matter, please do not hesitate to ask for details.

0 Likes