Hot answers tagged

55

A bootloader on a microcontroller is responsible for updating the main firmware over a communication channel other than the programming header. This is useful for updating firmware in the field over BLE, UART, I2C, SD cards, USB, etc. It would be extremely inconvenient to require customers to purchase programmers just to update the firmware on their ...


42

GPIO_PuPd (Pull-up / Pull-down) In digital circuits, is is important that signal lines are never allowed to "float". That is, they need to always be in a high state or a low state. When floating, the state is undetermined, and causes a few different types of problems. The way to correct this is to add a resistor from the signal line either to Vcc or Gnd. ...


31

VDDA is not connected. Application note AN4325 Getting started with STM32F030xx and STM32F070xx series hardware development says, The VDDA supply can be equal to or higher than VDD. This allows VDD to stay low while still providing the full performance for the analog blocks. When a single supply is used, VDDA must be externally connected to VDD. So,...


27

Definitely the CMSIS. It is not exactly a library, it mostly contains definitions for the various registers. It is exactly what one needs to access the microcontroller's registers easy, so as to implement his/her own HAL. It has no overhead, since you just access the registers. Keep in mind that CMSIS, unlike the other two, is defined by ARM and not ST. ...


25

The question here really is: what is the machine code you're generating from the C program, and how does it differ from what you'd expect. If you didn't have access to the original code, this would've been an exercise in reverse engineering (basically something starting with: radare2 -A arm image.bin; aaa; VV), but you've got the code so this makes it all ...


25

So that the loading process can recover from errors. Suppose there is a communication error or power disconnects during an upgrade. If the boot loader were part of the application you were upgrading then the user wouldn't be able to try again without using special hardware to reflash to boot loader. Some microcontrollers can't execute code from RAM. If the ...


24

All STM32 MCUs have self-programmable flash memory. If you need to store user settings, you can store them in an area of flash. ST provides a library to perform EEPROM emulation on the STM32F4. (There are similar libraries for most of their other parts as well.) Even if you don't plan on using that library, their application note explaining how it works may ...


23

Regular watchdog timers must be reset at some time before they time out. If you have a 100ms WDT you can reset it every 99.9ms or every 10us and it will never time out. Window watchdog timers have a time window within which they must be reset. If you reset it too early or too late (from the previous reset) it will cause the processor to reset. The ...


23

The internal oscillator is much less stable than an external crystal oscillator. If I'm reading the datasheet correctly, the internal 48 MHz oscillator is only factory calibrated to within 2.9% of the specified frequency - not even good enough for RS-232. There are ways to synchronize it to an external clock, I think it's designed to be used in a USB device ...


21

Three things you should note: 1) Most bypass recommendations in datasheets and application notes are fairly random in my opinion. You may easily be a better engineer than the person who wrote the application note :-). A better datasheet would talk about how low an impedance you as a board designer should provide and to what frequency. I wrote about this ...


21

If you want power-saving, put the MCU to sleep. The relevant instructions are WFI and WFE: wait-for-interrupt and wait-for-event, respectively. WFI is kind of self-explanatory: it wakes up when you get an interrupt. (The interrupt must be enabled, though!) WFE might merit a bit more explanation. To use it, it's probably enough to know that if you set ...


21

You have missed a major detail of RS232. Logic levels are as follows: Figure 1. RS232 signal levels. Source: Wikimedia Commons. Logic 1 = -3 to -12 V. Logic 0 = +3 to +12 V. Between -3 and +3 the logic level is undefined. The RS232 start bit is a logic 0. To convert from TTL (5 V) logic to RS232 a driver is required. Chips such as the MAX232 do the logic ...


20

http://github.com/dwelch67 stm32f4 and stm32vld in particular, but the others may be useful to you as well. mbed and the mzero directory under mbed (cortex-m0). I like the keep it simple stupid approach, minimal linker scripts, minimal startup code, etc. The work is done by the code not by any particular toolchain. Most forms of gcc and binutils (capable ...


20

Generally speaking the factory reset function you mention will restore any saved variable data information back to default values. It is not true that all embedded devices have this capability. Some do but not all. If you want your device to support a return to factory default firmware itself then your design has to incorporate a memory into the circuit to ...


19

The main difference between a function and a software interrupt is what is known as context. A function runs within the context of your main program. An interrupt runs within the context of the interrupt handler. On a simple system this may be no real difference, and software interrupts may simply be used as a convenient way of providing library routines ...


19

It says the implementation of the function should be weakly linked (as opposed to strongly linked, which is the usual). This allows providing a "fallback" implementation of a function, in case no other (strongly linked) is found. This is often used for default interrupt handlers in bare-metal MCU frameworks. This way, when you implement an interrupt, you ...


17

Why don't you use the CMSIS library? There is a specific function for that. Moreover, This is the Code taken from CMSIS Library for System Software Reset: /****************************************************************************** * @file: core_cm3.h * @purpose: CMSIS Cortex-M3 Core Peripheral Access Layer Header File * @version: V1.20 * @date: ...


17

I managed to solve that problem. If anybody encounters similar problem, here's what I've done: I used ST-Link v2 and ST-Link Utility. In setting, I set "Connect under reset" and SWD interface (I'm not sure about frequency). Then I press the reset button on my board and clicked "Target" -> "Erase chip" and just after clicking I released the button - It ...


17

I got the first method from this page working on my STM32F072. http://www.openstm32.org/forumthread1055 As stated there, The way I got printf (and all other console-oriented stdio functions) to work was by creating custom implementations of the low-level I/O functions like _read() and _write(). The GCC C library makes calls to the following ...


17

You misunderstand what the heap is. The heap is the area where malloc gives you blocks of RAM dynamically at run-time. Your globally scoped, statically allocated variables & arrays are not 'on the heap'. If you're not using malloc or any of its variants in your program, you can quite safely set the heap size to 0.


17

Have you looked at your power supply waveform with an oscilloscope? The LF33 linear low-dropout voltage regulator you seem to be using requires a minimum of 2µF of added output capacitance for stability, your schematic only shows 100nF. Also, I don't see any input capacitance before the regulator. If the regulator is oscillating, it could be intermittently ...


16

You can configure the ADC to read in a sequence of channels in a loop. Those channels are being converted regularly. In injected mode conversion is triggered by an external event or by software. An injected conversion has higher priority in comparison to a "regular" conversion and thus interrupts the regular conversions. The different ADC-Modes are ...


16

In your disassembly we see calls to 64 bit (double precision) math functions:- 08001956: bl 0x80004bc <__extendsfdf2> ... 0800195e: bl 0x8000564 <__muldf3> 08001962: bl 0x8000988 <__fixdfsi> The STM32F4 only supports 32 bit floating point in hardware, so these functions must be done in software and will take many cycles to execute. ...


16

In general, it is perfectly fine to use the internal pull-up or pull-down resistors. Disadvantage is that you can forget to enable it from software, that can cause a little headache. The external pull-ups will always be there. So do not forget to enable the internal ones and save a lot of PCB area by reducing component number. The STM32's internal pull-up ...


15

Good question; you think they would put that info in the manual...or a least a little blurb like the following... Doing some digging, found this from STM32F10x Technical Training V0.3 Event Out signal generation Pulse generation with SEV instruction: to wake-up an other MCU from low power mode through its Event In signal Looked up SEV instruction ...


15

Before you can start executing code from external RAM, you have to first initialize FSMC and copy your code into that RAM, so you have to boot from flash anyway. A properly written linker script (with an additional code section linked at the correct address but placed in flash, like the .data section) will help greatly. You'll be able to mark functions you ...


15

Sometimes finding the answer to these questions for an ARM device can be more difficult than simpler microcontrollers because the information is often spread across family and programming guides rather than included in the datasheet. In this case the answer appears to be on page 381 of the RM0090 Reference manual: The STM32F4xx are able to handle external ...


15

Generally, you only need to handle the interrupt flags which you have specifically enabled with USART_ITConfig(). However, if you enable the RXNE interrupt (USART_ITConfig(USARTx, USART_IT_RXNE)) then this also enables the Overrun interrupt! So you must handle both of those. The USART flags can be confusing. There are separate status flags and interrupt ...


15

Let's start with the HAL_I2C_Master_Transmit() function. If you check its declaration: HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout); Minor problem with 2nd parameter, the slave device address. The slave device address is b1010000 if we complete it to 8bit format, ...


15

The shortest CAN frame is 55 bit times, so in the very worst case situation with a completely saturated bus consisting of one data byte frames (which is not really realistic for a CAN bus with any sort of useful performance) you will be receiving a frame every 220 µS (55 / 250000). The cheapest ST microcontroller that has a CAN controller is the ...


Only top voted, non community-wiki answers of a minimum length are eligible