README.md
1# Microchip BSP
2
3## 1. Microchip BSP Introduction
4
5Supported Microchip SAM (ARM Cortex-Mx Core) MCU is as following:
6
7### ARM Cortex-M23 Series
8
9- saml10 | 3.3V Cortex-M23 with ultra low power
10- saml11 | 3.3V Cortex-M23 with ultra low power and trust-zone
11
12### ARM Cortex-M0+ Series
13
14- samc21 | 5V Cortex-M0+ with 2 CAN-FD support
15- saml21 | 3.3V low power Cortex-M0+
16- samd21 | 3.3V industrial level Cortex-M0+
17
18### ARM Cortex-M4 Series
19
20- same54 | 3.3V 120MHz Cortex-M4F core with CAN-FD/USB/Ethernet support
21
22### ARM Cortex-M7 Series
23
24- same70 | 3.3V 300MHz Cortex-M7 core with CAN-FD/High speed USB/Ethernet support
25
26### Directory description:
27
28 * applications:
29 * user main function entrance,
30 * driver example - like i2c, can, adc ...
31 * application example
32 * board:
33 * user board initialization
34 * user driver adpater code, like console device, ethernet device
35 * bsp:
36 * MCU BSP files - startup file, peripheral drivers, configuation headers and linker script
37 * generated from start.atmel.com - DO NOT modify it
38
39## 2. RT-Thread porting guide of Microchip SAM MCU
40
41### 2.1 Configure project BSP on Atmel Start
42
43Visit <https://start.atmel.com/#> and click CREATE NEW PROJECT.
44
45
46
47Input MCU part number and then select device, click CREATE NEW PROJECT.
48
49
50
51Add STDIO and other driver/middleware to project.
52
53
54
55Configure STDIO driver.
56
57
58
59Configure CAN module clock.
60
61
62
63Configure CAN module driver.
64
65
66
67
68
69Add LED pin description.
70
71
72
73Rename project.
74
75
76
77Save project configuration.
78
79
80
81Export project source code.
82
83
84
85### 2.2 Add project to RT-Thread source code
86
87Link: <https://github.com/RT-Thread/rt-thread> and download RT souce code.
88
89
90
91Unzip downloaded RT-Thread and SAME70 CAN Example
92
93
94
95Enter *rt-thread-xxx/bsp/microchip* directory and copy **same70** folder and rename it to **same70q20**.
96
97
98
99Enter same70q20 directory and remove all files except SConscript file.
100
101
102
103Copy all files from SAME70 CAN Example to rt-thread-xxx/bsp/microchip/same70q20/bsp.
104
105
106
107Modify rt-thread-xxx\bsp\microchip\same70q20\rtconfig.py.
108
109
110
111Modify rt-thread-xxx\bsp\microchip\same70q20\bsp\SConscript.
112
113
114
115Modify rt-thread-xxx\bsp\microchip\same70q20\bsp\same70b\gcc\gcc\same70q20b_flash.ld.
116
117
118
119Modify rt-thread-xxx\bsp\microchip\same70q20\bsp\same70b\gcc\gcc\startup_same70q20b.c.
120
121
122
123Alright, now you can use RT-Thread env tools to compile the project.
124
125### 2.3 Compile project with RT-Thread env tools
126
127About RT-Thread env tools, click [Here](https://github.com/RT-Thread/rt-thread/blob/master/documentation/env/env.md).
128
129Download RT-Thread env tools <https://www.rt-thread.org/download.html#download-rt-thread-env-tool>
130
131
132
133Unzip downloaded file and run env.exe.
134
135
136
137Enter your project directory and run scons command to compile it.
138
139
140
141Compile error you may have and proposed solution.
142
143
144
145Fix compiling error
146
147
148
149Compiling success
150
151
152
153In the following chapter I will show you how to debug RT-Thread with Studio 7.
154
155## 3. RT-Thread debugging with Microchip IDE
156
157Link: <https://www.microchip.com/en-us/tools-resources/develop/microchip-studio>, download & install Microchip Studio 7.
158
159
160
161Open installed Microchip Studio 7 and open object file for debugging.
162
163
164
165Choose object file, fill project name and select where to save this project.
166
167
168
169Select the right part number and complete object set up.
170
171
172
173Object file import complete and you can see related files are linked to project.
174
175
176
177Right click the project and choose the debug tools in project propertities setting.
178
179
180
181Choose debugger/programmer and debugger interface - SWD or JTGA.
182
183
184
185Press debugging button and enjoy your debugging journey.
186
187
188
189Debugging start and you can add breakpoint.
190
191
192
193Debugging paused at breakpoint and you can monitor local variables at Watch window.
194
195
196
197Debugging message output.
198
199
200
201## 4. Reconfigure MCU BSP
202
203Visit <https://start.atmel.com/#> and upload project configuration.
204
205
206
207Now you can reconfigure your project.
208
209
210
211
212## 5. Microchip SAM MCU BSP configuration and user guide
213
214Please refer to [ASF4 API Reference Manual](https://ww1.microchip.com/downloads/en/DeviceDoc/50002633B.pdf) for more details
215
216### 5.1 SAMC2x/E5x/E70 CAN Driver
217
218CAN driver configuration.
219
220
221
222
223CAN driver user guide - see [ASF4 API Reference Manual](https://ww1.microchip.com/downloads/en/DeviceDoc/50002633B.pdf) P121 for more details.
224
225To be continued.
226
227## 6. Contact Info
228
229- [Kevin Liu](https://github.com/klmchp), email: <kevin.liu.mchp@gmail.com>
230- [luhuadong](https://github.com/luhuadong), email: <luhuadong@163.com>
231