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
0 votes
0 answers
20 views

ESP32-C3-DevKitM-1 SPI Master Arduino IDE

I've been using the ESP-IDE documentation to write an SPI driver inside the Arduino IDE for the ESP32-C3-DevKitM-1. I'm trying to use custom pins, and I have written the following code. Once compiled ...
0 votes
0 answers
22 views

After 503/504 error W5500 can't connect to client

I am using a Raspberry Pi Pico and a W5500 with the Arduino IDE. Everything works fine, I can use POST and GET requests easily, but when the server is down or something happens, HTTP GET and POST ...
7 votes
1 answer
495 views

Program never goes into interrupt

I used to work with C but I am trying to learn using C++ for embedded programming. I want to do a basic GPIO interrupt example to understand the structure of a class and its usage. My microcontroller ...
  • 187
4 votes
2 answers
643 views

Embedded C++ and multiple copies of same structure

In embedded programming it is my understanding that we do not use dynamic memory allocation since we are working with a fixed-resources system and the code needs to be compiled for worst case memory ...
0 votes
1 answer
32 views

How to code process_state variable which reruns each time process commences?

I am making a bottle filling machine. I am using the YF-S201 water flow sensor to do the same and a 600ltr/min pump. While according to the sensor datasheet I should get the 750ml at 369 pulses, but ...
  • 127
-2 votes
2 answers
103 views

Drivers in C++ produces bigger assembly [closed]

I'm trying to figure out whether C++ is a suitable language for use in device drivers, like peripherals on Cortex-M3/M4. I started writing some drivers for GPIO and I noticed that it produces bigger ...
1 vote
4 answers
113 views

How to make water flow sensor work to measure flowed water and not flow rate

I am using the YF-S201 water flow sensor. I am using this to fill up bottles. I need to know how to alter the below code in a way that instead of measuring flow rate it measures water passed through. <...
  • 127
7 votes
2 answers
2k views

What does a function mean that doesn't have "void", "int", etc in front of it mean?

I am following a programming build in Arduino and I came across this code here: ...
  • 568
2 votes
0 answers
116 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. ...
  • 645
0 votes
0 answers
178 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 ...
-1 votes
3 answers
562 views

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

...
's user avatar
0 votes
1 answer
39 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 ...
  • 1
0 votes
3 answers
90 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 ...
  • 1
0 votes
0 answers
39 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 ...
1 vote
0 answers
49 views

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

I coded this: ...
3 votes
0 answers
50 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 ...
  • 31
-5 votes
1 answer
158 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 ...
0 votes
2 answers
172 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 ...
3 votes
2 answers
290 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 ...
0 votes
0 answers
729 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 ...
-1 votes
1 answer
204 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 ...
0 votes
0 answers
85 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 ...
  • 196
-1 votes
1 answer
146 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: ...
  • 17
0 votes
2 answers
196 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 ...
0 votes
1 answer
59 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 ...
0 votes
2 answers
157 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 ...
  • 1
0 votes
4 answers
304 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 ...
  • 37
0 votes
0 answers
90 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 ...
  • 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 ...
  • 37
0 votes
0 answers
100 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 ...
  • 37
1 vote
0 answers
253 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 ...
14 votes
2 answers
867 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 ...
  • 836
1 vote
1 answer
89 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) ...
  • 11
1 vote
1 answer
102 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 ...
  • 151
0 votes
0 answers
42 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 ...
0 votes
3 answers
84 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 ...
0 votes
2 answers
330 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 ...
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 ...
0 votes
0 answers
160 views

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

I'm trying to implement Pin class in C++ with digitalRead, digitalWrite, ...
0 votes
1 answer
110 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. ...
1 vote
1 answer
179 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: ...
4 votes
2 answers
2k 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 ...
  • 153
2 votes
1 answer
165 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 ...
  • 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 ...
1 vote
0 answers
247 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 ...
  • 21
0 votes
0 answers
44 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 ...
  • 1
0 votes
0 answers
143 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 ...
1 vote
0 answers
106 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 ...
  • 78
1 vote
0 answers
312 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 ...
2 votes
1 answer
143 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 ...
  • 23

1
2 3 4 5