Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
31
Ver.1.0.0
One sector contains 4096 bytes, e.g. 0x13000 ~0x13fff.
The “addr” must be the starting
address of one sector, and every time the function erases a complete sector.
Erasing a sector takes some time. In the case of a 16M system clock, it takes about
30~100ms or even longer time to erase a sector.
3) Influence of flash access/erasing operations to system interrupt
System interrupt must be disabled via “irq_disable()” when flash_read_page,
flash_write_page or flash_erase_sector is executed, and then restored
via “irq_restore()”
after operations are finished. This will ensure integrity and continuity of Flash MSPI
timing operation, and avoid hardware resource reentry due to MSPI bus lines invoking by
Flash operation in interrupt.
Since timing sequence of BLE SDK RF packet transmission and reception is always
controlled by interrupt, when system interrupt is disabled during Flash operation, it may
ruin the timing sequence, thus MCU fails to respond in time.
The influence to BLE interrupt by execution time of the Flash access function is almost
negligible; howerver, the “len” in the function will determine the time to access the Flash
area, it’s highly recommended not to set the “len” as large value in BLE connection state
during mainloop.
It takes tens of milliseconds to hundreds of milliseconds to execute the
“flash_erase_sector” function. Therefore, during mainloop of main program, once MCU
enters BLE connection state, try not to invoke the “flash_erase_sector” to avoid
disconn
ection. If it’s inevitable to erase Flash during BLE connection, BLE timing
sequence protection as introduced in section 3.2.4.4 Conn State Slave Role Timing
Protection should be adopted.
4) Read Flash via pointer
Firmware of 5316 BLE SDK is stored in Flash. When the firmware is running, only former
part of the code in Flash is stored and executed as memory resident code in RAM, and
the majority will be transferred to the high-
speed “cache” of RAM from Flash when
needed. MCU will automatically control internal MSPI hardware module to read Flash.
Flash can also be read via pointer. When data are accessed by MCU system bus, if the
data address is not in the memory resident ramcode, system bus will automatically switch
to MSPI, and read data from Flash by using MSCN, MCLK, MSDI and MSDO lines to
operate SPI timing sequence.
The following shows three examples:
u16 x = *(volatile u16*)0x10000;
// read two bytes from Flash 0x10000
u8 data[16];
memcpy(data, 0x20000, 16);
// read 16 bytes from Flash 0x20000 and copy to
data
if(!memcmp(data, 0x30000, 16)){
// read 16 bytes from Flash 0x30000 and compare
with data
//
……
}
In user_init, when calibration values are read from Flash and set to corresponding
registers, the reading is implemented via pointer. Please refer to the function below in
SDK: