stm32

STM32 : FatFs Library - f_mount

久未见 提交于 2020-01-06 19:29:34
问题 I am programming the STM32F0 (Keil uVision 5). I've tried to use FatFs library to manage a file system (SD card). I've writen every initialization functions and the project is compiling without any errors / warnings. But first function f_mount doesn't work properly. The function call is: const char sciezka = '0' ; FATFS *fs = (void *) 0; fresult= f_mount (fs, &sciezka, 1); Function doesn't even reach the line with disk_initialize. And I get fresult "FR_NOT_ENABLED" (f_mount -> find_volume : :

NVIC_SystemReset() stuck in while loop (STM32F302VB)

十年热恋 提交于 2020-01-06 19:24:35
问题 I'm currently developing on a STM32F302VB and I need to perform a software reset. On all my previous projects (with STM32F427 and STM32F030C8), I've always used the NVIC_SystemReset() function successfully. But for some reason it won't work with this chip. The implementation is in CMSIS core_cm4.h and is as follows: __STATIC_INLINE void NVIC_SystemReset(void) { __DSB(); /* Ensure all outstanding memory accesses included buffered write are completed before reset */ SCB->AIRCR = ((0x5FA << SCB

STM32 PWM DAC实验:cubemx实现

拜拜、爱过 提交于 2020-01-03 18:25:35
PWM DAC其实跟DAC是两码事,DAC是STM32的一个功能,可以直接输出(0~3.3V)。而PWM DAC是定时器TIM的PWM功能间接实现输出模拟量,实际端口输出的是(0或3.3V),只不过应用RC滤波将电压稳定在(0~3.3V之间)。在对输出精度不高的时候可以用该方式。 该实验是TIM PWM的拓展。当用作DAC时需要滤波,阿波罗采用二阶RC滤波,而RC(电阻电容)是跟PWM的频率有关系的。 之前的TIM PWM实验是实现呼吸灯效果,用的是90分频,因为TIM的时钟为90MHZ,分频后的周期为1us,PWM自动重装载值为500,向上计数,如果比较值是250,那么就是250us输出0,250us输出1。 那么这个实验是用256分频,也是根据90M/256=351.5KHZ来确定的RC。 那为什么要用256分频呢?其实用200、300、400都可以,只不过为了规范,我们设计此次DAC采用8位精度,也就是256。TIM最大支持16位的,但是分辨率越高,分频后的频率越低,周期越长。所以用8位还是比较好的。 如何理解PWM呢,就好像是一个灯泡,他的额定电压是自动重装载值,低于比较值他就灭,高于比较值他就亮,虽然电压从0到自动装载值匀速变化,灯泡也亮灭转换,但当速度快时,人眼就看不出来亮灭了,我们只能看到他是柔和的光不亮不暗。(比较值/自动重装载值) 就是你想让他亮的程度。

STM32断言assert_param 和 assert_failed使用

这一生的挚爱 提交于 2020-01-03 18:24:50
不忘初心,继续前行,小编了解到STM32中的断言功能,在此做个记录,有错误的地方希望指出,谢谢! 1、函数assert_param()传入为0时,直接跳到assert_failed()函数定义处,可以在assert_failed()函数中打印错误故障; 2、宏定义使用断言功能,在stm32xx_hal_conf.h文件中, #define USE_FULL_ASSERT 1U 4、注意:assert_param( ) ,传入0进入断言函数处, 传入1进入正常执行程序; 来源: CSDN 作者: qq_39758638 链接: https://blog.csdn.net/qq_39758638/article/details/103820392

How to decrease SPI overhead time for STM32L4 HAL library

邮差的信 提交于 2020-01-02 07:00:10
问题 I am using a STM32L476RG board and HAL SPI functions: HAL_SPI_Transmit(&hspi2, &ReadAddr, 1, HAL_MAX_DELAY); HAL_SPI_Receive(&hspi2, pBuffer, 4, HAL_MAX_DELAY); I need to receive data from accelerometer's buffer with maximum speed and I have a problem with delay in these functions. As you can see on the oscilloscope screenshots, there are several microseconds during which nothing happens. I have no idea how to minimize the transmission gap. I tried using HAL_SPI_Receive_DMA function and this

Embedded C++11 code — do I need volatile?

落花浮王杯 提交于 2020-01-02 04:16:09
问题 Embedded device with Cortex M3 MCU(STM32F1). It has embedded flash(64K). MCU firmware can reprogram flash sectors at runtime; this is done by Flash Memory Controller(FMC) registers (so it's not as easy as a=b). FMC gets buffer pointer and burns data to some flash sector. I want to use the last flash sector for device configuration parameters. Parameters are stored in a packed struct with arrays and contain some custom classes. Parameters can be changed at runtime (copy to RAM, change and burn

SPI_I2S_ReceiveData always returns 0xff or 0x00

别来无恙 提交于 2020-01-01 07:21:18
问题 I want to create firmware to stm32f4 discovery wich flashes the lights, when the board moves. But SPI_I2S_ReceiveData always returns 0xff or 0x00. I think the problem is in my SPI initialization but I do not know where exactly it is. Here is my code. #include <stm32f4xx.h> #include <stm32f4xx_rcc.h> #include <stm32f4xx_gpio.h> #include <stm32f4xx_spi.h> #include <stm32f4xx_i2c.h> void InitLEDs(void); void InitSPI(void); void Delay(int iTicks); void DiodeFlash(void); unsigned short

SPI_I2S_ReceiveData always returns 0xff or 0x00

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 07:21:04
问题 I want to create firmware to stm32f4 discovery wich flashes the lights, when the board moves. But SPI_I2S_ReceiveData always returns 0xff or 0x00. I think the problem is in my SPI initialization but I do not know where exactly it is. Here is my code. #include <stm32f4xx.h> #include <stm32f4xx_rcc.h> #include <stm32f4xx_gpio.h> #include <stm32f4xx_spi.h> #include <stm32f4xx_i2c.h> void InitLEDs(void); void InitSPI(void); void Delay(int iTicks); void DiodeFlash(void); unsigned short

HAL_SetDate sets the year to wrong value

醉酒当歌 提交于 2020-01-01 07:01:05
问题 I'm using STM32F030RCT6 with CubeMX. Device is a datalogger and RTC is the main thing that cannot fail. On Errata Sheet there is something about RTC Shadow Register. I configured CubeMX to not generate MX_RTC_Init() function and it has been working normally so far. (I'm using LSE) I need to update the time/date from GSM time but when I set the year to 18 with HAL_SetDate() and after a small delay I read with HAL_GetDate() , sDate.Year gave me 20 . Apart from Year , the other values are

STM32 how to get last reset status

北慕城南 提交于 2020-01-01 05:47:25
问题 I'm working with STM32F427 and I'd like to get cause of last reset. There is RCC clock control & status register RCC_CSR with many reset flags, but I'm not able to get any meaningful value. By reading the value of that register, I get only 0x03, which means LSI ready and LSI ON, but no flags about reset are set if I try power on, software reset, low voltage etc. I found snippet of code for getting reset flags like below, but all the flags are still 0. if (RCC_GetFlagStatus(RCC_FLAG_SFTRST)) .