Questions tagged [c++]

C++ is a compiled general-purpose programming language that adds object-oriented features and other enhancements to the C language, which it is largely a superset of. It is popular for both embedded and PC software development.

Filter by
Sorted by
Tagged with
2 votes
0 answers
65 views

Reading 2 digit 7 segments with ESP32 using TM1650 maybe?

I have been trying to contact a forum member that has done a modification to his pool equipment in order to control it remotely instead of having to go to the box every time and check on the codes. ...
user avatar
  • 645
0 votes
0 answers
30 views

Set brightness of flash lamp/LED with an ESP32

This sketch is to turn on and turn off an LED flash (torch) on board ESP32S camera periodically ...
user avatar
-1 votes
3 answers
84 views

I have an error saying: expected unqualified-id before 'if'

...
user avatar
0 votes
0 answers
19 views

Omron PP02 sensor signal issues

I am using omron PP02 pressure sensor for my sphygmomanometer project. The data sheet is here DataSheet Link, and the user manual is here UserManual Link. I "believe" I have correctly wired ...
user avatar
  • 43
0 votes
1 answer
28 views

vivado HLS or SDsoc for use openCV

I want to do an image processing by openCV on FPGA . But I do not know if I should use the SDsoc method or the vivadoHLS method. The size of the images I am going to process is large and I want to ...
user avatar
  • 1
0 votes
3 answers
67 views

Saltwater Measurement via Arduino

This is a strange question, but I'm trying to learn specific uses for all of the Arduino functionalities. If I were to program the Arduino to spit back the result of analog input into serial as seen ...
user avatar
  • 1
0 votes
0 answers
18 views

Keysight ADS User-Defined Models to AWR/Virtuoso

everyone! In ADS Keysight it is possible to create a model - the so-called User-Defined Model. This is C++ code that describes the Y-matrix of the component. Is there the same possibility in AWR ...
user avatar
1 vote
0 answers
33 views

ESP8266 D1 mini pro/ Arduino IOT, no function is getting called

I coded this: ...
user avatar
3 votes
0 answers
41 views

Is LTC2485 Arduino library missing information?

I'm using LTC2485 and got confused by the provided software code vs. the datasheet. As described in LTC2485 I2C Data Format the LTC2485 ADC is 24 bits + sign ADC so like 25 bits. In the given software ...
user avatar
  • 31
-5 votes
1 answer
102 views

Polling a button and delaying/switching based on the input. Millis? Delay and loop counter? [closed]

So this is the setup: I previously asked a question about this assignment. THIS IS A NEW QUESTION. THIS IS NEW CODE. ONLY THE IMAGES ARE THE SAME. I originally approached this using an interrupt on ...
user avatar
0 votes
2 answers
141 views

Why is my interrupt so slow/inconsistent? Arduino external interrupt as pedestrian crossing button

So this is the setup; It's a traffic light system with 2 road lights and a pedestrian crossing. The normal sequence is alternating between main road green and secondary road green. It reads these ...
user avatar
3 votes
2 answers
251 views

Detecting the push button outside the loop function in Arduino

I'm new to Arduinos. I made a simple digital clock with an Arduino, a 2 x 16 LCD, and two push buttons to control the digits in the clock, one on the digital pin 10 to increase the digits of the ...
user avatar
0 votes
0 answers
356 views

Raspberry Pi Pico: Hardware UART Tx not working

I recently got a raspberry pi pico as an evaluation board for the rp2040. When I tried to use hardware UART, I found that it would not send data. To find out what was going on, I used an LED on the Tx ...
user avatar
-1 votes
1 answer
79 views

How to repeat a task every X ms on STM32F303VCT6 (C++) using timers/interrupts?

My aim is to do the following: 1- Repeat a task every 250ms and when the button is pressed the task is repeated every 500ms, and if the button is pressed again go back to every 250ms. 2- I plan on ...
user avatar
0 votes
0 answers
76 views

ATSAMD21 (arduino) is pulling ports low when calling wire.onRequest()

The intent: Using the controller and I2C for turning a port high and low and querying for data from an agent. The setup: Two Adafruit Itsybitsy M0 Express (ATSAMD21) connected via I2C, 4k7 pullups on ...
user avatar
  • 196
-1 votes
1 answer
99 views

Error: Definition of nested anonymous union in packed "" must be __packed

I'm using the ARM DS-5 with the ARM 5 Compiler Toolchain. I'm attempting to use the "mavlink_types.h" (link: https://github.com/mavlink/c_library_v1). However, I've got an error said that: ...
user avatar
  • 17
0 votes
2 answers
155 views

Embedded C++ save and restore data

I am working on an embedded C++ project. I am dealing with complex and dynamic objects with lots of objects pointing to one another. I need to store and recall these objects to non-volatile memory. In ...
user avatar
0 votes
1 answer
40 views

NVM Region not unlocking on SAML21 Flash memory

I am trying to write to a specific address on my SAMR34 which uses SAML21. However, I noticed that despite first erasing the row te address is located in, the data was not being written. So I checked ...
user avatar
0 votes
2 answers
110 views

How to load an executable program on an STM32F401 without using an online compiler?

I am a newbie to embedded system. I decided to buy an STM32 board to get started. The problem now is that I would like to know if there is a simple way to write some C++ code in a simple text file ...
user avatar
  • 1
0 votes
4 answers
238 views

Handling two interrupts occurring at the same time for different producers

So I have a UART IRQ handler that is fired for each byte sent over UART, which then writes to a Fifo buffer and once the end of the data is detected, a callback is invoked which parses the data and ...
user avatar
  • 37
0 votes
0 answers
89 views

Making sense of an architecture for a FreeRTOS based application

This is more of an architectural design question and any suggestions shall be appreciated. So far, a general idea is that there's a system thread that's like a central task that decides how to ...
user avatar
  • 37
0 votes
0 answers
54 views

Object's members' values change as soon as interrupt is fired

I have a UART class that has instances of Fifo. What I notice is as soon as the UART IRQ handler is fired, the member variables of ...
user avatar
  • 37
0 votes
0 answers
78 views

Interrupt handler starts behaving unexpectedly when scheduler runs

I have an IRQ handler that gets fired upon receiving a character over serial, and everything is fine until I run a FreeRTOS scheduler inside main, and now what I see is IRQ handler still getting ...
user avatar
  • 37
1 vote
0 answers
207 views

How to convert raw ADC value into voltage in volts in software?

Let's say I have a microcontroller with an ADC and my goal is to measure instantaneous values of the line to line voltage of the three phase grid 400 V/50 Hz. I have a voltage instrument transformer ...
user avatar
0 votes
0 answers
54 views

How to create advanced pwm signals with Mbed ? (stm32)

Context: I need to control an h-bridge with pwm on each mosfet with bootstrap. The low side mosfet (L1) needs to close when the high side one (H1) opens. The waveform should look like that: Do I have ...
user avatar
14 votes
2 answers
847 views

Avr-gcc using repeated addition instead of MULU instructions

I recently compiled some C++ code for the ATmega1284P in Atmel Studio and was analyzing the timings of some routines using my scope. To my surprise, a loop I thought I had optimized was taking longer ...
user avatar
  • 836
1 vote
1 answer
88 views

mush instead of signal stm32 nucleo-l053r8

Generating a triangular signal. The "printf" line is commented out. If the "printf" line is uncommented, instead of a signal, mush. How to fix it? (stm32 nucleo-l053r8) ...
user avatar
  • 11
1 vote
1 answer
97 views

My itoa (c++)conversion has a problem

I am receiving a string of data via UART in PIC32, extracting and concatenating two of its bytes, dividing the result by 2, converting the resulting integer to a string and transmitting via i2c to ...
user avatar
  • 151
0 votes
0 answers
36 views

Lora sx1278 implementation by Arduino Uno

I'm implementing a Lora network, with two SX1278 modules and Arduino Uno. Lora is based on three classes. A , B and C, The question is : for change For example A to B, what should exactly change in ...
user avatar
0 votes
3 answers
82 views

How to make sure my motor will not start spinning on power up in case the throttle (POT) was not at a 0 position?

I am trying to make sure my motor which is connected to my controller circuit would not just start spinning when you first apply power to it as if the Potentiometer is left high before the battery is ...
user avatar
0 votes
2 answers
223 views

Raspberry Pico and DHT11 not working C/C++

This is my Wiring here + is connected to 3v3, - to GND and OUT to pin28 I'm using this ...
user avatar
0 votes
0 answers
65 views

PID Control: Is adding a delay before the next loop a good idea?

I am implementing PID control in c++ to make a differential drive robot turn an accurate number of degrees, but I am having many issues. Exiting control loop early due to fast loop runtime If the ...
user avatar
0 votes
0 answers
129 views

How to implement `analogRead` (Arduino) on AVR?

I'm trying to implement Pin class in C++ with digitalRead, digitalWrite, ...
user avatar
0 votes
1 answer
92 views

Error Real Time Clock implementation AVR microcontroller

I want to create a real-time clock using ATmega328p microcontroller. The microcontroller's frequency is 1 MHz. So, I think I should use timer interrupts in CTC mode to generate interrupt every second. ...
user avatar
1 vote
1 answer
147 views

C++ AVR big code size & excess unused symbols in build file

I'm developing the program for the AVR microcontroller in C++. I have created a class that contains 8 methods(with constructors) but used only 3. Class code: ...
user avatar
4 votes
2 answers
1k views

Why use const variables instead of preprocessor directives when programming embedded with C++

I read on here that when programming with C++, const variables are better than preprocessor directives, ie #define, for declaring constants. I'm confused about why that is the case. I understand that ...
user avatar
  • 53
2 votes
1 answer
140 views

C++ AVR microcontroller optimization problem

I'm faced with a weird problem. I'm developing a program for AVR. Microcontroller ATtiny85. Frequency 1 MHz. Programmer ...
user avatar
  • 21
0 votes
2 answers
54 views

problem facing in running the three function in arduino

I am making and Arduino program for a 3 phase inverter. I have designed 3 functions for each individual phase. In 3 phase, the 2nd phase has to start at 120 degree with respect to first phase and ...
user avatar
1 vote
0 answers
159 views

SIM7020G nb-iot module interface with esp32

My code at the moment is to connect esp32 to MQTT server via wifi and its working completely fine. The next step is to use sim7020G NB-IOT module to achieve the same connection but as I have never ...
user avatar
  • 21
0 votes
0 answers
33 views

Wierd LSM303DLHC magnetometer output

I'm kind of new to electronic and recently bought a Adafruit 9DOF Sensor. I use it with a Raspberry Pi Zero connected through I²C and when I try to read the Z-axis magnetic field data of the ...
user avatar
  • 1
0 votes
0 answers
92 views

How can I get SPI SCK line to idle low without wasting current with a pulldown resistor?

I am using the STM32L475 MCU and am using SPI to communicate with an SD card. When I configure the SPI SCK GPIO pin, I configure it as Alternate Function SPI in PushPull mode. I set the ClockPolarity ...
user avatar
1 vote
0 answers
91 views

UART Issues with MCP39F511

I've been trying to debug a UART communication issue on a custom design based on ADM00667 development board where there are only a few minor changes. I have the dev kit hooked up to an nRF52840 BLT ...
user avatar
  • 68
1 vote
0 answers
258 views

Which library to use for FT232H, libMPSSE vs libFTDI or something else?

I have an FT232H chip, which supports a max SPI speed of 30 Mhz, I am interested in writing a library which uses the maximum speed of FT232H. And control 4-5 GPIO pins at the same time. I have come ...
user avatar
2 votes
1 answer
127 views

How to make more precise a CNC?

I have a problem with precision for my CNC machine, when I try to draw a diagonal line on paper. I use 3 unipolar stepper motors (RS 440-442) for 3 axis (x,y,z.) These 3 motors are controlled ...
user avatar
  • 23
1 vote
1 answer
73 views

How do I give several classes access to the single RTC on my MCU

I'm writing my first large-ish C++ embedded program on a STM32F413. I've become a reasonably firm believer in object oriented coding but am not particularly knowledgeable. The STM32F413 has one RTC ...
user avatar
  • 13
1 vote
1 answer
217 views

How to turn on and off LED when ESP32 board reach specific internal temperature threshold?

I'm a beginner and I'm working on a project to turn on and off an LED using a phone app. I'm using DOIT ESP32 Devkit V1 which I control via Wifi using Blynk app, jumpres and LED. at first I wrote a ...
user avatar
2 votes
2 answers
380 views

Interrupts using member function

I am trying to use a member function in an interrupt. The function uses member variables so I created a global instance of that class to use it in a static function. The problem is that I created a ...
user avatar
  • 23
0 votes
0 answers
1k views

reading data stream from usb bulk endpoint using libusb

I’m writing a program to read and write data to a usb device. Right now I don’t have the device so I’m using a loop board just to write the software. When I’ll get the actual device I will need to ...
user avatar
0 votes
0 answers
147 views

Modifying Option Bytes at compile time

I need to modify the option bytes at compile time for STM32L0xx controller and generate the binaries i.e. .hex, .bin. could you please suggest a solution for the same. I amusing STM32Cube IDE for ...
user avatar
-1 votes
1 answer
162 views

Serial Communication between two Arduino not working

I'm trying to perform a simple communication sending two strings in two char arrays from an Arduino Uno to another one. My problem is that after the 5th or 6th iteration the two strings will mix. ...
user avatar
  • 145