0% found this document useful (0 votes)
153 views

Programming Your Nucleo Board: Updated:Wednesday, March 14, 2018

Uploaded by

Littleant
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views

Programming Your Nucleo Board: Updated:Wednesday, March 14, 2018

Uploaded by

Littleant
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Programming Your

Nucleo Board
Updated:Wednesday, March 14, 2018
Outline
• Download the provided Zip file on the web!!
• What is Nucleo Board?
• Programing the development board
STM32F401
Board IO Pins
Ardunio Compatible
Morpho connector
Nucleo Board Pinouts
Comparing Arduino and Nucleo Board
Expansion Shields for Nucleo Board
Driver boards

CO Sensor
STM32 Nucleo Ecosystem

http://www.st.com/en/evaluation-tools/stm32-mcu-nucleo.html?querycriteria=productId=LN1847
STM32 Nucleo Ecosystem STM32F401RE MCU –
STM32F401RET6

Flash
Size

http://www.st.com/en/evaluation-tools/stm32-mcu-nucleo.html?querycriteria=productId=LN1847
STM32F401RE MCU –
STM32F401RET6
• ARM Cortex-M4 @ 84 MHZ
• 512-KB Flash & 96KB SRAM
• 64-Kbyte of CCM (core coupled memory) data RAM
• LCD parallel interface, 8080/6800 modes
• Timer with quadrature (incremental) encoder input
• 5 V-tolerant I/Os
• Parallel camera interface
• True random number generator
• RTC: subsecond accuracy, hardware calendar
• 96-bit unique ID

http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-f401re.html#design-scroll
STM32F401RE MCU
Zooming in
Programmer

STM32
http://www.st.com/content/ccc/resource/technical/document/user_manual/98/2e/fa/4b/e0/82/43/b7/DM00105823.pdf/files/DM00105823.pdf/jcr:content/translations/en.DM00105823.pdf
System View
• The ST-LINK Programmer

allows us to
program the
board

STM32
Board Schematic

https://www.arrow.com/en/reference-designs/nucleo-f401re-stm32-nucleo-development-board-with-
stm32f401ret6-mcu-supports-arduino-and-st-morpho-connectivity/e9173db0f3c486986faab9dbea5b2a9b
Board Schematic
Use the bush button

https://www.arrow.com/en/reference-designs/nucleo-f401re-stm32-nucleo-development-board-with-
stm32f401ret6-mcu-supports-arduino-and-st-morpho-connectivity/e9173db0f3c486986faab9dbea5b2a9b
Board Schematic

https://www.arrow.com/en/reference-designs/nucleo-f401re-stm32-nucleo-development-board-with-
stm32f401ret6-mcu-supports-arduino-and-st-morpho-connectivity/e9173db0f3c486986faab9dbea5b2a9b
Answer the following questions:
You need to use the board schematic. Make sure you have the board.

1. Can the Nueclo board operate with 3.3V supply?


2. How many LEDs the board have? What are the Labels?
3. How many jumpers does the board have? How are they labeled?
4. Does the board outputs 3.3V?
5. How many buttons are on the board? How are they labeled?
6. How many oscillators are on the board? How are they labeled?
7. What types of package the STM chip uses?
8. How many pins does the MCU have?
9. Which port the BUE button is connected to?
10. PC10 is connected to which PIN on the chip?
11. What is the value of the resistor directly connected to the Green LED?
12. Looking at the board, where are SB29 and SB42 and are they closed or open?
13. Which IO port LD2 is connected to?
14. How many pins (in total) are on each Morpho connector?
15. Which PIN on the Morph connector is connected to PC10? What is the reference designator for this Morpho connector?
16. On your board is JP6 placed? What is it used for (see the schematic)?
17. How many PORTS are available on the board (e.g., Px) ? How many bits does each PORT have?
Checking your Connection
Make sure your computer sees the board
If not make sure you have downloaded the driver – just double click on the provided driver file.
Start a NEW project in your Keil
• On the left side of the
window under Devices,
click to expand
STMicroelectronics.
• Find STM32F4 Series and
expand it
• Double click on
STM32F401RE and it
should add it to the packs
list on the right side.
• Click all the buttons that
say Install or Update to
get all the
features/packages that
Keil offers.
Start A New Project
• Open Keil uVision 5 from your Windows
• Make sure all projects are closed:
• Project à Close Project
• Click on Projectà new uVision Project … [1]

• In the window click on New Folder [1]


• Type the name of the project: [3]
ASM_NewProject [2]
• Go to the new folder that you just
created [3]

[2]
Start A New Project-2
• The Select Device window pops up
• In the search type: STM32F401RETx
• Click on the device (STM32F401RETx)
that showed up and then click OK
Start A New Project-3
• At this point the Manage Run
window pops up
• CHECK CMSIS à CORE and
DEVICEàSTARTUP boxes –
note that the color changes
• Then click OK

If Devices Are Marked as X


Start A New Project-4
• At tis point your Project window should show the [2]
CMSIS and DEVICE – these are the CMSIS system
initialization files and startup files in order for the
RUN TIME to operate [1] [4] [5]
• Click on the OPTIONS FOR TARGET [2]
[1]
• Click on DEBUG tab [3]
• CHECK and Select the USE ST-LINK [4]
• Click on Setting [5]
• In the CORTEX-M4 Target Drive [9]
• Choose Under Reset [6]
• Check RESET AFTER CONTROL Box [7]
• Click ok [8]

• In the OPTIONS window, Click on OK [9]


• In the PROJECT window click on Source Group 1 and
select ADD NEW ITEM….
• In the new window select

[6]
[7]
[8]
Start A New Project-5
• In the PROJECT window click on Source Group 1 and
select ADD NEW ITEM….
• In the new window select ASM files
• Then type the name of the ASM file:
ASM_NewProject.s
• Click on ADD
Start A New Project
• In the project window click on ASM_NewProject.s
under the Source Group 1 folder
• Open the file
• Type in the following code
• Save the file
• Press F7 and make sure there are no errors (as
shown below) – Note: If you do not see the TIME
ELAPSED then you need to make sure you BUILD ALL

assembling startup_stm32f401xe.s...compiling
system_stm32f4xx.c...linking...Program Size: Code=300 RO-data=404
RW-data=0 ZI-data=1536 ".\Objects\workingProject.axf" - 0 Error(s),
0 Warning(s).Build Time Elapsed: 00:00:01

• Under DEBUS tab à Click on the START/STOP


DEBUG SESSION
• Under DEBUS tab à Click on RUN
Running with Code Size Limit: 32KLoad
"C:\\Users\\es\\Desktop\\EE310-
2017\\Objects\\workingProject.axf" *** Restricted Version with
32768 Byte Code Size Limit*** Currently used: 704 Bytes (2%)
Make sure you change
your STARTUP file UNCOMMENT these lines (192 & 193):
IMPORTANT:
Build All Target Files

Also, make sure you build the entire project. You should see
Build Time Elapsed to ensure the project was properly built
(see next slide):

assembling startup_stm32f401xe.s...compiling
system_stm32f4xx.c...linking...Program Size: Code=300 RO-
data=404 RW-data=0 ZI-data=1536 ".\Objects\workingProject.axf"
- 0 Error(s), 0 Warning(s).Build Time Elapsed: 00:00:01- 0 \
Modify the program….
1. Change the delay value and see how the blinking LED changes
2. In Keil, which the program is running, click on System View button
and see how the registers change
3. Change the program such that the LED ON time is much shorter
than the OFF time – in this case we are creating different delays for
__ON and __OFF
Programming GPIO Ports in STM32F411xC/E
• Table 1 gives the boundary
addresses of the peripherals
• See Section 2.3 of the
Reference Manual

Click on the Reference


Manual to go to the
appropriate page
Offset:
0x4002 0000 + 0x08 = GPIOA_OSPEEDER
More Examples
RCC_AHB1ENR EQU 0x40023830
GPIOA_MODER EQU 0x40020000
GPIOA_ODR EQU 0x40020014
Configure the GPIOA
STEP 1: Setting up the GPIOx (A-H)
• The STM32F401RETx microcontroller on the Nucleo board has several general purpose input/output (GPIO) ports named Port A, B,
and C. Each port can have up to 16 pins, and each port has associated with it the following set of registers:
• GPIO port mode register (GPIOx_MODER) – port mode (In/Out/Analog In)
• GPIO port output type register (GPIOx_OTYPER)
• GPIO port output speed register (GPIOx_OSPEEDR)
• GPIO port pull-up/pull-down register (GPIOx_PUPDR)
• GPIO port input data register (GPIOx _IDR) – In INPUT then what is INPUT state?
• GPIO port output data register (GPIOx_ODR) – If OUTPUT what is the port OUTPUT state (H/L)
• GPIO port bit set/reset register (GPIOx _BSRR)
• GPIO port configuration lock register (GPIOx_LCKR)
See Reference Manual
• GPIO alternate function low register (GPI Ox_AFRL)
Section 8.4 GPIO registers
• GPIO alternate function high register (GPIOx_AFRH)
• GPIO Port bit reset register (GPIOx_BRR)

where the 'x' in each register name acronym represents the port i.e. the GPIOx_MODER associated with port A is called
GPIOA_MODER.
16 PINS on the PORTS 15 3 2 1 0

GPIO register See Table 26

map and reset values


(Reference Manual)
•'00'-> input mode, which allows the GPIO pin to be
used as an input pin,
•'01'-> Output mode, which allows the GPIO pin to be
used as an output pin,
•'11'-> Analog mode, which allows the GPIO pin to be
used as an Analog input pin and finally,
•'10'-> Alternate function mode which allow the GPIO
pins to be used by peripherals such as the UART, SPI
e.t.c. It is important to note that if a pin's MODE is set
to alternate function, any GPIO settings for that pin
in the GPIO registers will be overridden by the
peripheral.
16 PINS on the PORTS 15 3 2 1 0

GPIO register See Table 26

map and reset values


(Reference Manual)
•'00'-> input mode, which allows the GPIO pin to be
used as an input pin,
•'01'-> Output mode, which allows the GPIO pin to be
used as an output pin,
•'11'-> Analog mode, which allows the GPIO pin to be
used as an Analog input pin and finally,
•'10'-> Alternate function mode which allow the GPIO
pins to be used by peripherals such as the UART, SPI
e.t.c. It is important to note that if a pin's MODE is set
to alternate function, any GPIO settings for that pin
in the GPIO registers will be overridden by the
peripheral.
;; Set GPIOA PA05 to be an OUTPUT
LDR r5, = GPIOA_MODER
LDR r6, [r5]
ORR r6, #0x400 ; 0000 0000 0000 0000 0000 0100 0000 0000
STR r6, [r5] ; 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16 PINS on the PORTS 15 3 2 1 0

GPIO register See Table 26

map and reset values


(Reference Manual)
•'00'-> input mode, which allows the GPIO pin to be
used as an input pin,
•'01'-> Output mode, which allows the GPIO pin to be
used as an output pin,
•'11'-> Analog mode, which allows the GPIO pin to be
used as an Analog input pin and finally,
•'10'-> Alternate function mode which allow the GPIO
pins to be used by peripherals such as the UART, SPI
e.t.c. It is important to note that if a pin's MODE is set
to alternate function, any GPIO settings for that pin
in the GPIO registers will be overridden by the
peripheral.

; 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16 PINS on the PORTS 15 3 2 1 0

GPIO register See Table 26

map and reset values


(Reference Manual)

PC13

PA5
Configure the GPIOA
STEP 2: Clock Setting
for GPIOx
• RCC AHB1
peripheral clock Bit 0 GPIOAEN: IO port A clock enable
enable register Set and cleared by software.
0: IO port A clock disabled
(RCC_AHB1ENR) 1: IO port A clock enabled

• Section 6.3.9
RCC_AHB1ENR
Configure the GPIOA
STEP 2: Clock Setting for GPIOx
• RCC AHB1 peripheral clock enable register (RCC_AHB1ENR)
• Section 6.3.9 Bit 0 GPIOAEN: IO port A clock enable
Set and cleared by software.
• Loading 0000 0000 0000 0001 0: IO port A clock disabled
1: IO port A clock enabled

RCC_AHB1ENR
Answer the following questions:
You need to use the reference manual.

1. What is the address of GPIOB_OTYPER?


2. What is the address of RCC_AHB1ENR?
3. If the value of register 0x4002 0414 is 0x2 what does it mean?
4. Referring to Figure 16, what does 5V tolerant mean?
5. Referring to Table 23, if PUPDR & MODER are both set to 11, what is
the I/O configuration?
6. Referring to Table 23, what are PP and PU?
Looking At The Peripherals
References
• The Definitive Guide to ARM® Cortex®-M3 and Cortex®-M4
Processors – Chapter 15
If You Experience Any Issues….
If You Get Compiling
Errors
• At tis point your Project window should show the [2]
CMSIS and DEVICE – these are the CMSIS system
initialization files and startup files in order for the [3]
[4]
RUN TIME to operate [1]
• Click on the OPTIONS FOR TARGET [2] [1]
• Click on DEBUG tab [3]
• CHECK the SIMULATOR [4]
• Click on OK
• In the PROJECT window click on Source Group 1 and
select ADD NEW ITEM….
• In the new window select
If Devices Are Marked as X
Re-do this section
AFX Error:
Missing afx file
• Make sure you do not have
multiple projects in the same
directory
*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'assembling
Brach_Part_2.s...Brach_Part_2.s(79): warning: A1447W: Missing END directive at end of file, but
found a label named END"Brach_Part_2.s" - 0 Error(s), 1 Warning(s).Error: Could not load file
'C:\Users\es\Desktop\EE310-2017\ARM Version\Keil_Projects\myNewProject\Objects\NewProject.axf'.
Debugger aborted !

• Also, make sure you build the


entire project. You should see *** Using Compiler 'V5.06 update 5 (build 528)', folder:
'C:\Keil_v5\ARM\ARMCC\Bin'Rebuild target 'Target 1'assembling
Build Time Elapsed to ensure the startup_stm32f401xe.s...assembling led2.s...compiling
project was properly built (see system_stm32f4xx.c...linking...Program Size: Code=300 RO-
next slide): data=404 RW-data=0 ZI-data=1536 ".\Objects\workingProject.axf"
- 0 Error(s), 0 Warning(s).Build Time Elapsed: 00:00:02
Build All Target Files

Also, make sure you build the entire project. You should see
Build Time Elapsed to ensure the project was properly built
(see next slide):

*** Using Compiler 'V5.06 update 5 (build 528)', folder:


'C:\Keil_v5\ARM\ARMCC\Bin'Rebuild target 'Target 1'assembling
startup_stm32f401xe.s...assembling led2.s...compiling
system_stm32f4xx.c...linking...Program Size: Code=300 RO-
data=404 RW-data=0 ZI-data=1536 ".\Objects\workingProject.axf"
- 0 Error(s), 0 Warning(s).Build Time Elapsed: 00:00:02

You might also like