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
1
vote
1answer
21 views

FTDI LIBMPSEE unreliable SPI connection

I am sending bytes from SPI master (FTDI FT2232H) over SPI to the SPI slave (FPGA). SPI master is actually a C program that implements libMPSSE directly from the FTDI. C program looks like this: ...
1
vote
1answer
56 views

can't view the transmitted bytes over UART on the received end as expected

I wrote a simple function to transmit the data over UART on nRF52 but having trouble seeing data on the receiving end: terminal. Every time I transmit something, it comes out as ? in a serial console, ...
-1
votes
1answer
99 views

Algorithm for calculating prescaler and period of a timer

I want to set frequency of a timer in a microcontroller. Frequency is determined by Prescaler and Period (ARR). Both of these are 16bit integer numbers. $$f_{tim}=\frac{f_{clock}}{prescaler\cdot ...
0
votes
1answer
61 views

Using strtok function leads to clearing token before I can use it

I want to design a GPS car tracker that alarms when the speed reaches a certain value and I want to first test the code with the USB to TTL module which is connected to my stm32, and simulate sim808 ...
1
vote
1answer
33 views

Mails Usage on FreeRTOS (STM32L4)

I have an application on STM32L4 with multiple queues and threads without problems. I try to add a mail queue via the following function : But it seems the linker can't find the reference : I check ...
2
votes
2answers
57 views

STM32 register does not change

I want to change the SDADC register while the STM32F373VBTx is running. First time, the MX_SDADC_init() set the SDADC gain. Second time, my software set the SDADC ...
4
votes
3answers
1k views

Convert the type of calculation result in if() to uint8_t

I am writing in C using the Atmel Studio (AVR-C.) I have an if statement: if( (rxProcessing < (rxWritePos-1) ) ) Where ...
3
votes
1answer
93 views

FreeRTOS - Guru meditation error

I've recently started to study esp-idf sdk, there a lot of new concepts related to RTOS that are new to me. I'm using a ESP32-WROOM-32 board. My main problem concerns to the following code: ...
0
votes
1answer
61 views

Corruption(?) of the raspberry pi pico's uart characters with the c sdk

I'm making a remote controlled machine using a pi pico to drive the motors and read some sensors, and a raspberry pi 4 to send commands to the pi pico via serial and host the web interface. I am ...
2
votes
1answer
95 views

Trouble using the UART with RPi Pico

I'm making a remote controlled machine using a pi pico to drive the motors and read some sensors, and a raspberry pi 4 to send commands to the pi pico via serial and host the web interface. I'm ...
0
votes
2answers
68 views

Flash page erase problem

I am using STM32F3 and I could not erase its flash. Below codes include address, where is my fault? ...
1
vote
0answers
39 views

Stm32f103 adc stable conversion

I am making a ntc thermometer with stm32f103c8 (by writing over registers without using state library). The code works as it is,I did the adc conversion in 7.5 cycles. I used the calibration register ...
0
votes
0answers
40 views

Resetting Microchip MM7150 to reliable state

So, I recently acquired the MM7150 chip from Microchip for use in a project. It functions as a combined 9 axis motion sensor, combining a gyroscope, accelerometer and magnetometer. Specifically, I'm ...
1
vote
0answers
24 views

LWIP pbuf copy issue

I am using the LWIP library on my stm32f4 project. In the low_level_output function have pbuf p member. I need to change its length with length + 1 and I need to add 1 byte end of the pbuf->payload ...
0
votes
1answer
21 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
2answers
107 views

How can I run C code in specific hardware setting

i write face detection on matlab and converted to c to use on mcu (STM32F4) now i want to know the code can run on this type of mcu there is tool or something to test this?
1
vote
1answer
104 views

Read data from a register in C-code [closed]

I am a beginner and learning by myself. I need your help to start the third implementation in my life in VIVADO ( "Hello world" and "led") I will implement SPI connection with DMA, ...
1
vote
0answers
98 views

Inconsistent behaviour with LIS3MDL magnetic sensor

I'm working on implementing a driver for the LIS3MDL magnetic sensor using FreeRTOS under the hood with some of our in-house functionality as well. Link to the device documentation if useful (used ...
1
vote
0answers
66 views

How we can jump to address of function(or specific address)?

I working with ARM CORTEX-M4. I wrote this code for jump to a function. I define this function: ...
1
vote
1answer
103 views

How are embedded C compilers different from C compilers used for desktop applications?

I've started learning about embedded systems and wondering since the compilers used for embedded applications aren't the same as the ones used for desktop applications; whether they behave differently ...
-1
votes
2answers
104 views

How to display my date in the 2nd line of the LCD?

Below are the codes I using to display dates and times and basically I used the function "write(hr1,hr0,min1,min0,sec1,sec0);" to display the time and "day_compute(day);" to ...
0
votes
1answer
60 views

HAL_I2C_Master_Transmit_DMA return HAL_ERROR

These my I2C init functions in stm32f4_hal_msp.c file ...
1
vote
0answers
63 views

UART DMA Buffer Problem

I have a problem with DMA receive function, when I stop the HAL_UART_DMAStop(&huart2); dma buffer doesnt clean, so I see the all data in buffer, ( I am using NORMAL BUFFER) when I send 17 ...
0
votes
1answer
93 views

Bitwise OR operator confusion [closed]

Can anyone tell me the difference between the following two assignments? control_reg |= (1<<2) | (1<<4); control_reg = (1<<2) | (1<<4);
0
votes
1answer
46 views

PIC18F4550 Optimize code for controlling output signal

I'm trying to develop a C program to control the turn on/off of thyristors by changing the angle of the output signal (down time, and up time). I use a pot to control the angle, and I receive an input ...
1
vote
1answer
160 views

HAL UART DMA NDTR Register

I am working with the stm32f4xx for the using UART DMA Tx-Rx operations. I have this line firstly: ...
0
votes
2answers
135 views

STM32: How do I place a large buffer into a specific memory region?

This is an embedded project using the STM32H7A3ZIT. I'm trying to store a large LCD image buffer in ram, but my program will not compile, even though the buffer should fit. I'm using STM32cubeIDE with ...
1
vote
3answers
138 views

Led not blinking - bare metal STM32F030x4

I've been following a bare metal programming tutorial aimed to STM32 devices. The author uses a shelf development board, however, I have a custom board bought from a friend (image below). Due to this ...
0
votes
0answers
27 views

Controlling DC-Motor (60V) from Encoder pulse signals using ATmega88, C-Programming

I have given the following C-Code to test a 60V DC motor with gear box ratio 16:1 and incremental encoder to see if the code calculates the speed by reading the Pulse signal as feedback for ...
2
votes
1answer
148 views

Function pointers causing unexpected behaviour within STM32H753ZI Microcontroller

hope everyone one is doing well. Just out here seeing the craziest programming behaviour I have ever seen, I was wondering if anyone can explain why is this happening? I finally just finished ...
1
vote
0answers
59 views

Writing an Array to EEPROM Problem

When I write an array to EEPROM and read it I always get 0xFF. I am writing in addres 0x0001 to 0x0005. The password I am entering is 1,1,1,1,1 saved in uint8 array ...
0
votes
0answers
21 views

Difference between axi dma sg mode and cyclic sg mode

What is the difference between axi dma sg mode and cyclic sg mode? Does it mean that the allocated rx buffer is reused like fifo when the whole buffer is used up? xaxidma_example_sgcyclic_intr.c ...
3
votes
1answer
133 views

How to transform the line voltages to the phase voltages in control software?

Let's say I am measuring line voltages of the three phase grid 400V/50Hz via three instrument transformers whose secondary windings are connected to the adc of my microcontroller i.e. I have following ...
0
votes
1answer
54 views

RTC with ATmega 32 & ds1307 showing the year completely wrong

I have this project to build a clock / calendar with ATmega and ds1307 showing it on a 20*4 LCD (LM044L). I have implemented the code showing the time correctly, i have initialized the RTC too, but ...
0
votes
1answer
28 views

How to use TA1 of P1.6 without also using it on P1.2 on MSP430F1101

I have been struggling for a lot of time now, training to use the pwm function on pin 1.6 of the microcontroller. For P1SEL=BIT2, it is correctly using TA1 on P1.2, but for P1SEL=BIT6 it is not using ...
0
votes
0answers
66 views

RFID with PIC16f877A

I have been working on my school project for couple of weeks and I'm trying to make RFID Door Lock by using PIC16f877A and RDM6300 RFID reader. I made a code works on PROTEUS but I interfaced the ...
1
vote
1answer
93 views

MPLAB programing: Questions on USART initialization code

I have just started using MPLAB for microchip Atmega128. I had a few questions regarding the following code segment for USART initialization which I found in the product documentation. Do I need to ...
0
votes
1answer
66 views

AXI Stream Master - M_AXIS_TVALID not always be '1' during a transaction and M_AXIS_TLAST

I am implementing my AXI Stream Master module which can be use with Vivado DMA module. The connection of module is shown: I have 3 questions: 1.) Could the "m_axis_tvalid" signal be non ...
6
votes
7answers
2k views

Should the pointer datatype be always same as the data type of variable it points in embedded C?

Im wondering if there is a convention or rule about pointer datatype and the stored variable's data type. If x is an integer ...
0
votes
2answers
110 views

How to exit from an interrupt's loop for MSP430

I'm new to MSP430 and microcontrollers. Right now I'm learning interrupt routines and trying to write a program that changes the LED's state (OFF-ON-BLINK) by every press on P1.1 button. I have used ...
0
votes
0answers
97 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 ...
1
vote
2answers
179 views

hal_delay in external interrupt problem

I wrote a simple C program for STM32: main.c ...
0
votes
0answers
138 views

DMA multiplexing on an STM32H7

Goal On my current project I have connected a multiplexer (4051) on 8 adcs that I read from a single pin on my stm32h7. I would like to sequentially change the three gpio's connected to the mux ...
0
votes
1answer
75 views

Expected a "," Error in keil

Error: ../Src/main.c(107): error: #253: expected a "," code part: uint8_t maskPWR_MGMT_2[2] = {0x6c, 0b00000111};//6c
0
votes
1answer
71 views

Unnexpected Behaviour From Software UART On ATtiny84A AVR

I am trying to implement a software UART for the ATtiny84A, as it does not come with a UART out of the box. The following is an example of the UART TX: ...
0
votes
2answers
106 views

`sizeof` Function Is not Working as Expected With AVR Microcontroller [closed]

Observe the following example code (Microcontroller used: ATtiny84A): ...
0
votes
0answers
69 views

Could a PIC18 running two functions simultaneously?

I am building a robotic car with stepper motors (for wheels) and infrared sensors(avoiding obstracles) using PIC18F4550 microcontroller. So, I have created a function to drive the stepper motor steps ...
2
votes
1answer
69 views

Configuring the Ports of an AVR Microcontroller for SPI Use

I am trying to configure the an ATtiny84A for use with SPI, but I have some confusion with what Is being said in the datasheet for configuring the ports. The ATtiny84A has, what the datasheet calls, &...
0
votes
1answer
72 views

STM32H7 32-Bit Counter with Reset, C Language Function

Need help a simple a 32-Bit counter with reset. Pseudo code: ...
0
votes
1answer
67 views

How to calculate THD using only the first harmonic?

How can I calculate THD using only the first harmonic? How can I implement in C code DFT voltage formula in order to calculate THD?

1
2 3 4 5
30