stm32

How can I change the start address on flash?

只愿长相守 提交于 2020-05-15 03:59:06
问题 I'm using STM32F746ZG and FreeRTOS. The start address of flash is 0x08000000. But I want to change it to 0x08040000. I've searched this issue through google but I didn't find the solution. I changed the linker script like the following. MEMORY { RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K /* FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K */ FLASH (rx) : ORIGIN = 0x8040000, LENGTH = 768K } If I only change it and run the debugger, it has the problem. If I change the VECT_TAB_OFFSET from

Light the LED on STM32F103C8T6

懵懂的女人 提交于 2020-04-29 15:42:50
问题 I'm trying the light an LED (on port c, pin 13) on STM32F103C8T6. I'm not using IDE. Code: #include "include/stm32f10x.h" int main() { RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; GPIOC->CRH &= ~GPIO_CRH_CNF13; GPIOC->CRH |= GPIO_CRH_MODE13_0; GPIOC->BSRR = GPIO_BSRR_BR13; while(1) { GPIOC->BSRR = GPIO_BSRR_BS13; } return 0; } Links to include files in include directory: system_stm32f10x.h core_cmInstr.h core_cmFunc.h core_cm3.h stm32f10x.h part1 stm32f10x.h part2 That's how I compile it arm-none-eabi

STM32Cube - project does not build (Selected processor does not support Thumb mode)

a 夏天 提交于 2020-04-18 07:29:33
问题 I have generated a code base using STM32Cube for STM32F205RB to be used within Atollic TrueSTUDIO. The project does not build, giving the error: arm-atollic-eabi-gcc -c -mthumb -std=gnu90 -DUSE_HAL_DRIVER -DSTM32F205xx -IC:\Users\Elliott\Atollic\TrueSTUDIO\ARM_workspace\USBInterfaceCUBE\USBInterfaceCube/Inc -IC:\Users\Elliott\Atollic\TrueSTUDIO\ARM_workspace\USBInterfaceCUBE\USBInterfaceCube/Drivers/STM32F2xx_HAL_Driver/Inc -IC:\Users\Elliott\Atollic\TrueSTUDIO\ARM_workspace\USBInterfaceCUBE

Issues reading data from ADXL355 using SPI (STM32 board)

老子叫甜甜 提交于 2020-04-16 03:33:51
问题 I'm trying to read data from an EVAL-ADXL355-PMDZ connected to a STM2L072 Lora discovery kit through the SPI protocol for a project. At first I was using an ADXL345 sensor and I was able to read the accelerometric data and convert it to g without any issues. After switching the sensor to ADXL355, I keep receive all zeroes when reading data registers instead. I changed my initial code for ADXL345 accordingly to the datasheet of the ADXL355 sensor (https://www.analog.com/media/en/technical

Issues reading data from ADXL355 using SPI (STM32 board)

半城伤御伤魂 提交于 2020-04-16 03:33:46
问题 I'm trying to read data from an EVAL-ADXL355-PMDZ connected to a STM2L072 Lora discovery kit through the SPI protocol for a project. At first I was using an ADXL345 sensor and I was able to read the accelerometric data and convert it to g without any issues. After switching the sensor to ADXL355, I keep receive all zeroes when reading data registers instead. I changed my initial code for ADXL345 accordingly to the datasheet of the ADXL355 sensor (https://www.analog.com/media/en/technical

基于stm32的modbus协议移植

冷暖自知 提交于 2020-04-09 11:00:05
在移植过程中得益于这两篇blog,大家可以参考下。 http://ntn314.blog.163.com/blog/static/161743584201233084434579/ http://bbs.eeworld.com.cn/thread-362508-1-1.html 这两篇博客上对modbus协议以及移植解释的很清楚,这里就不在啰嗦了。 首先,要下载一个freemodbus,自己写的modbus协议也可以,但考虑到时间和可扩展性还是选择开源的比较妥当些。这个协议最核心部分我感觉就是对寄存器的读写,当然如果涉及到PLC当然还有继电器等,其他部分已经把接口给你了,然后自己就按照说明去添加就可以。对了,在移植中当时对这个过程 *pucRegBuffer++ = ( uint8_t )( usRegHoldingBuf[iRegIndex] >> 8 ); *pucRegBuffer++ = ( uint8_t )( usRegHoldingBuf[iRegIndex] & 0xFF ); 有点模糊,但在纸上画一下就豁然开朗了。其他的就没有难度了。下面就进入正文: 首先需要改动的部分还主要是 eMBRegInputCB(UCHAR * pucRegBuffer,USHORT usAddress,USHORT usNRegs)、 eMBRegHoldingCB(UCHAR *

stm32:简单按键输入实现

时间秒杀一切 提交于 2020-04-08 14:07:51
开发环境keil4,芯片STM32F103C8T6 1、main.c //串口实验 #include "sys.h" #include "delay.h" #include "key.h" #define DC12VDO_ON() GPIO_SetBits (GPIOC, GPIO_Pin_13) #define DC12VDO_OFF() GPIO_ResetBits (GPIOC, GPIO_Pin_13) int Index1,Index2,Index3 = 0; int time1; unsigned char gUart_Rece_Buf1[256]; unsigned char gUart_Rece_Buf2[256]; unsigned char gUart_Rece_Buf3[2048]; int i,j=0; u8 key; int main(void) { delay_init(); //延时函数初始化 sys_Init(); //系统初始化(时钟初始化、中断初始化、GPIOx初始化、串口1初始化、串口2初始化、串口3初始化) while(1) { DC12VDO_OFF();//led常亮 key=KEY_Scan(); if(key==1) { DC12VDO_ON();//灭led delay_ms(1000);//等待 } } } 2、key.c

基于stm32的HC-SR04超声波测距模块使用

北城以北 提交于 2020-04-06 19:09:17
1 工作原理 使用超声波模块之前,先了解其IO口和工作原理: 1.1 IO说明 VCC: 供5V电源 GND: 为地线 TRIG: 触发控制信号输入 ECHO: 回响信号输出 1.2 基本工作原理: 认真看好以下工作原理,后面的代码就是基于工作原理来实现的。 (1)采用IO口TRIG触发测距,给最少10us的高电平信号。 (2)模块自动发送8个40khz的方波,自动检测是否有信号返回; (3)有信号返回, 通过IO口ECHO输出一个高电平,高电平持续的时间就是超声波从发射到返回的时间。 测试距离=(高电平时间*声速(340M/S))/2 时序图: 2 程序编写 2.1 外设配置 根据两个信号引脚来配置两个单片机的IO口 trig: 需要产生一个10us高电平, 配置为推挽输出; echo: 等待高电平脉冲并测量其脉冲宽度, 配置为下拉输入 测量echo的高电平持续的时间,需要用到定时器, 因此配置一个定时器,用来计时 void UltrasonicWave_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);//开启GPIOB时钟 RCC

STM32串口之空闲中断

泪湿孤枕 提交于 2020-04-06 13:44:38
NBiot模块一般都是串口接口,使用AT指令集,对接中国移动onenet平台。先用串口助手去测试,流程测试OK之后需要在MCU上重新写一遍。 STM32 串口 IDLE 中断 IDLE其实是空闲的意思。IDLE中断叫空闲中断,不叫帧中断。那么什么叫空闲,怎么定义空闲呢?在实际发送数据的时候,比如一串字符串,我们会采用如下方式发送 void uart1_putc(char dat) { SBUF = dat; while (!TI); TI = 0; } void uart1_puts_n(char *str){ while (*str) uart1_putc(*str++); } void uart1_puts_n("i am handsome"); 其实发送的两个字符之间间隔非常短,所以在两个字符之间不叫空闲。空闲的定义是总线上在一个字节的时间内没有再接收到数据,空闲中断是检测到有数据被接收后,总线上在一个字节的时间内没有再接收到数据的时候发生的。 而总线在什么情况时,会有一个字节时间内没有接收到数据呢?一般就只有一个数据帧发送完成的情况,所以串口的空闲中断也叫帧中断。 要怎么开启帧中断呢? 其实其他串口配置不用改变,只需要在开启串口接收中断的时候加上一句话就Ok。 USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);//开启串口接收中断