Unconsciously, the lack of chip has lasted for a long time, chip prices are soaring, and all kinds of M4, M7 series development board prices are also rising. As a DIYer, I don't know how much inventory you still have, but my "small chip library" has almost nothing left. The luxury of using one or even several MCU on an application scheme or development board has gone forever, but the idea of using domestic high-quality chips as "core module board" has also emerged.
Just got a few Geehy APM32F407ZGT6 samples applied not long ago, so I planned to try to use the samples in order that I could make a Raspberry PI Compute Module based on APM32F407.
MCS Compute Module 1 (hereinafter referred to as CM1) is a computing module that uses ARM Cortex-M4 32-bit microcontroller as the core and has onboard WIFI & BLE 5.0 and Ethernet interface. At the same time, most of the core functions of 407 peripherals are retained by using B2B interface to
## Core configuration
• Geehy APM32F407ZGT6 168MHz 32-bit ARM Cortex-M4 CPU
• Internal 192KB + external 2MB SRAM
• 1MB Flash storage
• 100 MBPS Ethernet PHY supports IEEE 802.3
• Supports 2.4GHz Wi-Fi and Bluetooth 5.0(LE)
• Supports USB 2.0
• Support SWD interface to download APM32F407 program
• Supports USB-JTAG to download ESP32 C3 programs
## B2B interface
The B2B interface is designed to be unified to ensure that subsequent designs such as CM2, 3, and 4 can be used on different extension boards.
High speed
Low speed
LED8080 interface ×1
GPIO×10
DCMI-14bit interface×1
UART×2
Ethernet interface×1
I2S×1
OTG_HS interface×1
CAN×2
OTG_FS interface×1
I2C×1
SPI×1
TIMER channeI×10
TIMER complementary channel group×1
SDIO-8bit interface×1
DAC channel×1
ADC channel×1
03 Hardware Design## Schematic diagram
Module each part of the schematic connection diagram.
## PCB
You can draw PCB diagram, which estimates better wiring with BGA package. I advise that the authority produces some different packages of chips, to meet the needs of different application scenarios.
When the board is done, it is found that RT-Thread 4.1 version already supports the development of APM32F407 series, so I directly use the operating system of RT-Thread Studio to light up.
Install the SDK
Because it is a self-designed development board, chip support package will be used to develop it.
## Install JLINK support
JLINK v7.8 and above versions have supported all of the APM32 series, If you do not want to download simulation which need to choose more options,you can install the latest version.
## Create project
CM1 uses APM32F407ZGT6, so the chip model here is also APM32F407ZGT6, and RT-Thread is version 4.1.0.
## Write code
### applications
Add LED flash and print the code of "Hello RT-Thread!" in main.c file.
### Configuration crystal oscillator
You should notice that system_apm32f4xx.c uses an external crystal oscillator by default and is configured at 8MHz. Since CM1 uses a 25MHz external crystal oscillator, the corresponding value needs to be modified.
### Download and debug
After compiling and downloading, start the serial terminal of RT-Thread Studio. And you can see the string printed by the serial port.
Finish lighting up.
Finish lighting up.
To cloudify the device, you definitely need networking media, which uses the onboard ESP32 C3 WROOM module and writes in the official ESP AT firmware.
## Configure ESP32 C3
The official ESP AT firmware can be obtained from gitee:
https://gitee.com/EspressifSystems/esp-at
The AT firmware uses ESP32 C3 UART1 for AT instruction communication by default. However, the CM1 adopts the communication mode APM32F407 USART3 and ESP32 C3 WROOM UART0. Therefore, you need to modify the official firmware configuration.
Change the default UART port to UART0.
The configuration does not output log information from UART0, then recompile and download it to ESP32 C3.
Finally, text an "AT" character from the debug serial port reserved for ESP32 C3 WROOM. If the debug serial port has responds, it will be successful. You can check the official manual for specific AT instructions supported.
## AT Device software package
The next step is to control the networking of the ESP32 C3 WROOM using APM32F407. Instead of making the wheel again, use the AT Device package directly on RT-Thread Studio (thanks to the RT-Thread team).
### Add software package
Open RT-Thread Settings and add the software package AT Device.
###Configure the software package
Configure the at device software package and UART device driver component, and save the configuration file. The WIFI and serial port information should be configured according to the situation of your device.
### Modify the official code
The official code is not very perfect, so you need to add your own UART3 configuration for passthrough.
### Compile and download
After compiling and re-downloading, you can see that the communication At device is successful.
## OneNet platform creates MQTT products and devices
The cloud platform used is still the familiar OneNet platform. There are many articles on the operation of OneNet platform. You can refer to the official documents.
https://open.iot.10086.cn/doc/multiprotocol/book/get-start/product&device/product-create.html
What you should note here is that the MQTT product was created using the older version of Multi-Protocol Access. Don't ask why you can not use the new version, and you can rush the RT-Thread team into upgrading article. After the device is created, record the device ID, authentication information, API Key, product ID, and API Key etc.
## OneNet software package
This package only supports older versions of the oneNet platform for multi-protocol access (rush RT-Thread team again).
### Add software package
###Configure the software package
Configure the onenet software package and fill in the corresponding information recorded which is about creating the product and device.
###Write the OneNet application API
After the configuration is finished, the cJSON WebClient software package is also referenced. At that time, you can test this with the onenet_sample code. However, since the official Demo is not perfect, you can rewrite it yourself according to the official Demo. The msh command of bsp_onenet file is defined as follows.
###Initialize the MQTT Server
###Publish data
###Acquire data
### OneNet platform
You can see that the Template value on the onenet platform changes to 24. You can also upload and read bin files for OTA and read pictures for image transmission and display.
Next, I would prepare to do a CM1 based IOT expansion board, motor expansion board, touch-screen small terminal, various application routines and so on. It can give full play to the performance of the DIY of APM32F407 chip, and interested partners can wait for next article.
Comments
Please log in or sign up to comment.