STM32F1 Memory & Bus

Started by tha, October 22, 2020, 08:07:25 AM

Previous topic - Next topic

tha

Reading the Flash memory
Flash memory instructions(คำสั่ง) และ data access ถูกกระทำผ่านทาง the AHB bus. The prefetch block ถูกใช้สำหรับ instruction fetches ผ่านทาง the ICode bus. Arbitration(การชี้ขาด) ถูกกระทำใน the Flash memory interface, และลำดับความสำคัญจะถูกกำหนดให้กับ data access บน the DCode bus.

Read accesses สามารถถูกดำเนินการได้ด้วยตัวเลือกการกำหนดค่าต่อไปนี้ :
• Latency: จำนวนของ wait states สำหรับ a read operation ที่โปรแกรมได้ทันที
• Prefetch buffer (2 x 64-bit blocks): มันถูกเปิดการใช้งานหลังจาก reset; a whole(ทั้ง) block สามารถถูกแทนที่ด้วย a single
   read จาก the Flash memory เนื่องจากขนาดของ the block เท่ากันกับ the bandwidth ของ the Flash memory. ขอบคุณ the
   prefetch buffer, faster CPU execution เป็นไปได้เนื่องจาก the CPU fetches(ดึง) one word ในเวลาเดียวกันที่ the next word
   พร้อมมีให้ใช้งานใน the prefetch buffer
• Half cycle: สำหรับ power optimization

Note:  ตัวเลือกเหล่านี้ต้องถูกใช้ให้สอดคล้องกับ the Flash memory access time. The wait states แสดงถึงอัตราส่วนของ the SYSCLK (system clock) period ต่อ the Flash memory access
time:
- 0 wait states, if 0 < SYSCLK ≤ 24 MHz
- 1 wait state, if 24 MHz < SYSCLK ≤ 48 MHz
- 2 wait states, if 48 MHz < SYSCLK ≤ 72 MHz

Half cycle configuration ไม่มีให้ใช้ร่วมกันกับ a prescaler บน the AHB. The system clock (SYSCLK) ควรเท่ากันกับ the HCLK clock. คุณสมบัตินี้จึงสามารถถูกใช้ได้กับเพียง a low-frequency clock ของ 8 MHz หรือน้อยกว่า. มันสามารถถูกสร้างจาก the HSI หรือ the HSE แต่ไม่ใช่จาก the PLL.

The prefetch buffer ต้องถูกเก็บเมื่อใช้ a prescaler แตกต่างไปจาก 1 บน the AHB clock.

The prefetch buffer ต้องถูก switched on/off เพียงเมื่อ SYSCLK ต่ำกว่า 24 MHz และไม่มี prescaler ถูกใช้งานบน the AHB clock (SYSCLK ต้องเท่ากับ HCLK). The prefetch buffer โดยปกติ switched on/off ในระหว่างขั้นตอนการเริ่มต้น(the initialization routine), ขณะที่ the microcontroller กำลังรันบน the internal 8 MHz RC (HSI) oscillator.

การใช้ DMA: DMA เข้าถึง Flash memory บน the DCode bus และมีลำดับความสำคัญเหนือกว่า ICode instructions. The DMA จัดให้มี one free cycle หลังจากแต่ละ transfer. บางคำสั่งสามารถถูกดำเนินการพร้อมกันกับ DMA transfer.

Programming and erasing the Flash memory (การโปรแกรมและการลบ the Flash memory)

The Flash memory สามารถถูกโปรแกรม 16 bits (half words) ในแต่ละครั้ง

สำหรับ write และ erase operations บน the Flash memory (write/erase), the internal RC oscillator (HSI) ต้องถูก ON.

The Flash memory erase operation สามารถถูกดำเนินการที่ page level หรือบน the whole Flash area (mass-erase). The mass-erase ไม่มีผลต่อ the information blocks

เพื่อให้แน่ใจว่าจะไม่มี over-programming, the Flash Programming และ Erase Controller blocks ถูกให้นาฬิกาโดย a fixed clock.

การสิ้นสุดของ write operation (programming or erasing) สามารถทริก an interrupt. interrupt นี้สามารถถูกใช้เพื่อออกจาก WFI mode, ได้เพียงถ้า the FLITF clock ถูกเปิดการใช้งาน. มิฉะนั้น, the interrupt นี้ถูกให้บริการเพียงหลังจากออกจาก WFI เท่านั้น.

The FLASH_ACR register ถูกใช้เพื่อ enable/disable prefetch และ half cycle access, และเพื่อควบคุม the Flash memory access time ให้สอดคล้องกับ the CPU frequency. ตารางข้างล่างนี้จัดให้มี the bit map และ bit descriptions สำหรับ register นี้.

สำหรับ information ที่สมบูรณ์ของ Flash memory operations and register configurations, อ้างอิงถึง the STM32F10xxx Flash programming manual (PM0075) or to the XL STM32F10xxx Flash programming manual (PM0068).

tha



Bits 31:6 Reserved, must be kept at reset value.
Bit 5 PRFTBS: Prefetch buffer status
บิตนี้จัดให้มีสถานะของ the prefetch buffer.
     0: Prefetch buffer ถูกปิดการใช้งาน
     1: Prefetch buffer ถูกเปิดการใช้งาน

Bit 4 PRFTBE: Prefetch buffer enable
     0: Prefetch ถูกปิดการใช้งาน
     1: Prefetch ถูกเปิดการใช้งาน

Bit 3 HLFCYA: Flash half cycle access enable
     0: Half cycle ถูกปิดการใช้งาน
     1: Half cycle ถูกเปิดการใช้งาน

Bits 2:0 LATENCY: Latency
บิตเหล่านี้แสดงอัตราส่วนของ the SYSCLK (system clock) period ต่อ the Flash access time.
     000 Zero wait state, if 0 < SYSCLK≤ 24 MHz
     001 One wait state, if 24 MHz < SYSCLK ≤ 48 MHz
     010 Two wait states, if 48 MHz < SYSCLK ≤ 72 MHz

tha

3.4 Boot configuration
ใน the STM32F10xxx, 3 different boot modes สามารถถูกเลือกผ่านทาง BOOT[1:0] pins ดังแสดงใน Table 9.



ค่าบน the BOOT pins ถูกลงกลอน(latched) บน the 4th rising edge ของ SYSCLK หลังจาก a reset. มันขึ้นอยู่กับผู้ใช้ที่จะเซ็ต the BOOT1 และ BOOT0 pins หลังจาก Reset เพื่อเลือก the required boot mode.

The BOOT pins ยังถูกสุ่มอีกครั้ง(re-sampled) เมื่อออกจาก Standby mode. ด้วยเหตุนี้พวกมันต้องถูกเก็บไว้ใน the required Boot mode ที่กำหนดค่าใน Standby mode. หลังจาก startup delay นี้ผ่านไป, the CPU ดึงข้อมูล(fetches) the top-of-stack value จาก address 0x0000 0000, จากนั้นเริ่ม code execution จาก the boot memory ที่เริ่มจาก 0x0000 0004.

เนื่องจาก fixed memory map ของมัน, the code area เริ่มจาก address 0x0000 0000 (เข้าถึงผ่านทาง the ICode/DCode buses) ขณะที่ the data area (SRAM) เริ่มจาก address 0x2000 0000 (เข้าถึงผ่านทาง the system bus). The Cortex®-M3 CPU ดึงข้อมูล(fetches) the reset vector บน the ICode bus เสมอ, ซึ่งหมายความว่ามี the boot space มีให้ใช้ใน the code area (โดยทั่วไป, Flash memory)เท่านั้น. STM32F10xxx microcontrollers จัดให้มีกลไกพิเศษเพื่อสามารถ boot จาก SRAM ได้อีกด้วยและไม่เพียงจาก main Flash memory และ System memory เท่านั้น.

ขึ้นอยู่กับ the selected boot mode, main Flash memory, system memory หรือ SRAM สามารถเข้าถึงได้ดังต่อไปนี้ :

• Boot จาก main Flash memory: the main Flash memory ถูกนามแฝง(aliased) ใน the boot memory space (0x0000
   0000), แต่ยังคงเข้าถึงได้จาก original memory space (0x800 0000) ของมัน. กล่าวอีกนัยหนึ่ง, the Flash memory contents
   สามารถถูกเข้าถึงเริ่มจาก 0x0000 0000 หรือ 0x800 0000.

• Boot จาก system memory: the system memory ถูกนามแฝง(aliased) ใน the boot memory space (0x0000 0000), แต่
   ยังคงเข้าถึงได้จาก original memory space ของมัน (0x1FFF B000 ใน connectivity line devices, 0x1FFF F000 ใน mcu
   เบอร์อื่น).

• Boot จาก the embedded SRAM: SRAM เข้าถึงได้เพียงที่ address 0x2000 0000 เท่านั้น

Note: เมื่อ booting จาก SRAM, ใน the application initialization code, คุณต้องย้ายที่ the vector table ใน SRAM โดย
    ใช้ the NVIC exception table และ offset register.

สำหรับ XL-density devices, เมื่อ booting จาก the main Flash memory, คุณมีทางเลือกที่จะ boot จากหนึ่งใน two memory banks. โดบค่าเริ่มต้น, boot จาก Flash memory bank 1 ถูกเลือก. คุณสามารถเลือกที่จะ boot จาก Flash memory bank 2 โดยการเคลียร์ the BFB2 bit ใน the user option bytes. เมื่อบิตนี้ถูกเคลียร์และ the boot pins อยู่ใน the boot จาก main Flash
memory configuration, the device บู๊ท(boots) จาก system memory, และ the boot loader กระโดดไปปฏิบัติงาน the user application ที่โปรแกรมใน Flash memory bank 2. สำหรับรายละเอียดที่มากขึ้นอ้างอิงถึง AN2606.

Note: เมื่อ booting จาก Bank2 ใน the applications initialization code, ย้ายที่ the vector table ไปยัง the Bank2
     base address. (0x0808 0000) โดยใช้ the NVIC exception table and offset register.


tha

Embedded boot loader
The embedded boot loader ถูกตำแหน่งอยู่ใน the System memory, โปรแกรมโดย ST ในระหว่างการผลิต. มันถูกใช้เพื่อโปรแกรมใหม่ the Flash memory ด้วยหนึ่งของ the available serial interfaces:
• ใน low-, medium- and high-density devices the bootoader ถูกทำให้ทำงานผ่านทาง the USART1 interface.
• ใน XL-density devices the boot loader ถูกทำให้ทำงานผ่านทาง the following interfaces: USART1 or USART2
   (remapped).
• ใน connectivity line devices the boot loader สามารถถูกทำให้ทำงานผ่านทางหนึ่งของ the following interfaces: USART1,
   USART2 (remapped), CAN2 (remapped) or USB OTG FS ใน Device mode (DFU: device firmware upgrade).

The USART peripheral ทำงานด้วย the internal 8 MHz oscillator (HSI). The CAN และ USB OTG FS, อย่างไรก็ตาม, สามารถทำงานได้ก็ต่อเมื่อ an external 8 MHz, 14.7456 MHz หรือ 25 MHz clock (HSE) มีอยู่เท่านั้น.

Note: สำหรับรายละเอียดที่มากขึ้นอ้างอิงถึง AN2606.