New answers tagged

2

This note is present in many STM32 datasheets (from stm32f030rc below): Despite the fact that is not a current in/out of the GPIO pin itself and that information on precise current and voltage values is not available in the notes, it may be a problem.


1

Yes, it is possible that applying voltages around 1.8 V will cause high currents in the input circuitry of the IO pins. The switching threshold for CMOS gates is typically set near one-half of the supply voltage, or 1.65 V in your case. If the input voltage is close to that switching threshold then both the PMOS and NMOS transistors will be enabled, allowing ...


1

When studying embedded systems on the beginner level, we are always told to never write long ISRs. Especially don't call delays or print functions from inside the ISR. Though in this case the most convenient fix might be a quick & dirty release of the global interrupt mask. Something like this: void EXTI0_IRQHandler(void) { __asm("CPSIE i"); /...


1

No, AFAIK the algorithm needs just 2 pages. Number of variables (keys) is irrelevant. You just need to define separate keys for your variables. Remember, each 2-byte record needs a 2-byte key, and they don't take any space unless you record them. Of course I'm assuming that your variables are at most 2-byte long. I can't remember if the library provides a ...


0

Since you are using Nucleo, the MCU that handles the ST-LINK debugging has the crystal oscillator, and it provides a square wave clock out to the target MCU. It is the MCO pin that can fed to two pins in the target MCU.


3

It sounds like EXTI0_IRQHandler() is preventing the systick timer from running. I believe HAL_Delay() uses the systick timer. So the timer stops incrementing and the HAL_Delay() function waits forever. It may be possible to fix this by adjusting the priority of EXTI0_IRQHandler() lower than the systick mechanism so that systick continues to run even while ...


0

The way I would do this: in the callback function, stop the timer and DMA and set some "flag" variable: void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) { HAL_ADC_Stop_DMA(&hadc1); HAL_TIM_Base_Stop(&htim3); samplingFinished = 1; } (samplingFinished is uint8_t global variable) and in main while loop check if ...


0

My guess (as I struggled with it for a while myself): Note: Reading I2C_SR2 after reading I2C_SR1 clears the ADDR flag, even if the ADDR flag was set after reading I2C_SR1. Consequently, I2C_SR2 must be read only when ADDR is found set in I2C_SR1 or when the STOPF bit is cleared. This happens when you use the debugger and try to see which bits are set. The ...


1

Most bits in status register SR1 will get cleared when they have been set to 1 and the MCU reads them as being set to 1, so you don't have to do anything at all to clear them. This behaviour is explained in the manual.


1

My tranceiver have RE and DE pins so I configured like this: // Configure the RS-485 pins: GPIO_InitStruct.Pin = GPIO_PIN_3 | GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); And I add RE pin to Reset for the ...


0

Agree I suspect the USB transfer is taking longer than you expect. Set the ADC up as a separate DMA/interrupt task to fill buffers and never stop transferring into clean buffers. Then let the USB just transfer the buffers to the PC as they are filled


3

The board manual says it is used to connect an external debugging tool to debug the target MCU on the Nucleo board. However, I see no reason why the onboard ST-LINK debugger cannot be used to debug another target (as I have done this on another Nucleo board), but the on-board target needs to be disconnected from the ST-LINK debugger pins (physically, or ...


2

The internal oscillators are reliable, and will meet the accuracy specified in the datasheet, if that's adequate for your application, then by all means use them. If you're not sure, and you have the pins and PCB area available, add a crystal or oscillator to your circuit, and board, and don't populate them unless you find they're required. In the part you ...


2

HSI16 and HSI48 are both reliable. HSI16 +/- 2% accuracy over the whole temperature interval is extremely good for an internal oscillator. HSI48 is less accurate but still reliable. SPI clock recovery is far less critical than USB because it has a dedicated clock pin. For safety critical applications use an external hardware watchdog to control your CPU ...


0

Yo have to start the receive with interrupt, with set timeout - a timeout timer that restarts at received char. So you should start receive and this should trigger an interrupt when last character is received + timeout_char / or if no character is received + timeout_recv Then you you have to parse the received telegram by using receive complete callback. You ...


0

Models of quartz crystal do not have transconductance. No equation nor explanation in the linked design guide demand the transconductance of a crystal. Transconductance is a property of a fet amplifier in the oscillator part of the microcontroller. It can be found in the microcontroller datasheet. You can think of it with the next simplification of the ...


2

The transconductance cannot be found on crystal datasheet, because it is not a property of the crystal. It is a property of the oscillator and therefore found in the MCU datasheet.


0

Since the signal lines are not routed as a differential pair, I would avoid using this as USB. While the bus may work (e.g. if each trace is close to 45 Ohms), the large loop formed by 7cm separation could make for a decent amount of radiated emissions (and noise pick-up). Plus if they designed these signals only for general I/O they probably didn't put any ...


2

You need to do VBUS sensing if you have another power source. If your device is bus powered only, all it could tell you is that you have no power, but the MCU isn't running at this point either, because it has no power. If you have a separate power source, you need to reset the USB state machines (and possibly some other logic) when VBUS goes away, because ...


2

Make 2 global variables called tick and previousTick, or whatever you want, and inside the timer ISR increment the tick variable by 1. then check if the difference between this tick and previous tick is larger than a value of your choice then consider the button debounced, otherwise if the difference of this tick and previousTick is not large enough then ...


2

If the datasheet says "Vcc + 0.4V" and Vcc=0V then +0.4V is your maximum safe voltage, until the rails come up. That is according to the datasheet. I would personally try to arrange things so that the situation where the 74xx IC is powered while the uC is not does not happen. As well as damage to the IO ports, weird things like latch up conditions ...


2

This line looks suspect: EXTI->PR |= EXTI_PR_PR13; The user manual tells you to write a '1' bit to clear the interrupt. That line does not quite do what you expect. Why you might ask? The register you read is not the same register you write. This is why doing a read/modify/write is not correct in this situation. the required code is: EXTI->PR = ...


0

As stated already, you can set ODR directly, if you don't need the other bits to keep their current settings. There is another way to set groups of 8 or 16 bits within the ODR register if they are byte or hword (16-bit) aligned. But only on those devices that allow byte or hword access to the register. You could use this: ((uint8_t*)&GPIOB->ODR)[1] = ...


2

I'm hopeful that my answer is useful after about 3 years! This is because of your PCB design, not the code. Most of the microcontrollers, same as STM32F407, only have one USB port that can be configured as the Host or Device. But in the evaluation boards, the Discovery board for example, there are both the Host and Device physical ports. These ports share ...


0

Replace for (int rows = 0; rows < NUM_ROWS; rows++) { if (HAL_GPIO_ReadPin(GPIOD, keyscan_row_io[rows].pin)) key_state [rows * NUM_ROWS + cols] = KEY_DOWN; else key_state [rows * NUM_ROWS + cols] = KEY_UP; } with for (int rows = 0; rows < NUM_ROWS; rows++) { if (...


0

Answer: reduce oscilloscope scale frequency.The signal will build up slowly but retain its shape.


0

The proper way to do this is to use the on-chip hardware peripheral timers of your MCU. That being said, if you for some reason needs a counter like this you should not use signed types. In fact the default primitive data types of C (int, long etc) should never be used in embedded systems - you should be using uintn_t types from stdint.h. Unsigned types in C ...


2

Assuming the goal is protect company intellectual property, STM32F7 and STM32F401re family of product offer distinct level of protection that might work. Readout Protection (RDP) Level 0: No readout protection Level 1: memory readout protection Level 2: chip read out protection Proprietary code Read out Protection (PcROP) PcROP is capable of preventing ...


3

Your plan sounds good to me. The datasheet circuit is drawn like that because it assumes that whatever you're switching with the NPN output is also powered by the same 12-24V input source. This would be the case if the load were a relay coil, for instance. But you don't have to do that, and tying the output to an MCU pin with a pull-up resistor is just fine. ...


5

The GX-H8A has NPN type open-collector output, so it should work exactly as you described. The 10k pull-up can make the signal rise quite slowly, but it should not matter much, I just mention it so you can change to stronger pull-up if it is a problem. If the rise time is not important and the internal weak pull-up of the MCU is enough, you can also try ...


0

I don't know if you can active it by alarm, but you can active WakeUp in CubeMX: (NOTE: The option is not available for STM32F1xx. The picture is for STM32F4xx) Don't forget to also enable the interrupt. OK, now copy and comment these lines in MX_RTC_Init(void): /** Enable the WakeUp */ if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0, ...


0

Some time ago I tested a grayscale jpeg software encoder on a NXP LPC2388 and then on an LPC1778 both running at 48 MHz. The CMOS camera was Omnivision OV7676 (0.3 Megapixel 640×480). I used chrominance samples only, that is Y, because as said I tested a gray scale software encoder. I was able to get a frame rate of 2 fps on LPC2388 an 5 fps on LPC1778. The ...


2

I wonder if a MCU is enough for 2 fps. STM32F7/H7 has a hardware jpeg compression peripheral that only takes 4 ms to compress a 640x480 image. However converting the image from RGB to the required YCbCr format takes ~60 ms at 400 MHz, equating to a total time of ~900 ms for converting 2816x1584. I expect an STM32F4 with encoding done purely in software ...


1

RCC_CFGR is the register that switches the CPU to a different clock. If the MCU stops working after that, there's something wrong with the new clock source. The clock tree diagram in figure 13 (section 5.2) of the STM32F76x reference manual shows the various clock sources. You're configuring the AHB clock, which feeds into the CPU. Here are some things that ...


0

I was able to program the target board by connecting only the data pins and ground. It seems sufficient to simply leave the two Vdd pin unconnected.


1

Did you do a "refresh" before reading the values? when you change the light levels you have to do a relatch of the bank so setting lock byte again to 0xAA as described here


2

The clock configuration for the F412 is significantly more complicated than that for the F411. If you refer to the F12 Reference Manual, page 112, you find Figure 13: Compare that to the F411 Reference Manual, page 93, Figure 12: So there are at least 2 extra bits which need to be correctly configured just to get the 48MHz clock enabled for the USB module. ...


0

I think I solved the problem. I can't say that I did a very big job, but I tried to launch all the DHT functions one after the other, and see if the main loop gets stuck. The code did not crash at any point. Then I slightly changed the functions of DHT sensor, and then the whole sequence of DHT code was like this: uint8_t Rh_byte1, Rh_byte2, Temp_byte1, ...


0

I solved my problem today. I was changing ARR and Prescaler together. But i have seen a guy's comment which was about missing part of changing. So i decided to change all of them at the same time. __HAL_TIM_SET_AUTORELOAD(); __HAL_TIM_SET_PRESCALER(); __HAL_TIM_SET_COMPARE(); When i had done like this. It worked. I hope it will be helpful for anyone who ...


3

The board manual says this : "The SDRAM is selected by SDNE0 and can be addressed from 0xC000 0000 to 0xC0FF FFFF." The reference manual says only banks 4 and 5 support SDRAM, so there can be no SDRAM on bank 1.


4

open ST-LINK utility-> go to Target -> Option Bytes then change the Read Out protection to level 0 Apply, then make a full chip erase. it has worked for me, hope this helps you I found the answer in this link https://community.arm.com/developer/tools-software/tools/f/keil-forum/34824/can-t-disable-read-out-protection


0

I found the problem. There is a define in eeprom.h file for page size. It was: #define PAGE_SIZE ((uint32_t)0x0800) I changed it to : #define PAGE_SIZE 0x400U And everything works without problem


0

Let's say you update ARR as 90 when your CNT register is 95, when do you think the next update/reload happens? Options: when you set ARR check CNT if it's higher than next ARR value.(poor) set CNT to 0 when you are updating ARR.(OK) Enable relevant timer interrupt, update ARR only in timer overflow ISR.(Best in my opinion)


2

STM32F411 has OTG_FS hardware, which has internal pull-ups controlled by the software. Board designs using this uC don't need to provide external ones. I once came across a damaged STM32F407, which somehow got its internal USB pull-up damaged. I had to provide/solder an external pull-up resistor on the board. But this is an extreme situation.


4

I looks as if you misunderstood the EEPROM API (probably due to its poor documentation). Your code modifies the key instead of the value and once the page is full, it will not migrate the correct values to the new page as it only works for a fixed set of keys. Assuming that alarm_counter is in fact the values that you want to increase when the button is ...


3

I want to increase the variable when I push the button and save it to eeprom. What you're doing is incrementing the address (i), so you're writing the value of alarm_counter across a whole page of Flash.


2

It's not just a bandpass filter. It's an antenna tuner, a "transmatch" or Z-match block, which performs the same task as a transformer. (But a resonant transformer, in this case.) It steps signal-voltage up or down, while also connecting a high impedance to a low impedance, to minimize SWR and eliminate reflected energy. (Two coils and a ...


1

What will be the output voltage levels? The first thing to do is choose Vdd, which for most designs is 3.3V (you can choose Vdd to be anything that is within the processors operational ratings in the datasheet) Then you need to figure out what the load current will be on the GPIO of the STM32 (should not be more than 8mA sourcing and 20mA sinking there are ...


1

The right sequence in assembly (for stm32l4) movw r9,#OTG_FS_L movt r9,#OTG_FS_H add r8,r9,#TX_FIFO0_STR ;(TX_FIFO0_STR equ 0x1000) mov32 r1,#(PKTCNT_CNT_1PACK+0x12) ;1pac size 18 str r1,[r9,#OTG_DIEPTSIZ0_B] ldr r1,[r9,#OTG_DIEPCTL0_B] orr r1,#(EPENA|CNAK) str r1,[r9,#OTG_DIEPCTL0_B] ;send prepare mov r1,#0x0112 ;len=18 +dev_id=1 ...


0

I would use either one from the same family used in a reference design or pick a commonly available part (search by quantity available on a distributor like Digikey's website), and then use its characteristics in the formulas provided by STMicroelectronics to check it is appropriate. Budget a few pF for stray capacitance, then measure and tune as necessary.


Top 50 recent answers are included