Difference between revisions of "MK22 Core:Project Transplanting Note"
From Microduino Wiki
(→Notes of Transplanting Codes from Arduino to Mbed) |
(→Outline) |
||
Line 1: | Line 1: | ||
==Outline== | ==Outline== | ||
− | *'''[[Microduino-Core MK22]]''' is a M4 framework | + | *'''[[Microduino-Module Core MK22]]''' is a M4 framework core based on the MK22FN512VLH12 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]]'''. | *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. The self-balance robot has the currency of standing up, but it can’t really stand up yet. | + | *Except the self-balance robot, the other 3 can all work on MK22. The self-balance robot has the currency of standing up, but it can’t really stand up yet. |
==Steps of Development== | ==Steps of Development== |
Revision as of 03:48, 26 July 2016
Contents
Outline
- Microduino-Module Core MK22 is a M4 framework core based on the MK22FN512VLH12 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 MK22. 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 registering, go back 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 bin file after the success of compiling and linking.
- 4、Download JFlash:https://www.segger.com/jflash.html
- 5、Use JFlash to download bin to MK22 to run it.
Program Code
- Cube robot:Open Source Electric Drive Cube Robot
https://developer.mbed.org/users/beian10/code/CubeFine/
- 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.
Notes:
- The entrancy of Arduino is the setup and loop function in .ino file, and the entrance of mbed is the main function in main.cpp. While(true) can be sued 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 sued 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:lixianyu@toweer.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_Freescale\TARGET_KSDK2_MCUS\TARGET_K22F\TARGET_FRDM, the PinNames.h file has the definition of all pins of MK22.
- mbed has realizes the TARGET MK22.
- Enter the directory of TARGET_Freescale, you can see mbed has realized the following specific MCU:
- MCU not listed can’t use mbed platform now.