LPC Core：Project Transplanting Note
From Microduino Wiki
- Microduino-Module Core LPC is a M0 framework Core based on the LPC824M201JHI33 of NXP. This article realizes some application development transplantation work based on mbed.
- This article is realized on the basis of transplanting Open Source Electric Drive Cube Robot, Open Source LED Dot Matrix Screen, Open Source Self-balance Robot System and Open Source WiFi Weather Station System.
- Except the self-balance robot, the other 3 can all work on LPC824. The self-balance robot has the currency of standing up, but it can't really stand up yet.
Steps of Development
- 1. Enter mbed Mainpage, and register.
- 2. After the registration, return to Mainpage, and click the "Compiler" on the top right corner, to enter the online compiling mode.
- 3. After compiling, clicking "Compile" can automatically download the file bin after the success of compiling and linking.
- 4. Download JFlash: https://www.segger.com/jflash.html
- 5. Download bin to LPC824 through JFlash to run it.
- Cube robot: Open Source Electric Drive Cube Robot
- Dot matrix screen: Open Source LED Dot Matrix Screen
- Balance robot: Open Source Self-balance Robot System
- WIFI weather station: Open Source WiFi Weather Station System
Notes of Transplanting Codes from Arduino to Mbed
- Study guide about mbed won't be said here any more, because there are many materials online.
- You can see File:MBed Study Guide.pdf here.
- The entry of Arduino is the setup and loop functions in .ino file, and the entry of mbed is the main function in main.cpp. While(true) can be used to realize the function of function loop in Arduino in main function.
- PinMode in Arduino needs to be changed into the instance of classes such as AnalogIn, AnalogOut, DigitalOut and DigitalIn of mbed.
- In Arduino, analogWrite can be used to realize the output of PWM, and it should be changed into the instance of class PwmOut in mbed. In mbed, the output frequency and width of PWM both can be dynamically set through API.
- In Arduino, class Serial is used to output serial port, and the instance of class Serial should be used to take place of it in mbed
- Function millis and micros in Arduino should be altered into the instance of class Timer in mbed. Besides, in mbed, the effects of class Timeout and Ticker are respectively to realize single operation and timed repeat operation.
- Function pgm_read_byte in Arduino is to read data from flash. And you can directly operate pointer uint8_t in mbed, and don't need single function to read data from flash.
- Wire is be used for the operation of the I2C in Arduino, and it should be taken place by the instance of class I2C in mbed.
- The interval of taking the temperature of AM2321 is must bigger than 2s, or i2c won’t work.
- SimpleTimer has a bug, which will result in a quick calling of two timing function. For example, setInterval(4000, sendCH4), execute function sendCH4 once every 4s, but in the actual runtime, the execution interval of sendCH4 will be less than 4s.
You can sen an email to me if you have any questions: email@example.com, and let us talk about the word of mbed.
- About the definition of pins, you can clone mbed source code to local：https://github.com/mbedmicro/mbed.git
- In the directory hal\targets\hal\TARGET_NXP\TARGET_LPC82X\TARGET_LPC824, the PinNames.h file has the definition of all pins of LPC824.
- mbed has realizes the TARGET LPC824.
- mbed has offered support for the MCU of the following manufacturer:
- Enter the directory of TARGET_NXP, you can see mbed has realized the following specific MCU:
- MCU not listed can't use mbed platform now.