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
2 votes
2 answers
46 views

Keil uVision Disassembly Window with ARM Microcontroller

I have a couple of probably simple questions for you all regarding disassembly from C code to assembly code. I am using Keil uVision as a programmer and debugger with a TIVA TM4C123GXL microcontroller ...
  • 1,154
1 vote
3 answers
198 views

Best way to interact with MPU

For the simplicity of the problem let's assume I'm using an Arduino. If, for example, I have this code: ...
  • 129
1 vote
1 answer
57 views

Retry function - I2C hung state handling PIC XC8

This may be a very borderline Stack Overflow question, but I decided to post here because I'm dealing with the I2C protocol for a PIC MCU in XC8. I'm learning how to talk with devices over I2C and it'...
  • 584
3 votes
3 answers
201 views

Raspberry Pi not reading rotary encoder accurately

I wish to write a program for my Raspberry pi that will print > when a rotary encoder is rotated clockwise and < when its ...
2 votes
1 answer
148 views

How to use a variable delay in Microchip PIC microcontroller (MPLAB X), without using floating point arithmetic?

I'm using a PIC10F220. For some reason, this delay works perfectly fine: __delay_ms(10); But, when I try to run a delay with a variable, it gets an error. This ...
  • 53
1 vote
1 answer
74 views

SD FIFO has no data available when mounting with FATFS

Issue I'm attempting to mount an SD card to my STM32F407 with Elm Chan's FATFS using SDIO and f_mount returns FR_DISK_ERR. The ...
  • 155
0 votes
2 answers
109 views

String array display on LCD using PIC MCU

I want to display certain messages on an LCD using a PIC MCU (16F887) and mikroC PRO for programming. I have stored the words in a 2D string array like in the following program: ...
0 votes
0 answers
17 views

Smartfusion2 soft CoreGPIO not working

I am having trouble getting the Digikey MKR board with a Smartfusion M2S010 soft CoreGPIO to run. I am using Libero SoC 2022.1 and Softconsole 2021.3. Softconsole has all its settings set as per the ...
2 votes
1 answer
118 views

Strange PORTA behaviour when using bitwise XOR in PIC microcontroller

I am trying to blink an LED using one of the PIC16F15214's timers and I have noticed a strange behaviour. I have started the project following the PIC1000 (TB3261) guidelines for writing C code and I ...
  • 21
0 votes
2 answers
72 views

PIC16F1517 timer0 does not work

I am trying to use Timer0 to control a blinking LED, but I am having some difficulties... the LED never turns on. I referred to this tutorial to set things up, but I still can't understand it, could ...
0 votes
1 answer
84 views

Alarm gets instantly fired on a Raspberry RP2040

I'm writing a program to manage the velocity of a motor that is remotely controlled. For security reasons, I want to stop the motor after one second after it receives a command if it doesn't receive ...
  • 135
0 votes
0 answers
46 views

Writing multiple buffers in ping pong mode tiva c

I'm trying to send multiple buffers each of 1k on EPI interface using uDMA on Tiva. I can send now two buffers in ping pong mode, but not sure where should I do the swapping between the buffers to ...
  • 177
0 votes
1 answer
61 views

ADXL355 Axes Overflowing

I am using an ADXL355 accelerometer on an ADXL355Z evaluation board and an RPI Zero W communicating over SPI, with datasheet here. I previously had it producing stable g values (with other issues as ...
4 votes
2 answers
178 views

STM32 applications hardfault after jumping from the bootloader

I am attempting to write a custom bootloader for a STM32F103C8Tx (64k Flash, 20k RAM variant) on a bluepill board. When the jump from the bootloader occurs the application immediately hardfaults on ...
  • 43
4 votes
1 answer
792 views

STM32 C function "strstr()" not working

I am trying to use an STM32 microcontroller (STM32L010C6T6 to be exact) to parse NMEA sentences from a GPS module over UART. I receive the messages fine, but run into issues when I look for specific ...
  • 179
0 votes
1 answer
79 views

Display all three colors (red/black/white) on an electronic paper display

I have been trying to drive a 2.13in electronic paper display (EPD) with an Adafruit nRF52 Bluefruit using the SSD1680 driver. I converted the image to C-code using an online image-to-C-code converter....
2 votes
2 answers
62 views

STM32 SD mounting returns error with SDIO

Overview I'm using a STM32F407ZGT6 and I'm currently trying to mount SD cards (MicroSD 32GB HCI and 256GB XCI picture) to the board using the FATFS library bare-metal. To handle low level I/O, I'm ...
  • 155
2 votes
0 answers
119 views

Which instructions do I use to be able to use UART directly on my STM32F107 microcontroller?

I've tried to figure this out on my own but after almost a week I'm still at more or less the same place where I started. So, I have an STM32F107 microcontroller on a board, which is linked to another ...
  • 31
2 votes
1 answer
86 views

Custom Memory Allocator - How to find the required alignment for a platform?

I'm building a portable arena allocator for embedded systems. Like for malloc, one of the requirements is to return a pointer aligned with the memory. The question ...
  • 591
2 votes
1 answer
95 views

I2C read() lost 1 bit

I try to use I2C to read data from ADS1110, the address of ADS1110 is seven bits, which is 1001 000. Writing data can only change the configuration register, which ...
-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
1 answer
65 views

Noise reduction algorithm for an AC mains voltage measurement

I am measuring and displaying the mains voltage at six inputs with a 12-bit ADC. To make the calculation simple and fast I am only using 11 bits. I am sampling the 50 Hz sine wave at 20 points using a ...
3 votes
1 answer
111 views

Confusion with variable update in microcontroller programming

I use an STM32 microcontroller board and to summarize the question, in the following code inside the if clause the variable called ...
  • 3,510
-1 votes
1 answer
41 views

Problem with the output of the engine control signal

Program to control three DC motor levels and display speed (RPM) on a 7-segment LED using 8051. Use external interrupt 0 to read pulse from encoder. When compiling on keil C there is no error, but ...
  • 13
1 vote
2 answers
90 views

Keil C & 8051: DC Motor Speed Control & Display [closed]

I am writing a program to control three DC motor levels and display speed (RPM) on a 7-segment LED display using an 8051. I use an external interrupt to read pulse from encoder. When compiling, the ...
  • 13
4 votes
4 answers
225 views

Would writing to same flash address reduce lifespan of MCU

I am using an STM8 microcontroller. Since the vector table is in flash memory, I need to write to flash memory in order to create and use the vector table. Since addresses of vector tables are fixed, ...
0 votes
2 answers
53 views

How to handle metastable input using a microcontroller? [closed]

I have a metastability problem and I want to know how to best handle it using the C language. The problem I have two GPIOs that define the state of my system. Because of the conditioning circuit, they ...
  • 591
-2 votes
1 answer
58 views

Why should I use printf for function works fine

I am trying to use Raspberry Pi Pico with C. I am taking data from RFID and trying to get decimal value from byte. I can take decimal value but I have a problem. I need to read 14 character from RFID, ...
2 votes
1 answer
134 views

What does LSB mean in PWM?

I have this PWM exam preparation question in Computer Engineering where it says "What is one V_LSB?". However we've discussed nothing about LSB in the PWM section. What does it means?
1 vote
1 answer
118 views

Simple AVR interrupts in C - How to cleanly stop and restart "INT0"?

I'm trying to use an ATTiny84's INT0 pin to detect a falling edge event on a 1 kHz signal. What is the correct way to temporarily halt this interrupt INT0, and then resuming it at a later time, ...
0 votes
2 answers
72 views

Why my timer1 not working?

My purpose is to measure phase angle between 2 square wave as below(yellow represent voltage ZCD and blue represent current ZCD passing through ACS712 hall effect current sensor) Below is my circuit ...
  • 607
0 votes
1 answer
50 views

Does interrupt service routine in PIC16F877A work with other self-defined variables?

On internet can seen countless simple example like the one below void __interrupt() isr() { if(TMR1IF) {Do something} } But does it work on self-defined ...
  • 607
1 vote
2 answers
107 views

Cannot configure timer to 10µs on STM32F401 device

I'm using an STM32F401CCU6 microcontroller and am trying to generate a timer interrupt of 10 us with TIMER3. The timer is a update event timer. The formula I'm using is: ...
0 votes
1 answer
73 views

Does the frequency of APB1 on stm32f4 have to stay at 42 MHz?

I'm trying to configure the clock of my stm32 board. And I'm wondering if I always have to make the SYSCLK 168 MHz and APB1 42 MHz. If the APB1 is not 42 MHz, I get a weird result when using uart. I ...
6 votes
2 answers
2k views

Problems casting a uint8_t array to a struct

I'm having problems casting an array of uint8_t to a struct in C using a Silicon Labs MCU (EFM32GG11B120F2048GQ64). The byte array is the received data from a UART, and I want to cast it to a struct ...
  • 197
3 votes
1 answer
84 views

How to determine phase sequence of the unbalanced three phase grid?

Let's say I have three phase voltage grid which is unbalanced (three phase utility grid). The phase voltages are sampled by the adc (suppose that the analog channel is properly designed from the hw ...
  • 885
1 vote
2 answers
108 views

How to decompose the three phase unbalanced grid into the symmetrical components?

Let's I have three phase voltage grid which is unbalanced. The phase voltages are sampled by the adc and I would like to determine in the C language software the positive sequence, negative sequence ...
  • 885
0 votes
0 answers
101 views

Blocking Task when calling vTaskDelay

I'm running some tasks in esp32, my problem is when im calling vTaskDelay() from a task, an other task start executing, wich is something i dont want, so how to make vTaskDelay() a blocking function ...
2 votes
0 answers
104 views

STM32F107 CAN software driver does not work

I am using ST drivers to use CAN bus on an STM22F107 according to the code below. It does not work. The code is as below and is available here. ...
  • 113
0 votes
1 answer
95 views

Sequence on MSP430 C code skipping certain flags [closed]

I am developing some code for the MSP-EXP430FR5994, specifically code using the MSP430's ADC. My plan for the ADC is to run a dual-channel ADC capture. However, I have only been able to run the code ...
0 votes
1 answer
54 views

MSP430 ADC, using a different memory slot other than MEM0

I'm working with the MSP430Ware Sample Code for a basic ADC on the MSP-EXP430FR5994 development board. On the code, it uses MEM0 and the supporting infrastructure such as flag 0 to convert. The one ...
0 votes
1 answer
514 views

Control LEDs with 74HC595 shift register through SPI

I'm currently working on a project for which I need to control 16 white LEDs with two shift registers 74HC595 in cascade. I work on a ...
  • 11
2 votes
1 answer
112 views

What is the proper way to handle a status led when HardFault_Handler or any error is raised?

I am trying to implement a very basic status indicator using an STM32 - Basically I would like to toggle a RED LED when a fault is triggered by the MCU. Naively I added a toggle LED function in the ...
  • 185
0 votes
3 answers
110 views

A question about memory address in microcontroller vs PC [closed]

In context of embedded C, considering the following line: *((volatile uint32_t *) 0x48000414) |= 1UL<<12; Now 0x48000414 can be a memory pointer to a ...
  • 1,303
0 votes
2 answers
1k views

How does STM32CubeIDE locate the header file in such case?

I created a C/C++ project in STM32CubeIDE as follows: In the main.c I had to write the include as follows: #include "..\Inc\myRandom.h" otherwise if I ...
  • 1,127
0 votes
1 answer
113 views

HAL_SPI_Transmit does not send the bit pattern expected way

As a beginner, to test HAL_SPI_Transmit function for this Nucleo board, I wanted to send 0b10101010 on MOSI line and observe it on scope. But I don't see that bit pattern on scope, instead I see the ...
  • 1,669
1 vote
1 answer
121 views

problem in echoing 8 bytes in STM32 SPI slave

Linux SPI master sends 8 bytes data of these every 1 second: ...
13 votes
2 answers
3k views

Why does modulo operation consume more power?

I mainly use Cortex-M4F or Cortex-M0/0+ devices such as: STM32L4, G4 STM32L0, G0 I sometimes see blogs like this one saying "Avoid Modulo" for lower power consumption. Comparing these two ...
0 votes
0 answers
26 views

problem with sd card video door phone

I'm working on the code of a video door phone and I'm trying to improve it. with 16 GB SD card the pictures that the camera takes can be seen on the LCD but when I connect the SD card to PC using a SD ...
0 votes
3 answers
473 views

Why are MSPs in STM32 HAL defined as callback functions?

Please see my edit: I asked this question stackoverflow and no one answered. In STM32CubeMX MSP stands for MCU Support Package and of all here is what it basically about: MSPs are user callback ...
  • 1,127

1
2 3 4 5
31