Tag Archives: STM32

MPU6050 initialize failure [How to Solve]

1. 6050 initialization failed

If 6050 fails to initialize, first check whether the read address is wrong

res=MPU_Read_Byte(MPU_DEVICE_ID_REG);
	printf("mpu addr=%x\r\n",res);
	if(res==MPU_ADDR)//Device ID is correct
	{
		MPU_Write_Byte(MPU_PWR_MGMT1_REG,0X01); //set CLKSEL,PLL X-axis as reference
		MPU_Write_Byte(MPU_PWR_MGMT2_REG,0X00); //Acceleration and gyroscope both work
		MPU_Set_Rate(50); //Set the sampling rate to 50Hz
 	}
	else return 1;

I read out here is 0x68, different connection will also lead to different ID, if the address is correct, that is return 0, here for the initialization of the 6050 initialized through.

2, mpu initialization failure
Mpu initialization failure is common to return error code 8, you can step by step into the source code to analyze.

Solution I.
mpu_dmp_init() -> run_self_test() Here is the self-test, jump into the function can be seen, meaning that it needs to be placed horizontally in order to self-test successfully, so only the module can be placed horizontally, if not directly mask this part of the code can be.

Solution two.
Trace the source code: mpu_dmp_init() -> run_self_test() -> mpu_run_self_test(gyro, accel) -> accel_self_test(accel, accel_st)

Both the initialization is successful only when the absolute value of st_shift_var < the value of test.max_accel_var. And the absolute value of st_shift_var is different for different positions of MPU6050 modules. Only when the module is placed horizontally, the absolute value of st_shift_var is closest to the value of test.max_accel_var, if this parameter is not modified, the module needs to be placed horizontally according to method 1 for testing

Here you can print out the absolute value of st_shift_var and the value of test.max_accel_var when debugging, my solution here is to change the initialization value of test.max_accel_var from 0.14 to 0.16. Then the module will be initialized successfully when the module is placed horizontally. This is shown in the figure below:

3. Initialization passed, but the data is 0

Another situation is that all initialization passes, but the Euler angle data is all 0. This situation is because there is a hard delay in the code or the processing of other modules affects 6050, so the data is all 0. The personal test is to mask the data processing screen of a module after the test.

[Solved] NO ST-LINK detected/ST-LINK USB communication error

Here is a simple method to solve error: NO ST-LINK detected/ST-LINK USB communication

 

Solution:
① download and install STLINK driver

② update STLINK firmware

③Find stlink_winusb_uninstall.bat in your keil5 installation directory>ARM>STLink>USBDriver directory and click to execute it (i.e. uninstall first), then execute stlink_winusb_install.bat again (i.e. reinstall)

[Solved] Keil5 burn STM32F chip Error: error: Flash download failed – “cortex-m4″“

Load “…\Obj\Laliji.axf”
Set JLink Project File to “F:\01MCU\STM32F429\TestProgram\Project\JLinkSettings.ini”
JLink Info: Device “STM32F429IG” selected.

JLink info:
DLL: V4.98e, compiled May 5 2015 11:00:52
Firmware: J-Link V10 compiled Oct 15 2018 16:40:35
Hardware: V10.10
S/N : 260106173
Feature(s) : FlashBP, GDB, FlashDL, JFlash, RDI
JLink Info: Found SWD-DP with ID 0x2BA01477JLink Info: Found SWD-DP with ID 0x2BA01477JLink Info: Found Cortex-M4 r0p1, Little endian.JLink Info: FPUnit: 6 code (BP) slots and 2 literal slotsJLink Info: CoreSight components:JLink Info: ROMTbl 0 @ E00FF000JLink Info: ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 000BB00C SCSJLink Info: ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 003BB002 DWTJLink Info: ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 002BB003 FPBJLink Info: ROMTbl 0 [3]: FFF01000, CID: B105E00D, PID: 003BB001 ITMJLink Info: ROMTbl 0 [4]: FFF41000, CID: B105900D, PID: 000BB9A1 TPIUJLink Info: ROMTbl 0 [5]: FFF42000, CID: B105900D, PID: 000BB925 ETM
ROMTableAddr = 0xE00FF003

Target info:
Device: STM32F429IG
VTarget = 3.270V
State of Pins:
TCK: 0, TDI: 1, TDO: 1, TMS: 1, TRES: 1, TRST: 1
Hardware-Breakpoints: 6
Software-Breakpoints: 8192
Watchpoints: 4
JTAG speed: 5000 kHz
No Algorithm found for: 08000000H - 08001073H
Erase skipped!
Error: Flash Download failed - “Cortex-M4”
Flash Load finished at 14:46:07

 

Solution:
1, click the magic wand of keil interface (Alt + F7)
2, Settings

3, Flash Download -> add

4, choose the type of chip-> add

[Solved] No corresponding flash error is found during MDK download

1. There is no stmf10x 128K flash model in keilmdk

2. Go to keil’s official website to download the DFP package of the corresponding model

you can download the latest installation package
3. Put the downloaded DFP into the Keil installation directory, (you can leave it alone. The installation path of the pack package is the default and cannot be changed)

4. After installation, you need to put the. FLM file in the downloaded package under this path

5. The. FLM file cannot be found in the downloaded DFP. You need to copy the. FLM file in
G:\keil\arm\pack\keil\stm32f1xx_df\2.4.0\flash

copy the copied file Put the parts into storage
in FLM package
G:\keil\arm\flash

then restart keil OK

[Solved] STM32F4 MDK5 Software Simulate Error: error 65: no ‘read‘ permission

Stm32f4 mdk5 software simulation error: no ‘read’ permission

Problem description

CPU: stm32f407
mdk5 software simulation prompts that you have no read-write permission and can only run step by step. The prompt code is as follows:

*** error 65: access violation at 0x40023800 : no 'read' permission
*** error 65: access violation at 0x40023800 : no 'write' permission
*** error 65: access violation at 0x40023808 : no 'write' permission
*** error 65: access violation at 0x40023800 : no 'read' permission
*** error 65: access violation at 0x40023800 : no 'write' permission

The root cause is: there is a problem with the map address space permission mapping. Some address spaces do not have read and write permissions, resulting in the program can not run automatically.

Solution:

Add map address space permission mapping
according to the introduction of network resources, there are three methods:
1 Modify the debug tab in the project configuration option, and stm32f1 series chip verification can be used normally. F4 series chips cannot be used normally
2. Modify the map address permission mapping directly on the debugging page. After normal modification, the program can run normally. It needs to be reset when exiting debugging, which is inconvenient to operate
3. In the debug tab of the project configuration options, add the correct initialization file directly. (recommended)

Method 3:

Create a new “debug.ini” file in the project file, and add the map address permission mapping code in the file

map 0x40000000, 0x40007FFF read write // APB1
map 0x40010000, 0x400157FF read write // APB2
map 0x40020000, 0x4007FFFF read write // AHB1
map 0x50000000, 0x50060BFF read write // AHB2
map 0x60000000, 0x60000FFF read write // AHB3
map 0xE0000000, 0xE00FFFFF read write // CORTEX-M4 internal peripherals

The specific map address permission mapping can also be viewed in the memory map option in the debugging interface.

Method 2:

On the debug page, select the memory map option under the debug tab, as shown below

Map address mapping can be added according to the error prompt.

Method 1:

Relevant parameters are mainly configured according to the model of Engineering chip

[Solved] Keil-MDK Error: “Error: Encountered an improper argument”

Keil MDK solves the problem of “error: encoded an improved argument”


Arm official problem description and solutions: https://developer.arm.com/documentation/ka004382/latest


Cause of problem: μ The vision5 debugger is currently unable to process dwarf debugging information that contains folders or file names with UTF-8 characters. In other words, your project directory should be in Chinese, instead of using the directory with Chinese.

Solution: change all the paths to English, then clean up the project and recompile.

IAR Compile Error: Error[Li005]: no definition for [How to Solve]

after transplanting the program today, there was an error report of “error [li005]: no definition for” during compilation, which was encountered and solved before. Today, I’m going to officially record the causes and solutions of this error.

1. Reasons

just look at the error reminder given by IAR, “error [li005]: no definition for xxxxx”, which means that xxxxx is not defined (all cases I encounter refer to a function), but find the problem yourself, and you will find that this xxxxx has been defined in other C files, and this xxxxx function has been declared in the header file corresponding to this C file, And the path of the header file has been included in the IAR settings. There should be no problem! Then I began to wonder.

2. Solutions

let’s talk about the solution to this problem:

2.1 the C file where the xxxxx function is located is not added in the project

most of this happens because you accidentally removed the C file from the project, and you haven’t noticed it. The solution is very simple. Add the C file to the project again and recompile it.

2.2 when using conditional compilation, the xxxxx function is not compiled

this is why I have this problem this time. Let me give you an example:

#define FANJIE 1

#if FANJIE
void Get_Fans(void)
{
    for(int i  = 0; i<100;i++);
}
#endif

Take the simple function above as an example, when FANJIE is 1, call Get_Fans() in other c files, and no error will be reported, but when FANJIE is 0, call Get_Fans() in other c files Function, it will report the error “Error[Li005]: no definition for Get_Fans”.
The solution is also very simple, just make sure that the conditional compilation can be compiled normally.

[Solved] Rtthread DCM component dcm_cache_save interface Error: mkdir:/data failed

The rtthread dcm data persistence component was used in the project, but mkdir:/data failed was reported during dcm_cache_save

But this error log is not the code of this project, it is confirmed that it is the log printed inside the dcm interface

Then confirmed that the macro #define DCM_DEFAULT_STORAGE_NAME “/user/data/db/dcm” is already in rtconfig.h

Declare that this macro is also useful for business code at system startup

The final investigation is because dcm_default_storage_name needs to be assigned when the system starts, and the dcm_strg.o of the dcm component depends on

If this variable is not assigned, it will default to mkdir:/data, but if /data has no permission, it will report that error.

So dcm_default_storage_name = DCM_DEFAULT_STORAGE_NAME is solved (it needs to be called at startup)