Hot answers tagged

30

I'm not an electronics engineer, but I would go for using the TX operation as a software UART. For an RX operation, buffering is needed, and interrupts are needed not to miss information. This is typically handled by a hardware UART. For a TX operation, you only need to send information, which is happening when you want it (for receiving you don't know ...


14

It's far simpler to implement a UART transmission in software because you just bit-bang the output port until the bytes are sent. To implement a receiver, you have to do multiple checks on the bits as they arrive (such as waiting for the start bit) and parity checking and usually, you have to run at a much higher processing rate to ensure you can cope with ...


12

The BYPASS pin should be low to to enable internal regulator. Now it is high and disables internal regulator.


3

I figured it out. NVIC->ISER[0] |= TIM2_IRQn; should be NVIC->ISER[0] = 1UL << TIM2_IRQn; because to enable the interrupt you want to set bit 28, not write 28 as bit value to the register. Now it works as expected.


3

Consider a successive approximation ADC. Each step size successively halves the step size at the previous step, so teh first step (for the MSB) compares the input with Vref/2. Then successive steps are smaller powers of 2, until ... 4095? No, 4096. Now the ADC can output 4096 codes, from 0 to ... 4095. Every output code is effectively "rounded down" to ...


3

You need a pull down resistor in you switch GPIO pin. Connect a 10K resistor from the pin to ground. The GPIO is probably floating causing the input to switch on/off very quickly when the button is not pressed. This will cause your LED to glow slightly or give random behavior. simulate this circuit – Schematic created using CircuitLab


3

Some reasons: printf uses _write and _read. You can write your own ones for example if you want to redirect output to SWO malloc & friends use _sbrk. Bur I would rather avoid dynamic allocation in the limited resources implementations. This version of _sbrk is very poor (it assumes that the stack is at the largest addresses and heap is just before etc ...


2

This is almost 100% opinion based answer. I personally do not like CMSIS wrappers. There is to much silly (IMO) macros and hidden objects created by them. I actually prefere freeRTOS API if I use freeRTOS. It makes also debugging more difficult.


2

Flash sector 11 might not available on the E type, only on the G type. As it is the last sector. Sectors are truncated from the higher addresses when selecting lower size parts. See chapter "Part numbering" in the datasheet. Any tips? Remove the flash lock/unlock between the erase and write. Some of the older ST parts require this to be one session. ...


2

The problem was found in memory addressing. Correct memory addresses are: CMD: 0x60000000 DATA: 0x60020000


2

Can I use SD card instead of usual flash chip in this case? No. SD cards are not well suited to memory-mapping in general, as they do not have predictable access times and cannot be read/written on a more granular basis than a sector (512 bytes). It will be connected to qspi controller like single spi flash memory. That won't work. The QSPI controller ...


2

I believe it's all embedded in this graph from the device data sheet: - So, calculate what 1 LSb means in terms of input voltage and multiply that by the digital value produced by that input voltage. You have to take into account several error factors though such as: - Offset error (the input voltage equivalent to digital zero) Gain error (the real average ...


2

Unfortunately STM32F103 series do not have OTG_FS hardware. Reference manual is misleading as it mentions both OTG_FS and USB Device modules. This is because some parts in this family have it (like STM32F105). You can use STM32CubeMX to find a microcontroller by filtering them according to selected criteria. A framework based on ArduinoIDE is probably not ...


1

Yes, shorting a capacitor with a button does cause a large pulse of current. In fact, AVR hardware design guide suggests that when a push button with contact bounce and reset capacitor is combined with stray inductance from wires and PCB traces, the surge voltages can be out of specs for the reset pin and thus a 330R series resistor is recommended. Also the ...


1

A USB-to-Serial adapter isn't a debugger. So, this won't work. Get a debugging adapter: STlink v2-compatible adapters are really cheap.


1

You need to rewrite all of those functions as STM32F4 and STM32F1 have completely different clocks, different GPIOs . Changing GPIO pin is definitely not enough.+-


1

Is this a proper method to do PWM to analog voltage conversion? Yes. Is there any way to improve the output accuracy of the STM32 and the detection accuracy of the ATtiny85 in this circuit design? Use the highest available PWM frequency. Make the r/c time constant large enough that voltage ripple is less than the accuracy you need, but small enough ...


1

After lots of tries, I found out that, remapped SPI1 does not work together with I2C1, because of I2C1-SMBA pin overlap with SP1 MOSI pin (PB5), even if you are not using SMBA. You can find about that here: STM32F103x8 errata chapter 2.8.7 So, I guess, I will use I2C2 for avoiding collision. The only change I should make on PCB would be redirecting I2C1 ...


1

The F4/F7 have plenty of memory to handle this. You'll need just over 200 bytes (100 samples * 2 bytes each), which is a fraction of even the smallest F4 chips. A moving average is a type of FIR filter and has some advantages to an IIR filter (such as an "infinite average"), such as that it responds more quickly to changes and will settle more quickly on a ...


1

If it were only a small number of averages then I would create a shift register. Pseudo code for a small number of averages. function movingAverage(pulseAverage) { static register[2]; // 3 registers register[2] = register[1]; // data shift register[1] = register[0]; // data shift register[0] = pulseAverage; // move the input into the ...


1

Both functions appear to work essentially identically, except for how bits 31:24 are handled - but I do not think this is your issue. You did not specify which Arduino you were using though, and since shiftIn is a simple bit-banging function it will run att different speeds depending on what processor and speed you are working with, so if you are using an ...


1

Do not wire two or more outputs together. That is a standard rule for push-pull type digital outputs. When other drives low while other drives high, abnormally large current flows from pin to pin and may damage one or both output pins. Also, UART needs TX output connected to RX input for communications.


1

The W5500 is an ethernet and TCP/IP controller. OSI Model layer 4. Short story, the W5500 is not a web server, and will never be. To get a web server, you have to run one on the STM32F4. The advantage is that you don't have to worry about layer 4 and below. You use the SDIO peripheral. This requires a driver. If you want the contents of the SD cards to be ...


1

CMSIS-RTOS is a standarized RTOS abstraction from ARM. You can us it for example with FreeRTOS or Keil RTX. A oversimplified analogy may be POSIX - you can basically compile the same code on Linux, BSD and MacOS. A good use case can be migration. If you eventually want to migrate (on ARM CPUs) from FreeRTOS to a different RTOS, then use the CMSIS API. If ...


1

If you want a different approach and don't want to overwrite functions or declare your own, you can simply use snprintf to archieve the same goal. But it's not as elegant. char buf[100]; snprintf(buf, 100, "%X %X", val1, val2); HAL_UART_Transmit(&huart1, (uint8_t*)buf, strlen(buf), 1000);


1

For those struggling, add the following to syscalls.c: extern UART_HandleTypeDef huart1; // access huart1 instance //extern int __io_putchar(int ch) __attribute__((weak)); // comment this out __attribute__((weak)) int __io_putchar(int ch) { HAL_StatusTypeDef status = HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); return (status == ...


1

It works just as expected from that code that controls the uarts - first there is transmission out on UART3, and after that is fully complete there is reception from UART2. So UART2 does not see any reception as at that time there is no transmission going on UART3.


1

It is far not enough. You need to disable all interrupts in the NVIC.


1

do STM assume that working with registers is not necessary when I use STM32? Yes. They don't want you to bang the registers directly, because then they would have to document them properly and you would have to know about any differences between devices (including hardware bugs). By going through the Hardware Abstraction Layer you are shielded from all ...


1

Yes, they're connected. This schematic uses the convention that any labelled net is connected to all other nets with the same label. For example, the two nets labelled "SWDIO" and "SWCLK" on the SWD connector are connected to the pins with matching labels on the microcontroller. Similarly, the pins on the two 20-pin connectors all match up with pins on the ...


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