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
0answers
33 views

RF ASK library for RENESAS ( in C language)

I am planning to switch from atmega328P to Renesas in one of my project. For Renesas I have been provided with CS+ software for compiling and uploading code. And I have to write code in C language. My ...
-1
votes
4answers
176 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 ...
0
votes
0answers
71 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 ...
0
votes
0answers
48 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 ...
0
votes
0answers
55 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 ...
1
vote
0answers
104 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 ...
0
votes
0answers
24 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 ...
0
votes
0answers
64 views

How to convert c project to cpp in Keil 5?

I am currently working on an IMU project with C in keil. But it needs Kalman filter source file. The file is in .cpp format. This filter has classes, which are not supported in C. How to convert all ...
14
votes
2answers
775 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 ...
1
vote
1answer
84 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) ...
1
vote
1answer
85 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 ...
0
votes
0answers
26 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
3answers
69 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
2answers
101 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
0answers
46 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
0answers
54 views

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

I'm trying to implement Pin class in C++ with digitalRead, digitalWrite, ...
0
votes
1answer
39 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
1answer
87 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: ...
3
votes
2answers
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 ...
2
votes
1answer
103 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 ...
0
votes
2answers
52 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 ...
0
votes
0answers
76 views

Modifying library for the WSSFM10 Sigfox module for compatibility with STM32L476RG

Arduino IDE version 1.8.13 installed. Selected options: Board: "Nucleo-64" Board part number: "Nucleo L476RG" U(S)ART support: "Enabled (generic 'Serial')" USB support (...
1
vote
0answers
49 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 ...
0
votes
0answers
28 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 ...
0
votes
0answers
66 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
0answers
51 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 ...
1
vote
0answers
140 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 ...
1
vote
1answer
109 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 ...
1
vote
1answer
60 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 ...
0
votes
0answers
72 views

Using Telegram bot to get messages from esp32 board

I'm working on a project to light an LED using my phone. I use DOIT ESP32 devkit V1 which is connected to an LED and is controlled by Blynk app via Wifi. I'm trying to write telegram bot which will ...
0
votes
0answers
50 views

Create a log file using Blynk server

I'm working on a project to turn on and off an LED using my phone (android OS). I use DOIT ESP32 devkit V1 board hich is connected to an LED and is controlled by Blynk app via Wifi. I want to ...
1
vote
1answer
107 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 ...
2
votes
2answers
159 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 ...
0
votes
0answers
718 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 ...
0
votes
0answers
58 views

find the amplitude and phase of the signal

How to write a code to compare the amplitude and phase of these three signal through Arduino?
0
votes
0answers
77 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 ...
-1
votes
1answer
116 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. ...
1
vote
2answers
283 views

RFID reader(125kHz) switching between antennas

My arduino application wants multiple separate cards in multiple separate (nearby) locations to be readable at roughly the same time. I am using a RDM6300 module, with a multiplexer to switch between ...
0
votes
3answers
100 views

Binary Manipulation in arduino with 74HC595

I'm doing practice of bit manipulation in arduino with a 74HC595 shift register. I would like to create an algorithm that allows the binary digit to perform this way: 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 ...
0
votes
1answer
561 views

Arduino RFID Multiplexer Antennas

I want to make a electronic chessboard that detects the position of every piece on the chessboard. Every chess piece will have RFID tag. My idea will be to have 2 multiplexers(1*8) one for the rows ...
0
votes
0answers
34 views

Will the following ATSAMD21 series code properly configure SysTick interrupt?

I haven't seen any examples of registering ISRs in Atmel Studio 7, but I've given the following code a go in my IDE. ...
0
votes
1answer
39 views

GSM SIM900 isn't communicating with the Arduino

When I connect my GSM SIM900 module to the Arduino and insert a SIM card, the Netlight and Status light blink for few seconds and then it stops. I am using 5V 1A to power the GSM and pins D7 and D8 ...
0
votes
1answer
396 views

How to implement 32-bit adder logic using two 16-bit adders?

I've been trying to implement a 32-bit adder by instantiating two 16-bit adders. The code is compiling but failing some test cases. I don't know what is going wrong in this. verilog code ...
0
votes
2answers
153 views

PLC Replacement with C++ Embedded System or Application Specific Circuit

I work for a company that uses PLCs in their products, but lately, we have thought about doing away with our PLCs for application-specific circuits, FPGAs, or some other type of system on a chip that ...
0
votes
1answer
101 views

Problems with mbed LPC1768 double precision

I have a motion profile generator which calculates a position 1000/sec. During the decelerating portion of the move, the following calculation is used: ...
0
votes
2answers
80 views

NTP Time calculating

I have this code and i use in my device. ...
2
votes
3answers
261 views

Meaning of (*(__IO uint16_t*)PAGE0_BASE_ADDRESS) variable declaration

There is a variable declaration: uint16_t status = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS); __IO is the precompiler directive ...
6
votes
9answers
3k views

What is the simplest instruction set that has a C++/C compiler to write an emulator for? [closed]

I'm looking into writing a little software emulator that emulates/runs instructions. The easiest would be to invent my own instruction set, but I thought it would be more fun if I write an emulator ...
9
votes
6answers
2k views

Concept of the static keyword from the perspective of embedded C

static volatile unsigned char PORTB @ 0x06; This is a line of code in a PIC microcontroller header file. The @ operator is ...
6
votes
1answer
1k views

STM32 crashes when FreeRTOS project is converted to C++

I am experimenting with STM32F303RE Nucleo board on SW4STM32 with FreeRTOS v10.1.1 and I was thinking of parsing NMEA sentences by adding the characters to a buffer using UART interrupt and then ...