# Tag Info

15

As you suspect, this is happening because the unsigned int data type is 4 bytes in size. Each *bss_start_p = 0; statement actually clears four bytes of the bss area. The bss memory range needs to be aligned correctly. You could simply define _BSS_START and _BSS_END so that the total size is a multiple of four, but this is usually handled by allowing the ...

7

I found the answer to this some time ago, posting it here in the hope it will help others. The reason 1 byte is sent immediately on enabling DMA, is because a DMA request (DRQ) is still active from the last time that TIM8 ran. TIM8 keeps running and raising DRQ signals, even after all the bytes in the buffer have been written and DMA stops. TIM8 is gated ...

5

The standard solution is memset(): #include <string.h> memset(&_BSS_START, 0, &_BSS_END - &_BSS_START) If you can't use the standard library, then you'll have to decide if it's ok in your case to round the size of the memory area up to 4 bytes and continue using unsigned int *; or if you need to be strict about it, in which case you'd ...

4

You can't really combine delays and measurements into one case. There is no common logic or one proper method. It depends on what you are doing and what timers and features the microcontroller has. A more specific answer would require a more specific question. If you implement measuring how long a piece of code executes like in your code, as long as the ...

4

Whenever an interrupt is triggered and the program is leaving its current work, there is some saving to do. The status bits in the status register are used for many tasks, that can be interrupted by an external/internal event. Imagine you check if a variable has reached a specific value and if this i true a conditional jump is to be made. Therefor the ...

4

In both boards, communication between the PC and the microcontroller is mediated by another microcontroller. On the Arduino board, communication between the target micro and the interface micro happens through the serial port of the target, while on ST boards communication happens through SWD interface. ST used SWD interface because it allows for much ...

4

I'm not sure I follow this. If the call to xQueueCreate() causes the system to crash, and xQueueCreate() is being called from main() before the scheduler has started, then it can't be the task stack size as the task is not running (and therefore its stack is not being used yet). If it is crashing in the call to xQueueCreate() then simply step into the ...

4

Just change != to <. That's usually a better approach anyway, as it deals with problems like this.

3

ADC reading and voltage level has a direct relationship. The ADC reading on the VREFINT channel and VDDA have inverse relationship. An ADC reading is the ratio of the measured voltage to VDDA, scaled up to 4095 (the maximum value that can be expressed on 12 bits). E.g. if you applied VDDA/3 to an ADC input, the result would be 4095/3=1365. So, the ...

3

Some micro-controllers have protected areas, which require additional steps to program and erase. Calibration parameters are usually stored in such areas, as they usually survive a firmware update. Other micro-controllers have areas of the flash that behave as EEPROM (single byte erase instead of sector erase). Parameters can be stored in such areas. If ...

3

No, the documention makes it quite clear that such behavior is fixed. But you can use a different GPIO pin of your choice to control your bootloader's behavior - ie, boot the target firmware or stay in bootloader mode. You could also use commands issued to the stock factory ROM bootloader to start your custom one, but that seems a little pointless as at ...

3

There are countless other sites and examples. Many thousands if not tens of thousands. There are the well known c libraries with linker scripts and boostrap code, newlib, glibc in particular but there are others you can find. Bootstraping C with C makes no sense. Your question has been answered you are trying to do an exact compare on things that ...

2

The relationship between ADC input voltage and output value is: $$IN = \frac{V_{REF} * OUT}{ 4095 }$$ Therefore: $$VREFINT = \frac{3.3*CAL}{4095} = \frac{V_{DD}*RAW}{4095}$$ Therefore: $$V_{DD} = \frac{3.3*CAL}{RAW}$$

2

VREFINTcal is the only known value. The value of VREFINT, when measured with a known good 3.3V Vdd. If you divide data with cal you know how many bits Vdd is off, assuming VREFINTcal is still valid. If VREFINTcal is 1000, and data is 1020, this means you've measured VREFINT to be 20 bits higher than it's supposed to be. Indicating a lower Vdd value. Hence ...

2

The HAL timer interrupt handler does not do anything special, it checks all possible pending interrupts, clears them and runs the callback. So it is not re-entrant. If your callback takes longer to run than the timer period, the interrupt has to wait until callback and handler are finished to run again, so during this time the interrups are missed and it ...

2

Sure. simulate this circuit – Schematic created using CircuitLab Figure 1. Two options. R3 and R4 added as per Spehro's comment. When the button is pressed it pulls the GPIO to a well defined voltage. When the button is released it needs to be pulled to the opposite logic level (other voltage rail). This is done by a pull-up (a) or a pull-down (b) ...

2

STM32F051 is based on Cortex-M0. This CPU core always loads interrupt vectors from address 0. Note ARM Cortex design documents strongly suggests that flash is at address 0x00000000, RAM at 0x20000000, peripherals at 0x40000000. For a bootloader/application interworking based on ARM Cortexes, main problem is: CPU boots by loading initial stack pointer and ...

2

1) The vector table is at the start of code normally and in your case there is the bootloader. The application code and it's vectors are later in code, so the interrupt controller needs to be told that when interrupt happens the vector is fetched from where the vectors for the main application are, otherwise it would jump to bootloader code. Bootloader uses ...

2

This applies to Eclipse CDT + GNU MCU Eclipse plugin, and might work in other eclipse based IDEs like yours. In the Project - Properties - C/C++ Build - Settings dialog there is a dropdown list at the top to select configurations, configured by default to switch between debug and release build. It's possible to define additional configurations there, e.g. a ...

2

A very quick scan of the datasheet suggests that the VC part is a strict subset of the ZG part. The VC part has fewer pins so you can't use ports F or G, and it has less flash memory. If my interpretation is correct, and you should definitely spend some time to verify, then any code that runs on the VC should also run on the ZG. I suggest that you try ...

2

When an exception (interrupt) happens the context of what the core is doing at that moment needs to be pushed on stack, so it is possible to return to it later. This is done by a stackframe. For an exception a stackframe looks like this: Registers R4 to R11 are not pushed to stack unless the exception code needs them. The compiler may push/pop these ...

1

Most delay methods in a microcontroller only guarantee that the delay will be at LEAST what you want it to be, not precisely what you want it to be. The simplest way is to poll a timer in the main loop amongst all the other things that are running to check if the timer has exceeded a particular count. Another way is to set a timer interrupt to trigger ...

1

I am also a starter and have been using STM32F407VG-DISCOVERY board over 2 months and it has almost evetything a starter may need. But in my location discovery boards were more expensive then Nucleo boards. I guess a Nucleo board also does the job. However, discovery boards has 4 user LEDs while Nucleo has 1 or 2. The maximum clock frequency is not a very ...

1

Actually, this is quite simple. Wire it up like this: simulate this circuit – Schematic created using CircuitLab You may even configure the GPIO as an open drain output and control the LED from the µC as well as the button. As you can't check the button while the GPIO is turned an output, you have to switch to input mode for a few µs every few ms. ...

1

HAL library functions are too slow for tasks involving precise timing, and the MCU in the linked post is twice as fast as yours, so it'd be even worse. For a bit-banging 1-wire implementation only 3 register accesses are needed: GPIOx->IDR to read the port, GPIOx->BSRR to output a bit, and SysTick->VAL, see below. If you can't get DWT->CYCCNT to ...

1

SPI has much less bandwidth so use the STM32 SDIO peripheral to provide faster transfer rates.

1

It sure looks like a typo to me. The only way the values 0x92 and 0x07 would make sense is if each byte is split into 4-bit nybbles, and the least-significant nybble is sent first, but the nybble itself is sent MSbit first — which would be truly bizarre. The more likely explanation is that the author forgot to flip it in his head when reading the ...

1

When the CPU receives an interrupt, it must save some of the current status of the CPU before invoking the interrupt handler so that it can be restored when the interrupt handler is finished. These data include the current flags and value of the program counter, and usually some other registers. (Jeroen3's answer gives the full details for this particular ...

1

I think you are mentioning the case of a so called floating input. When there is nothing connected to an input (either digitally or analog), the value you get is indetermined, and it is instable (meaning it can change for every reading you make). Always make sure you have something connected that you want to read to an input, AND in cases the input is not ...

1

You shouldn't have any particular expectation for the reading of an unconnected ADC input or one not definitively driven to a voltage with respect to the analog ground. If you consult the data sheet you will find there is a maximum drive impedance for meaningful results determined in part by the selected conversion time.

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