SPI Peripheral

The MCU bootloader supports loading data into flash via the SPI peripheral, where the SPI peripheral serves as a SPI slave.

The maximum supported baud rate of the SPI depends on the clock configuration fields in the Bootloader Configuration Area (BCA). The typical baud rate is 400 kbit/s with the factory settings. The actual baud rate is lower or higher than 400 kbit/s, depending on the actual value of the clockFlags and clockDivider fields in the BCA.

Because the SPI peripheral serves as a SPI slave device, each transfer should be started by the host, and each outgoing packet should be fetched by the host.

The transfer on SPI is slightly different from I2C:

  • Host receives 1 byte after it sends out any byte.

  • Received bytes should be ignored when host is sending out bytes to target

  • Host starts reading bytes by sending 0x00s to target

  • The byte 0x00 is sent as response to host if target is under the following conditions:

    • Processing incoming packet

    • Preparing outgoing data

    • Received invalid data

The following flowcharts show how the host reads a ping response, an ACK and a command response from target via SPI.

Host reads ping packet from target via SPI

Host reads ACK from target via SPI

Host reads response from target via SPI

Performance Numbers for SPI

The table below provides reference to the expected performance of write speeds to Flash and RAM memories using the MCU bootloader SPI interface. The numbers were measured on a number of platforms running the MCU bootloader from either the ROM or the RAM (for flashloaders).

Performance numbers SPI

SPI Bus Freque ncy (KHz)

Flash Average Writing Speed (KB/s)

Ram Average Writing Speed (KB/s)

KL27

KL28

KL43

KL80

K80

KL03

KL27

KL28

KL43

KL80

K80

KL03

100

7.07

7.46

7.24

6.74

6.71

6.20

8.60

9.25

9.01

8.46

8.04

6.80

200

11.45

12.26

11.88

11.53

10.18

8.87

15.23

17.98

17.04

16.17

14.19

10.64

300

13.84

15.17

14.70

15.08

12.42

-

19.91

25.11

23.06

24.65

18.79

-

400

16.42

18.09

17.23

16.91

13.74

-

25.89

32.95

31.15

28.89

23.95

-

500

18.26

19.82

18.17

18.94

14.98

-

31.47

40.10

36.61

36.61

27.83

-

600

18.72

20.72

19.98

20.63

15.21

-

32.40

44.98

40.96

42.26

27.67

-

800

21.19

22.06

22.27

22.04

16.11

-

39.83

50.00

51.54

49.98

30.15

-

1000

22.07

23.74

23.80

22.92

15.99

-

45.83

61.19

55.92

56.34

29.11

-

Default core Freque ncy (MHz)

48

48

48

48

48

8

48

48

48

48

48

8

Default bus Freque ncy (MHz)

24

24

24

24

24

4

24

24

24

24

24

4

Note:

  1. Every test covers all flash or RAM regions with 0x0 - 0xf.

  2. Run every test three times and calculate the average.

Flash Average Writing Speed

RAM Average Writing Speed

Parent topic:SPI Peripheral

Parent topic:Supported peripherals