PEmicro logo
Cart New Account Login

Logo image
HomeAbout usProductsSupportForumsBlogCustomer Service

by Johnny Ng

PEmicro supports external flash connected to an MCU via the SPI and Address/Data bus interfaces. When performing this type of programming, the algorithm needs to be set up specifically for our programmers to be able to communicate with the flash via the MCU. What must be configured depends on which external bus interface has been chosen for the connection. When using the Address/Data bus, the user will need to configure the external address, data, and bus control pins of the MCU. In the case of the SPI bus, the user will need to configure GPIO pins connected to the external SPI device properly. The modifications are made in the header of the algorithm file. PEmicro's PROGACMP software, as of version 8.84, has an SPI Diagnostic mode that provides the user with a new method to easily test the GPIO configuration in order to help troubleshoot programming issues.

Figure 1. External SPI Flash Connections

A standard SPI flash memory algorithm from PEmicro use any four GPIO pins for bit banging the SPI pins which are: 

1) /CS or /SS

2) /CLK

3) /MISO or /DO

4) /MOSI or /DI

The benefit of utilizing bit banging is that the algorithm can be modified to use any port on the microcontroller and not just the port specifically mapped to the SPI peripherals. The algorithm must be configured to turn on any necessary power and clocks to the port being used. In addition, the SPI pins need to be configured through the "PARAMx" parameters. Refer to the SPI algorithm user guide for more details and examples.

What if the SPI flash doesn't program or read properly during a flash programming session? It is likely a configuration issue. PEmicro's interactive PROG flash programming software has an "SPI Diagnostics" mode to help troubleshoot this scenario. This is useful if the user is able to load the SPI flash algorithm but not view the contents of Flash, program it, or erase it. The SPI Diagnostic mode can verify that the algorithm has control of each of the port pins being used.

The SPI Diagnostic mode should be used in conjunction with an oscilloscope or logic probe so that each port pin can be checked for the proper state.  The SPI Diagnostic Mode provides the capability to toggle each of the output pins that control /CS, /CLK. and /MOSI. It can also show the port value and pin values that are read back from the MCU.

The SPI Diagnostic mode is accessed through the tool bar from the Diagnostics option within the interactive PROGACMP flash programming software. If the option is not visible, then your software requires an update. Please contact us at technical-info (at) for further assistance.

Figure 2: Select Diagnostics Mode From Toolbar

The user can toggle /CLK, /SS, and /MOSI in the SPI Diagnostic mode window and verify the state of the signal on the oscilloscope. If the pin value is "1", the signal should be high. If the pin value is "0", the signal should be low. Other information that is reported includes the value of the port, the address configured in PARAM, and the port bit number configured. 

Figure 3: SPI Diagnostic Tool

If the SPI control pin does not toggle, then there is a problem with the configuration of your GPIO register settings for the specific GPIO controlling it. 

If you have any questions or comments about the SPI Diagnostic mode, please email us at

New or custom SPI flash algorithms may be requested on the PEmicro Flash Programming Algorithms page.

search in blog posts


Product pages
Cyclone (109)
Cyclone FX (114)
Multilink (73)
Multilink FX (66)
GDB Server (35)
Prog ACMP (37)
Interface Library Routines (7)

ARM (94)
NXP (92)
Microchip (7)
Cypress (7)
Infineon (7)
Maxim (3)
Nordic Semiconductor (3)
Silicon Labs (6)
Silergy Teridian (1)
STMicroelectronics (12)
Texas Instruments (2)
Toshiba (3)
Renesas (15)

Production Programming (114)
Debug (70)
Automated Control (31)
Miscellaneous (40)

© 2022 P&E Microcomputer Systems Inc.
Website Terms of Use and Sales Agreement