mbed exported Keil MDK failed on cpp initialization

08 Jun 2014

Recently I am working on a product based upon LPC1114 and EPD, check it out.

Basically I used mbed API, SSD driver libraries and I2C NVMEM libraries. I cloned SSD1306 libraries from Jonathon.

Because I want to save time on debugging, I export the code into MDK. I am very surprised the code will never goes to main() if I initialize SSD1306 object.

The disassembly shows it goes through

  • Reset_Handler:
  • main:
  • main_scatterload:
  • main_after_scatterload:
  • main_after_initio:

BL.W _cpp_initialize_aeabi_

Then it never jumps to main(), but stops on certain BKPT 0xAB.

I used eeprom libraries to replace SSD1306 liabries to test cpp initialization routines. It works. However, I have no idea why SSD1306 libraries will have problem.

SPI constructor error?

I prepared my code of SSD1306 on LPC1114, only for exporting and debugging on MDK.

After narrow down the issue, I found SPI constructor has issue. No matter I create an SPI object, or transfer PinName to SSD1306 constructor to create SPI object inside. The problem can be reproduced.

Does SPI PinName has limitations? Such only P5/6/7 or 11/12/13 is allowed. Therefore it limits hardware reuse for alternative functions on other pins?

Please help me if anyone knows the background.

08 Jun 2014

In spi_api.c the pins you're using for clk and mosi aren't accepted.

https://mbed.org/users/mbed_official/code/mbed-src/file/96162ccfbf43/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/spi_api.c

SSD1606 display(P0_6,P0_7,P2_0,P1_10,P1_5,P1_11);
// SSD1606::SSD1606(PinName cs, PinName rst, PinName dc, PinName clk, PinName busy, PinName data)
// clk = P1_10
// mosi = P1_11

09 Jun 2014

Thanks. I found that.

Only hardware supported SPI PinNames are allowed. I should refer to mbed code before put certain PinNames for testing.