You are on page 1of 33

ECE 521:

Microprocessor System
Assembly language programming and simple I/O
What we will learn in this section:

 Introduction of STM32F446RE Nucleo Board


 Assembly Language Programmer's Model
 Simple I/O (LED) using Assembly programming
NUCLEO-F446RE
STM32F446RE Nucleo Block Diagram
 The ARM has 4GB of memory address
space
5 STM32 Arm Naming
 The STM32 part numbers have the following format;
STM32 F 4xxx P FFF T 6

 The STM32F446_Nucleo board


used the STM32F446RE chip
that has 64 pins and 512kB size
of on-chip Flash Memory
STM32F446RE Nucleo Board and Top Layout

The ARM Nucleo board. The USB port at the top of


the board (mini-B) is the programming port.[3]
STM32F446RE Features
 LWFP64 package  Board power supply: through USB bus or from
 Three 12-bit, 2.4 MSPS ADC: 16 channels an external 5V supply voltage

 Two 12-bit D/A converters  External application power supply: 3V and 5V

 General-purpose DMA
 ST MEMS motion sensor, 3-axis digital output
accelerometer
 Audio DAC with integrated class D
 ST MEMS audio sensor
speaker driver
 Audio DAC with integrated class D speaker
 50 GPIO ports with interrupt capability driver
(most are 5 V tolerant)
 Eight LEDs (4 for user)
 Four USARTs and two UARTs
 Two pushbuttons (user and reset)
 Two SAI (serial audio interface)
 USB micro-AB connector for connection to a
 Two CAN (2.0B Active) mouse or other USB peripheral.
 SDIO interface  USB mini-B connector for programming
 8- to 14-bit parallel camera interface up directly from the Keil μVison 5 development
at 54 Mbytes/s
system.
STM32F446RE Features
 The STM32F446RE is an ARM Cortex M4
processor. The M4 is identical to the M3
but it has an additional DSP engine
added on.
 The ARM Cortex M3 and M4 processors
are RISC machines with a 3-stage pipe
(Fetch, Decode, and Execute)
 The M3 and M4 processors execute the
Thumb2 instruction set which consists of
50, 16-bit instructions and 6, 32-bit
instructions

ARM Cortex 3-Stage Pipeline


STM32F446RET6 Processor Microcontroller Block
Diagram
For the Nucleo board the
STM32F446RET6 has 512 KB of
flash memory and 128 K of RAM.
ECE 521:
Microprocessor System
Assembly Language Programmer's Model
Internal Registers
Figure shows the internal registers accessible to the assembly
language programmer.

 Register R13 is the stack pointer. The lower two bits of this
register is always zero since it accesses the stack on 32-bit
word boundaries. Normal operations always use SP_main
but for thread mode the processor can be configured to
use SP_process.
 Link Register R14 is a special one-level stack. When a
subprogram call is made from a main program the return
address goes into R14. If the subprogram makes further
calls the return address goes onto the stack in memory.

 Register R15 is the program counter. It is 32-bits long and


there is a linear address space from 0 to 232-1. Bit 0 of this
register is always 0 so that instructions are aligned on 16-bit
boundaries.
Memory Map of STMF446RE

 Flash memory used for Program Code


 SRAM used for variables, scratch pad and stack
 Example I/O : GPI0,Timer and ADCs
Notes: the upper limit address varies among the chips depending on the size of
on-chip Flash, SRAM and peripherals.
Memory map for STM32F446RE

 The ARM has 4GB of memory address


space
 use memory mapped I/O (meaning the
I/0 peripherals registers are mapped into
the 4GB memory space.
 The ARM has a 32-bit address and in hex
addresses range from 0000 0000 to FFFF
FFFF. This is a linear address space and
there are no I/O instructions since all ports
are mapped from memory.
 All of the I/O ports are mapped into the 4
GByte memory space. From Figure we see
that the peripherals are mapped to the
address range 0x4000 0000 to 0x5FFF FFFF.
Memory Addresses for I/O Ports
STM32F446RET6 Pin Assignments

The microcontroller on the


Nucleo board is the
STM32F446RET6 which
comes in a 64 pin
LQFP 64 (Low profile Quad
Flat Pack) package.
STM32F446RET6 Pin Assignments

 The Nucleo board has two connectors


each consisting of two columns of pins.
Connector CN7 is on the left in Figure and
CN10 is on the right.
 CN7 and CN10 each have 38 pins in two
19-pin columns for a total of 76 pins so that
all pins of the LQFP 64 package are
brought out along with multiple power and
ground lines.
 A few pins have no connection (NC). See
Table 29 in the User's Manual for a
complete mapping of all of the package
pins to the board pins at CN7 and CN10.
Pin Locations for CN7
Pin Locations for CN10
Pin Locations for CN6 & CN8
Pin Locations for CN5 & CN9
STM32F446RET6 Pin Assignments

 For the I/O ports, Table 2 gives the pins are available for the Nucleo Board:

Notes:
1. PB11 is not brought out to a board pin.
2. PA13 and PA14 are shared with the debug
circuitry and should be avoided if possible.
3. A User LED (green) is connected to PA5 and is
on when the pin is high.
4. A User push-button is connected to PC13.
Alternatives ARM Compilers

STM32CubeIDE MBED STM32DUINO KEIL uVISION

Specific and optimize Cross platform and Access to various Assembly and
STM32 chips multiple vendors library capability

Hardware Abstraction C C Assembly and C


(HAL) programming
Loading Project to Nucleo
 Plugs an USB cable into CN1 on the Nucleo board. If your
computer does not locate the driver you will have to locate the
driver and install it.
 Install ( )
Loading Project to Nucleo

 With your board plugged in, click Options for Target 1 icon
 Under the Debug tab click on the pull down menu on the right and choose STLink Debugger.
Loading Project to Nucleo
 Then click on Settings. At Target Com, select SW at the port and click OK.
Loading Project to Nucleo

 At this point you are ready to upload your code to the board and run your
program.
 To do this click on the Debug button or, click on Debug→ Start/Stop
Debug Session. The program will be downloaded to your board. Click on
Debug→Run to start the program running.
Debugger Screen
Debugger Screen
 The program that we are debugging uses port A for output. This is called GPIOA (General
Purpose I/O port A). Click on Peripherals → System Viewer → GPIOA to show the registers
in GPIO port A.

The registers in GPIOA as seen in the debugger. Click on the +


sign to expand the register to see the bits.
Interfacing to LED in assembly
language
Program Descriptions
 Refer to program blinking.s
 This program toggles LD2 for 0.5
second ON and 0.5 second OFF by
writing 0 or 1 to bit 5 of the Port A
Output Data Register.
 The green LED (LD2) is connected to
PA5.
 The LED is high active (a '1' turns on the
LED).
User LED connection for STM32F446RE Nucleo board  The default system clock is running at
16 MHz.
Steps to toggle the LD2 (green) continuesly
of the Nucleo board

1) Set the Mode register bits for PA5 as output


2) Write HIGH to PA5 in data OUT register
3) Call a delay function
4) Write LOW to PA5 in data OUT register
5)Call a delay function
6)Repeat step 2 To 5
Sample Coding

You might also like