When you download and program the discovery kit,
you might get the following errors:
No ST-Link detected,
Target not found,
Flash download failed,
ST-Link connection error,
and No target connected.
The short video shows you how to solve these errors.
First, let's check whether the ST-Link is recognized by Windows.
Go the device manager,
check whether ST-Link is listed as a USB device.
If not, re-install the ST-Link USB device driver.
To install or re-install the device driver,
go to the USB driver folder
and run the installation file
Next, check the jumpers on the discovery kit and
make sure that the following jumpers are
set correctly: CN3, JP3, JP5 and JP6.
The two jumpers on CN3 should be plugged in.
When both jumpers are in place,
ST-LINK is enabled to program
the on-board STM32L4 processor.
This is marked as DISCOVERY on the board.
When both jumpers are taken off,
ST-Link can be used to program
an external board via the CN4 connector.
This is marked as ST-LINK on the board.
The jumper JP3 has only one position.
Normally, jumper JP3 should not be taken off.
This is to ensure that the ST-LINK is connected to
the NRST pin of the STM32L4.
The jumper JP5 is labeled as Idd
and it has two positions: ON and OFF.
If the jumper is on position OFF,
the STM32L4 chip is powered directly by the USB.
If it is placed at position ON,
a module on board can be used to measure
the electrical current
consumed by the STM32L4 chip.
The jumper JP5 should be either ON or OFF.
It cannot be taken off.
The jumper JP6 has two positions: 3V3 and battery.
If we want to power the processor by a CR2032 battery,
which is inserted in CR1 on the bottom
side of the discovery board,
the jumper JP6 should be placed in the position battery.
Otherwise, the jumper JP6 should be placed in the position 3V3.
In summary,
ensure that jumpers CN3, JP3, JP5 and JP6 are set to
DISCOVERY, RST, ON and 3V3, respectively.
Next, we will erase the internal flash of the STM32L4 processor.
Run the application called STM32 ST-Link Utility,
click the menu "Target",
"Settings".
Select "Connect Under Set" as the connection mode.
Click "Target",
"Connect"
and then "Target",
"Erase Chip".
Make sure to disconnect.
Click "Target",
"Disconnect".
If it is not disconnected,
Keil cannot program the discovery kit.
Next, we will check the debug settings.
Click the icon "Options for Targets",
go to the Debug page,
make sure "ST-Link debugger" is selected.
Click "Settings"
In the Port, select Serial Wire (SW), instead of JTAG.
Change the connect from "normal" to "with pre-reset".
This is very important when you program your board for the very first time.
You might get an error of "Target not found",
when you download the code to the board at
the first time.
This is because the pre-installed demo program
quickly puts the microprocessor into a low
power mode immediately after a reset.
Program and debug with the pre-reset
will solve this error.
Next, go to the "Flash Download" page.
Make sure "STM32L4xx 1MB Flash" is present.
If not, click add
add it.
Click OK to save the changes.
Last, check your program code.
You program cannot modify the settings of
GPIO pin PA 13 and PA 14.
On STM32L4, these two pins are used to
program and debug.
Specifically, the alternate function of PA 13 and PA 14 should be
ST-Link SWDIO and SWCLK, respectively.
If your code accidently changes the mode or the alternate function of these two pins,
you won't be able to program the board
after you download the code to the board.
The solution is: First, use ST-Link Utility
to erase the flash chip, as shown previously.
Then, fix your program code.
Please visit the book website for
tutorials and project templates