STM32 program workflow

*: means done by hardware

* load word @0x0000-0000 to MSP
* load word @0x0000-0004 to PC (reset handler)
fetch
decode
execute

overview:
program work flow

startup_device.s file contains the size of the stack that is used by exceptions and interrupt service routines (ISR) for the current project. The heap which is used by memory allocation functions is configured in this file.

Reset_Handler:
– set up exception vectors tables offset
– initialize stack
– initialize the memory system, if using MMU
– initialize critical I/O devices
– initialize variables required by C and call the main() function

 

 

 

 

 

what’s a program and how it works

‘Get the result of 7+8’ is a program.
‘blink the LED’ is a program.
A program is a task we ask the SOC to execute.

How program works?

Fetch (the CPU get the instruction from flash accroding to the PC into IR)
Decode (IR decoder interpre IR instruction into control signals steps of control unit)
Execute (the CPU works base on control signals)

pipeline

how program works

assembly example

STM32 MCU tear down

For example: STM32F107xx
STM32F107xx(SOC) = Cortex-M3 + FLASH + RAM + Clock + DMA + I/O + USART + TIMERS + SPI + I2C + CAN + ADC + DAC + FSMC + Ethernet + USB

Cortex-M3(ARM Core) = Cortex-M3 CPU + NVIC + TPIU + ETM + SWJ + DWT + ITM + FPB

Cortex-M3 CPU (CPU)(like arm7tdmi, but not the same) tear down:

  • registers
    • programmable registers (Rn, PC, SP, LR, xPSR…)
    • unprogrammable registers (dedicated purpose, like Adderss register, IR, shadow regs)
  • control unit (the control signal after IR decoded)
  • ALU
  • MAC

CPU
cpu
cpu
arm7tdmi

Cortex-M3
cortex-m3

Basic SOC

Basic SOC

 

STM32F107xx

stm32f107xx

cpu physical

Make a plan today!

Do it daily, and you will see the change! Plan is the direction to success.

  • 6am is time to get up, poop, get the energy, you are good to go.
  • 12am is time to get a 20 min snap, then get the energy to work again.
  • 4am is time to exercise. then work.
  • 7am is time to clean, then get the energy to work again.
  • 23am is time to sleep.

123, go. you don’t need to think.

never stop the process untill you finish.