cancel
Showing results for 
Search instead for 
Did you mean: 

Way to denote row addresses of NAND flash may be wrong

LittleYe233
Associate II

I am using STM32CubeH7 from GitHub (the latest commit is here). In stm32h7xx_hal_nand.c, I found something starting at Line 582:

 

if (((hnand->Config.BlockSize) * (hnand->Config.BlockNbr)) <= 65535U)
        {
          *(__IO uint8_t *)((uint32_t)(deviceaddress | ADDR_AREA)) = 0x00U;
          __DSB();
          *(__IO uint8_t *)((uint32_t)(deviceaddress | ADDR_AREA)) = 0x00U;
          __DSB();
          *(__IO uint8_t *)((uint32_t)(deviceaddress | ADDR_AREA)) = ADDR_1ST_CYCLE(nandaddress);
          __DSB();
          *(__IO uint8_t *)((uint32_t)(deviceaddress | ADDR_AREA)) = ADDR_2ND_CYCLE(nandaddress);
          __DSB();
        }
        else /* ((hnand->Config.BlockSize)*(hnand->Config.BlockNbr)) > 65535 */
        {
          *(__IO uint8_t *)((uint32_t)(deviceaddress | ADDR_AREA)) = 0x00U;
          __DSB();
          *(__IO uint8_t *)((uint32_t)(deviceaddress | ADDR_AREA)) = 0x00U;
          __DSB();
          *(__IO uint8_t *)((uint32_t)(deviceaddress | ADDR_AREA)) = ADDR_1ST_CYCLE(nandaddress);
          __DSB();
          *(__IO uint8_t *)((uint32_t)(deviceaddress | ADDR_AREA)) = ADDR_2ND_CYCLE(nandaddress);
          __DSB();
          *(__IO uint8_t *)((uint32_t)(deviceaddress | ADDR_AREA)) = ADDR_3RD_CYCLE(nandaddress);
          __DSB();
        }

 

I think that if the number of total pages is no more than 65535, the code block sends a two-byte row address to NAND, otherwise three-byte. But if there is an NAND flash chip with 65536 pages, in my opinion, it is still sufficient to denote the row address with a two-byte number (from 0x0000 to 0xFFFF). In fact I am using W29N01GV with such number of pages, which only need two bytes for the row addresses. So is there anything wrong with the code? Any your reply will be highly appreciated.

0 REPLIES 0