2023-09-22 18:08:23 +08:00
|
|
|
|
# Microchip BSP
|
|
|
|
|
|
|
|
|
|
## 1. Microchip BSP Introduction
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|
Supported Microchip SAM (ARM Cortex-Mx Core) MCU is as following:
|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
### ARM Cortex-M23 Series
|
|
|
|
|
|
2022-04-27 09:24:56 +08:00
|
|
|
|
- saml10 | 3.3V Cortex-M23 with ultra low power
|
|
|
|
|
- saml11 | 3.3V Cortex-M23 with ultra low power and trust-zone
|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
### ARM Cortex-M0+ Series
|
|
|
|
|
|
2022-04-14 10:54:53 +08:00
|
|
|
|
- samc21 | 5V Cortex-M0+ with 2 CAN-FD support
|
|
|
|
|
- saml21 | 3.3V low power Cortex-M0+
|
|
|
|
|
- samd21 | 3.3V industrial level Cortex-M0+
|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
### ARM Cortex-M4 Series
|
|
|
|
|
|
2022-04-14 10:54:53 +08:00
|
|
|
|
- same54 | 3.3V 120MHz Cortex-M4F core with CAN-FD/USB/Ethernet support
|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
### ARM Cortex-M7 Series
|
|
|
|
|
|
2022-04-14 10:54:53 +08:00
|
|
|
|
- same70 | 3.3V 300MHz Cortex-M7 core with CAN-FD/High speed USB/Ethernet support
|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
### Directory description:
|
|
|
|
|
|
2022-04-14 10:54:53 +08:00
|
|
|
|
* applications:
|
|
|
|
|
* user main function entrance,
|
|
|
|
|
* driver example - like i2c, can, adc ...
|
|
|
|
|
* application example
|
|
|
|
|
* board:
|
|
|
|
|
* user board initialization
|
|
|
|
|
* user driver adpater code, like console device, ethernet device
|
|
|
|
|
* bsp:
|
|
|
|
|
* MCU BSP files - startup file, peripheral drivers, configuation headers and linker script
|
|
|
|
|
* generated from start.atmel.com - DO NOT modify it
|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
## 2. RT-Thread porting guide of Microchip SAM MCU
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
### 2.1 Configure project BSP on Atmel Start
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Visit <https://start.atmel.com/#> and click CREATE NEW PROJECT.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Input MCU part number and then select device, click CREATE NEW PROJECT.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Add STDIO and other driver/middleware to project.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Configure STDIO driver.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Configure CAN module clock.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Configure CAN module driver.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Add LED pin description.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Rename project.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Save project configuration.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Export project source code.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
### 2.2 Add project to RT-Thread source code
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Link: <https://github.com/RT-Thread/rt-thread> and download RT souce code.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Unzip downloaded RT-Thread and SAME70 CAN Example
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Enter *rt-thread-xxx/bsp/microchip* directory and copy **same70** folder and rename it to **same70q20**.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Enter same70q20 directory and remove all files except SConscript file.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Copy all files from SAME70 CAN Example to rt-thread-xxx/bsp/microchip/same70q20/bsp.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Modify rt-thread-xxx\bsp\microchip\same70q20\rtconfig.py.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Modify rt-thread-xxx\bsp\microchip\same70q20\bsp\SConscript.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Modify rt-thread-xxx\bsp\microchip\same70q20\bsp\same70b\gcc\gcc\same70q20b_flash.ld.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Modify rt-thread-xxx\bsp\microchip\same70q20\bsp\same70b\gcc\gcc\startup_same70q20b.c.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Alright, now you can use RT-Thread env tools to compile the project.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
### 2.3 Compile project with RT-Thread env tools
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|
About RT-Thread env tools, click [Here](https://github.com/RT-Thread/rt-thread/blob/master/documentation/env/env.md).
|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Download RT-Thread env tools <https://www.rt-thread.org/download.html#download-rt-thread-env-tool>
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Unzip downloaded file and run env.exe.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Enter your project directory and run scons command to compile it.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Compile error you may have and proposed solution.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Fix compiling error
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Compiling success
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
In the following chapter I will show you how to debug RT-Thread with Studio 7.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
## 3. RT-Thread debugging with Microchip IDE
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Link: <https://www.microchip.com/en-us/tools-resources/develop/microchip-studio>, download & install Microchip Studio 7.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Open installed Microchip Studio 7 and open object file for debugging.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Choose object file, fill project name and select where to save this project.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Select the right part number and complete object set up.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Object file import complete and you can see related files are linked to project.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Right click the project and choose the debug tools in project propertities setting.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Choose debugger/programmer and debugger interface - SWD or JTGA.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Press debugging button and enjoy your debugging journey.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Debugging start and you can add breakpoint.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Debugging paused at breakpoint and you can monitor local variables at Watch window.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Debugging message output.
|
2022-04-19 14:32:02 +08:00
|
|
|
|
|
|
|
|
|

|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
## 4. Reconfigure MCU BSP
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Visit <https://start.atmel.com/#> and upload project configuration.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Now you can reconfigure your project.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
## 5. Microchip SAM MCU BSP configuration and user guide
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
Please refer to [ASF4 API Reference Manual](https://ww1.microchip.com/downloads/en/DeviceDoc/50002633B.pdf) for more details
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
### 5.1 SAMC2x/E5x/E70 CAN Driver
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
CAN driver configuration.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
CAN driver user guide - see [ASF4 API Reference Manual](https://ww1.microchip.com/downloads/en/DeviceDoc/50002633B.pdf) P121 for more details.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
To be continued.
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
## 6. Contact Info
|
2022-04-14 10:54:53 +08:00
|
|
|
|
|
2023-09-22 18:08:23 +08:00
|
|
|
|
- [Kevin Liu](https://github.com/klmchp), email: <kevin.liu.mchp@gmail.com>
|
|
|
|
|
- [luhuadong](https://github.com/luhuadong), email: <luhuadong@163.com>
|