STM32, mass storage device. how to properly erase memory sectors?
I fixed uint16_t page to uint32_t page  and it worked. Thanks!
void AT45dbxx_ErasePage(uint32_t page)
{
    page = page &lt;&lt; AT45dbxx.Shift; // AT45dbxx.Shift = 9 For 264 byte per page 
    AT45dbxx_Resume();
    AT45dbxx_WaitBusy();
    HAL_GPIO_WritePin(_45DBXX_CS_GPIO,_45DBXX_CS_PIN,GPIO_PIN_RESET);
    AT45dbxx_Spi(AT45DB_PGERASE); // CMD 0x81
    AT45dbxx_Spi((page &gt;&gt; 16) &amp; 0xff);
    AT45dbxx_Spi((page &gt;&gt; 8) &amp; 0xff);
    AT45dbxx_Spi(page &amp; 0xff);
    HAL_GPIO_WritePin(_45DBXX_CS_GPIO,_45DBXX_CS_PIN,GPIO_PIN_SET);
    AT45dbxx_WaitBusy();
}
void AT45dbxx_WritePage(uint8_t *Data,uint16_t len,uint32_t page)
{
    page = page &lt;&lt; AT45dbxx.Shift;  // AT45dbxx.Shift = 9 For 264 byte per page 
    AT45dbxx_Resume();
    AT45dbxx_WaitBusy();
    HAL_GPIO_WritePin(_45DBXX_CS_GPIO,_45DBXX_CS_PIN,GPIO_PIN_RESET);
    AT45dbxx_Spi(AT45DB_MNTHRUBF1);  // CMD 0x82
    AT45dbxx_Spi((page &gt;&gt; 16) &amp; 0xff);
    AT45dbxx_Spi((page &gt;&gt; 8) &amp; 0xff);
    AT45dbxx_Spi(page &amp; 0xff);
    HAL_SPI_Transmit(&amp;_45DBXX_SPI,Data,len,100);
    HAL_GPIO_WritePin(_45DBXX_CS_GPIO,_45DBXX_CS_PIN,GPIO_PIN_SET);
    AT45dbxx_WaitBusy();    
}