cancel
Showing results for 
Search instead for 
Did you mean: 

FLASH STM32U5 Quad Word Size - Confused!

Rob Ashworth
Senior

I'm confused by ST's seeming definition of what they think a QUAD word is....according to most of the planet a WORD is 16-bits, so a QUAD word is 64-Bits.  However according to ST a quad word is 128 bits on the STM32U535.

I enclose a section of my code - essentially I want to write 11520 values which are U32's and then read them again when I power it back up, bit its getting confused because I can't get my head around whether there's 64, or 128 bits in a QUAD WORD!

 

xnLookup[][][] is the Parameter I want to write, and the read back which is a U32

This is the WRITE:

 i=0;//Channel 0..3
   j=0;//Temperature 0..180 (-50 to +130DegC)
   k=0;//Term X0, X1, X2, X3 etc
   n=1;//Counter for every 4th flash word
   MemCount=0;//Total memory locations


   //was 11520 for -50 to +130DegC.  change to
   for(m=0;m<11520;m++)//Total number of parameters to write - //12160
   {
	   //Copy the polynomial term into the flash array
	   flashdata32[n-1].l=xnlookup[k][i][j].l;//Put the polynomial term onto the flash array

	   //Every 4 itterations, write the array to flash
	   if(n==4)
	   {
		   n=0;//reset the counter
		   HAL_FLASH_Program(FLASH_TYPEPROGRAM_QUADWORD, FLASH_TLOOKUP+MemCount, ((u32)flashdata32));
		   MemCount=MemCount+16;//Next QUAD word - 16 BYTES
	   }
	   //Do the relevant index incrementing - next temperature, next channel, or next term
	   if(j>=180)
	   {
		   j=0;
		   i++;//i is the channel number 0..3
		   if(i>=16)
		   {
			   i=0;
			   j=0;
			   k++;//k goes 0,1,2,3 for each polynomial term
		   }
	   }
	   n++;//n is the Flashword index 0..3   4 words =16 bytes
	   j++;//j is the temperature index
   }

    //Now lock the flash
    HAL_FLASH_Lock();
}

This is the READ:

//Read all of the configuration data
void Read_TLookup(void)
{
   u16 i,j,k,l;
   u32 MemCount;

   l=0;
   k=0;

   //Read the Polynomial Calibration values
   l=0;
   for(k=0;k<4;k++)//Polynomial order index (X0, X1, X2, X3)
   {
      for(i=0;i<16;i++)//channel
      {
         for(j=0;j<180;j++)//temperature index - was 180, change to 190
         {
            MemCount=l*4;
            xnlookup[k][i][j].l=*(u32*)(FLASH_TLOOKUP+MemCount);//floating point representation
            l++;
         }
      }
   }
}

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
STackPointer64
ST Employee

Hello @Rob Ashworth,

A word typically denotes the native data size of a CPU, corresponding to its architecture. For example, on a 16-bit CPU, a word is 16 bits; on a 32-bit CPU, it is 32 bits, and so forth. In the case of the x86 architecture, originally a 16-bit design, the term "word" referred to 16 bits. With the evolution to 32-bit (x86) and 64-bit (x86-64) architectures, the native word size expanded accordingly to 32 bits and 64 bits, respectively, reflecting the CPU’s data handling capabilities. I hope this clarifies the misunderstanding.

Best regards,

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.

View solution in original post

4 REPLIES 4
STackPointer64
ST Employee

Hello @Rob Ashworth,

A word typically denotes the native data size of a CPU, corresponding to its architecture. For example, on a 16-bit CPU, a word is 16 bits; on a 32-bit CPU, it is 32 bits, and so forth. In the case of the x86 architecture, originally a 16-bit design, the term "word" referred to 16 bits. With the evolution to 32-bit (x86) and 64-bit (x86-64) architectures, the native word size expanded accordingly to 32 bits and 64 bits, respectively, reflecting the CPU’s data handling capabilities. I hope this clarifies the misunderstanding.

Best regards,

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.
TDK
Super User

> according to most of the planet a WORD is 16-bits, so a QUAD word is 64-Bits

The size of a "word" is dependent upon context. It is definitely not almost always 16 bits. It's generally the native size of whatever you're working with. On a 32-bit mcu, it's generally 32 bits.

Here, it is 32 bit.

If you feel a post has answered your question, please click "Accept as Solution".

Thanks for the reply - I guess understand even if in my view ST shouldn't have called it a "WORD" to avoid confusion.

gbm
Principal

Basically today "word" is equivalent to 16 bits only in Intel x86 world. When 8086 was introduced in 1979, the widest data it could handle was 16-bit, so that was called a "word".

All the computer architectures introduced after 1980 define word as 32-bit, 16-bit entity is called "halfword", and 64-bit - "doubleword". It is and was the same for MIPS, SPARC, ARM, POWER, RISC-V, ARC and Xtensa. There is no modern architecture using "word" to refer to 16-bits.

It's the architecture owner/designer who names the things - in the case of STM32 which uses ARM architecture, we should follow the ARM dictionary of names.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice