[Visual home environment analyzer] Read environmental data using ST MEMS sensor kit
[Copy link]
It was my first time using M7 for development, and I felt that it was still difficult. I needed to understand the examples in F7, how to burn and download, and because it was a two-layer structure, the boot and the actual app were downloaded separately, so I looked at the examples first and how to run them. Then I modified them and used cube_mx to produce my own app file.
Let's take a look at our board and modification process.
Things with Arduino interface can be connected directly.
Directly add our sensor package in the cube, and then prepare the corresponding interfaces. These have to be selected carefully because they are made by ourselves. In some ST routines, there are corresponding board-level packages, which contain a lot of ready-made things.
The project generated here cannot be used yet. We need to modify the project.
In Keil, we need to upgrade the compiler to use 6, and then the following IROM address, this address is our external QSPI Flash address, RAM is still our internal. Because there is no image, there is no need to load external SDRAM for the time being.
Find our SystemInit function, here we need to use it as an app and redefine our interrupt vector table.
/* FPU settings ------------------------------------------------------------*/
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
#endif
/* Reset the RCC clock configuration to the default reset state ------------*/
/* Set HSION bit */
RCC->CR |= (uint32_t)0x00000001;
/* Reset CFGR register */
RCC->CFGR = 0x00000000;
/* Reset HSEON, CSSON and PLLON bits */
RCC->CR &= (uint32_t)0xFEF6FFFF;
/* Reset PLLCFGR register */
RCC->PLLCFGR = 0x24003010;
/* Reset HSEBYP bit */
RCC->CR &= (uint32_t)0xFFFBFFFF;
/* Disable all interrupts */
RCC->CIR = 0x00000000;
#if defined (DATA_IN_ExtSDRAM)
SystemInit_ExtMemCtl();
#endif /* DATA_IN_ExtSDRAM */
/* Configure the Vector Table location add offset address ------------------*/
#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
SCB->VTOR = APPLICATION_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation to APPLICATION_ADDRESS in preprocessor defines */
#endif
SCB->VTOR = APPLICATION_ADDRESS | VECT_TAB_OFFSET; This is a redefinition. In the given process, APPLICATION_ADDRESS is defined in the global macro.
In fact, we only need to add the macro in the red box, and the rest are optimizations of other places. We have directly set them in cubemx. For example, the system frequency in the back is set directly.
After finishing, the code will be generated directly, and our application functions will also be ready.
The next step is to modify the download location. We cannot download to the internal flash here because the internal flash is used as boot. We need to download to the external flash.
As for how to find the boot, you can find the F7 package downloaded by cube, which contains the history, including the factory history, so the provided is relatively complete, including the two GUIs for booting.
You also need to be careful when using the routines inside.
Some of the programs that are opened use external SDRAM, which is not initialized in the program, which will cause it to fail to run, so be sure to choose internal RAM.
After completion, open the serial port and there will be information. Also note that serial port 1 has been modified.
They are PA9 and PB7.
|