Questions tagged [c]

C is an imperative (procedural) systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language. from http://en.wikipedia.org/wiki/C_(programming_language)

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

NFC communication - CR95HF over 15693 and 14443-A

CR95HF datasheet: https://www.st.com/resource/en/datasheet/cr95hf.pdf Demo board: https://docs.rs-online.com/562c/0900766b811c6bc2.pdf C/C++ library and guide for demo board: https://www.st.com/...
0
votes
0answers
27 views

millis() function for PSoC4

I'm replicating the function of millis() for the PSoC4 in order to store the timestamp of a signal's maximum amplitude. For this, I'm using a timer with a 1kHz to feed the "count" terminal ...
0
votes
0answers
58 views

Convert decimal fraction to binary number

I have this code that works for me to convert a double into a binary representation, I want to know how to convert the Fractional Part if it were separately. Example Function Prototype would be: ...
1
vote
1answer
58 views

Dali Light Addressing: How to?

As I am trying to create a program that addresses the various luminaires, I wanted to know better theoretically not the commands to give, but why I am giving that specific command. I've searched for a ...
1
vote
1answer
80 views

STM32, mass storage device. how to properly erase memory sectors?

I want to organize a USB stick based on STM32F105RBT + AT45DB041. Problem: after reconnecting the device to a PC, windows7 asks to format the disk. Problem identification algorithm: Connect to PC ...
2
votes
0answers
22 views

STM32 DAC Setup Issues

I am using the STM32F3 Discovery development board which has an STM32F303VCT6 mcu. I am also using the STM32CubeIDE. I am trying to set up the DAC to perform one-off digital to analog conversions when ...
0
votes
0answers
49 views

STM32 CAN Interrupt causes program to jump in infinite loop

Struggling with this issue for days now and can't find a solution. Maybe someone saw something like this before and can give me a hint. I have FreeRTOS running on an STM32L4 with different tasks. One ...
2
votes
0answers
35 views

ADC Overrun with Multimode, Scan and timer-triggered configuration

I'm using the STM32F446VE with 3 ADCs. I have a 50 kHz PWM running and want 2 of the ADCs to measure 2 Channels synchronized with the 50 kHz PWM. To achive this I used the regular simultanuous dual ...
0
votes
1answer
43 views

Why RXD text are uncomplete in atmega328 intrupt driven USART?

I have an Atmega328p MCU which is connected to USB port by ch340 chip and I've connected it to GSM module by hardware RX/TX/GND pins. I don't send any command to USB port all commands are send by ...
1
vote
1answer
62 views

Pic18F14K22 doesn't want to work with bluetooth

I'm currently working on a project that allows you control LEDs with bluetooth. I'm using an HC-05 bluetooth module. I got some code from the DeepBlue.com site where they explained the use of ...
1
vote
2answers
82 views

Reading PWM Signal with MCU

I'm trying to read a PWM Signal. I thought I could use a Voltage Divider and a ADC on MCU to "read" the PWM Input. My PWM Signal is a 12V (13.8V Car Board Net) 100Hz Signal with a Duty of 90%...
1
vote
2answers
101 views

Blue Screen of Death for Beginners Learning C? [closed]

Someone I know wants to learn C, but run their own programs and exercises on a PC. Which is all well and good until we get to pointers. Is there a significant chance of them damaging the PC or ...
1
vote
2answers
101 views

stm32 create a microsecond timer

I'm relatively new to stm32 stuff and i wanna get data from some rotary encoder, and i'm using interrupts to do so, i'm using a usb cable to send data from MCU(stm32f103c8t6) to my pc device and i ...
1
vote
1answer
35 views

Capacitive medium range sensor with STM8

I am trying to replicate the behaviour of this library: https://playground.arduino.cc/Main/CapacitiveSensor/ with an STM8, but I am not able to do it. I want to detect the proximity of the human hand ...
2
votes
2answers
76 views

PIC MCU: XC8 Not treating TMR0 as a 16 Bit Register

I recently finished a project programming a PIC18F2620. All was good, but I decided to explore the new stuff Microchip has to offer, and am now trying out the PIC18F47Q43. I'm getting a strange ...
2
votes
1answer
64 views

IEEE-754 Floating Point Converter

I have in hexadecimal representation a IEEE-754 Floating Point: uint32_t _u_IEEE_754 = 0x41100000; //9.0 The decimal representation is: 9.0 I am working in C under ...
0
votes
3answers
102 views

Optimization kills the switch statement that I need to use in a function

Optimization kills the switch statement that I need to use in a function Hi all, how are you?. I'm doing a project with a STM32F103C6 (it has 32KB flash) and I had to activate optimization options to ...
-2
votes
1answer
84 views

( Sprintf ) pros and cons, embedded design [closed]

What are the negatives aspects of using sprintf in embedded environments? I'd like to hear opinions and/or experiences on this. I have heard and read people recommending avoiding the constant use of ...
4
votes
5answers
2k views

Thread alternatives for embedded systems

I'm currently studying electrical engineering. Due to the pandemics, my classes were suspended and I'm using this time learning more about electronics and programming. I'm currently trying to use a <...
0
votes
0answers
49 views

How to receive data via SPI Interface with No Master Command but Multiple Slave Commands?

I am using STM32f401rct6 microcontroller - master (No Commands) and LTC6811 battery Monitoring IC- Slave (Multiple Commands) I have developed full firmware perfectly including drivers. But i have a ...
0
votes
0answers
38 views

STM32F100RBT6 basic initialization code does not work

I have been currently working with the HAL libraries but I got fed up with it and want to access registers and make better use of the uC itself. So, I have a code that should blink a LED and I have ...
0
votes
2answers
62 views

Compare register value using logical AND (&) and ==

...
0
votes
1answer
59 views

Configure SPI Slave to handle data coming at the wrong time

I am experimenting with the SPI protocol (fast speeds where 5 bytes of data is transferred in slightly less than 500us) on the STM32F410 configured as a SPI full duplex slave. A master device sends a ...
0
votes
2answers
60 views

Dealing with the “overflow” of data in a ring buffer

So I have a ring buffer that's used inside the USART's ISR to stores the user input and upon receiving \r, it calls the application callback where I parse the ...
0
votes
5answers
135 views

PIC processors - assembly vs. C?

I have heard that earlier PICs that are quite tiny are to be programmed using assembly and not C. Later PICs had hardware instructions to make them easy to be programmed via C language. However, I am ...
0
votes
1answer
56 views

What is the value present at the first address of flash memory of stm32 for every firmware?

Every firmware of Stm32 microcontrollers, the first value is starting with 0x2XXXXXXX, while working with custom bootloaders, I found that this is an address on SRAM, 1)What is actually present at ...
0
votes
2answers
53 views

Recieving and processsing array of data on STM32

I am trying to use RealTerm to send a .txt file containing a 10X10 array of data to my STM32 NUCLEO board using UART. So far I have been using HAL_UART_Receive_DMA and I have been able to store simple ...
0
votes
1answer
56 views

Estimating SOC using coulomb counting with DSP

I am trying to estimate the SOC of a battery using the Coulomb Counting technique. I am implementing the following equation on a DSP inside PSIM: $$ SOC[K] = SOC[K-1] - \frac{I_{Bat}}{Q_{Bat}}\cdot{Ts}...
0
votes
1answer
66 views

How to initialize a 16x2 I2C LCD in 4-bit mode with an STM32 MCU?

As part of an alarm clock project, I am trying to interface a 16x2 I2C LCD with an STM32F103RB microcontroller. The LCD uses an I2C backpack and only utilizes D7-D4 meaning 4-bit mode must be used. ...
0
votes
1answer
92 views

Switch on an esp8266 with a npn transistor (2n2222A)

this is my first question here, so I would like to ask you to kindly point out my mistakes regarding the question instead of just pressing the down arrow. That way I will have the opportunity to ...
0
votes
0answers
76 views

Running two threads at the same time is causing a hardfault

So i'm learning FreeRTOS on STM32 and currently following a tutorial to get things started. Following are my concerns with the first one being the most: I have two threads, but upon running a ...
1
vote
2answers
65 views

Context Switch in C in 32-Bit MCU

I am trying to understand the concept of 'Context switch' in reference to C-language and 32-bit MCUs. For example if I am programming STM32F407 MCU in C-language using STM32CubeIDE and I want to ...
0
votes
0answers
43 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 ...
2
votes
0answers
128 views

STM32 HAL_ADC_Start() ends with HAL_ERROR

I'm new to microcontroller programming and I have a problem I can't solve. I am using STM32 Nucleo board L4R5ZI and I try to read the analog value on one of the pins, and then use the ADC to convert ...
0
votes
1answer
40 views

Bug and Best Practices for Interrupt Handling/Organization

I've read a few documents on best practices for interrupt handling and thought I was doing things correctly, ensuring the variable set in the ISR was declared volatile. In my code the interrupt ...
0
votes
1answer
73 views

How to implement C language driver for SPI peripheral [closed]

I have been implementing device driver for the SPI peripheral of the MCU in C language. I would like to exploit interrupt mechanism for reception and also for transmission. As far as the reception ...
0
votes
1answer
78 views

Getting unexpected I2C Slave Address from a LSM9DS1 sensor and reading the wrong data from the register I just wrote in

I am using a STM32F030R8 nucleo board and a LSM9DS1 sensor. I'm just starting out learning about this stuff and I am having troubles reading from the sensor. Here are all the details about the problem ...
0
votes
1answer
120 views

Problem in c language [closed]

I need a and b value. a=2; b=a+=++a; a+=-b; Solution is: a=0 b=6 Why is this the ...
0
votes
0answers
35 views

How to increase polling speed of data from external ADC (controller and ADC has SPI interface) without any external interrupt?

I have an an external ADC which has capability to sample data at 40Ksps and controller needs to poll the data from ADC. I am unable to get enough sampling rate by keepon calling it from while(1) loop (...
6
votes
1answer
1k views

How to get rid of shift and logical operations

I am trying to upgrade an old firmware of a 32-bit MCU. The fw has many macros in it which uses various operations eg., logical shift etc. I want to replace these shift and logical operations. An ...
0
votes
0answers
22 views

How can I reset/stop a PWM timer using STM32F4 board

Hi I'm working with the STM32F4 board trying to make a servomotor do two movements (one side and the other). This is my code so far: ...
1
vote
0answers
35 views

How to use ATMega USART in synchronous mode using XCK pin

I'm working on a project with ATMega64 and I have a problem with one of the USART interfaces which is going to work in synchronous mode. when trying to send a test data like: ...
1
vote
0answers
40 views

Is my design for data reading over an I2C bus and writing back to UART good enough?

So I implemented drivers for I2C and USART using interrupts with some guidelines online, and was wondering if I can get some suggestions from a design point of view even though the code works (tried ...
0
votes
1answer
31 views

TIVA TM4C123G Driverlib Function Question

I have a question about how to use a basic GPIO function from the TIVA driver library to set an output pin high. See the below image for more detail. The red underline on the code on the left hand ...
0
votes
1answer
58 views

TM4C123 Header File Problem

I'm having trouble getting a simple blinky project working using the on-board LED's on the TIVA TM4C123G evaluation board. I am using the header files from the driver libraries so I don't have to ...
0
votes
1answer
58 views

Approach to prevent Replay and spoofing attack on CAN protocol

I want to make an authentication system between 2 buses. In order to achieve that I use counter to avoid replay and hash to avoid spoof. The message must be sent in two phases. Is there any proper way ...
0
votes
1answer
26 views

Decoupling setting of specific bits (transfer mode, stream, channel) from the generic DMA_Init() function

So with regards to DMA drivers, what's the approach for configuring certain bits generic inside a function which could be reused for both TX and RX calls which would require different stream parameter ...
0
votes
1answer
35 views

STM32 Nucleo board, SD card displaying symbols instead of numbers

Devices: STM32F4 The SD is working and the data is saving on the SD, but the problem is that the integers are displayed as symbols in this SD. So I think that the problem is that the function I used ...
3
votes
0answers
89 views

Is my IIR implementation (in C) correct for this difference equation?

I recently started developing a digital regulator for a DCM boost (Digital regulator for DCM Boost - How does it relate to duty cycle?) And I've implemented the difference the following controller in ...
1
vote
0answers
38 views

Compiler settings to code in C with Proteus

I have made a circuit for a game called catch the light on Proteus. I have a C code for that. But I don't know how to set compilers and all that. I tried to add source code but due to some compiler ...

1
2 3 4 5
28