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)
1,399
questions
0
votes
0answers
15 views
0
votes
0answers
27 views
How to read BMP280 “chip_id” using the Tiva TM4C123G SPI communication interface?
Am trying to read the chip_id of the BMP280 Pressure/Tempeture sensor using the Tiva TM4C123G Launchpad thought the SPI communication protocol.
To begin with let me provide some back ground info and ...
1
vote
2answers
59 views
Modifying an irregular length bit field in a register in C/C++
Suppose I wanted to modify the field ADD[7:0] in the following register:
I wrote this to make things more convenient.
...
0
votes
2answers
61 views
CANBUS Masking and Filtering
I am using a module to convert CAN to UART. This module has 2 programmable masks and 6 programmable filters.
There are 13 message IDs that come in over the CAN bus and I only want 9 of them. The IDs ...
1
vote
3answers
44 views
Send Data With Usart STM32
I have to send data using the usart2 in my nucleo64 stm32f446re board.
The type of data I have to send is float but until now I always send uint8_t using this code;
...
0
votes
3answers
72 views
How To Save A Matrix In Flash Memory In STM32
i'm new in stm32 and in embedded world in general. I'm using a nucleo64 f446re and I want to save a matrix in the flash memory.
Can I use CONST to do this?
0
votes
1answer
28 views
UART doesn't transmit all characters when using UDREn interrupt
Note: I am beginner :) MCU: Atemega328p
In Method 1, I am using a UDRn data register empty interrupt once the transmit buffer is empty and inputting characters from ...
1
vote
2answers
58 views
Does this interrupt improve performance even with while loop in ISR?
Note: I am a beginner :) MCU: Atmega328p
Which program below burdens the CPU the least? Would it be a significant difference?
Objective: to make a more "efficient" serial monitor by ...
0
votes
2answers
58 views
Checking and reading bits using while loops
Note: I am a beginner :) MCU: Atmega328p
I am struggling to understand how reading registers using while loops work in Embed C:
For example AVR-C USART Protocol:
...
1
vote
1answer
73 views
Why would you right shift 8 bits for 8 bit register?
MCU: Atemega328P Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf (Page 143 - USART)
Note: I am beginner :)
Using the BAUD ...
0
votes
0answers
37 views
Old VFD clocks and wired button problem
So, my friend stumbled across this old article:
https://steemit.com/electronics/@gleb-jeglov/how-to-make-a-vfd-clock-step-by-step
He gave me couple IV-18 tubes and asked me if I can make similar ...
1
vote
2answers
82 views
Tact switches only work once
I am trying to do a digital clock using an Atmega8A, LCD display (2x16) and four tact switches.
Key number 1 is connected to pin PD2, number 2 to PD3, number 3 to PB6, number 4 to PB7.
When you press ...
0
votes
2answers
55 views
How do I get started in C using avr-gcc on the mega2560 [closed]
I've program the arduino using tools before (on windows) and using C++ but never with c++ without tools nor done it on linux
I have a (at)mega2560 and want to do a simple blink program like the below
<...
0
votes
0answers
21 views
Normal Mode of CAN Controller in STM32L476 Nucleo Board is Not Working
I am using STM32L476RG Nucleo board which contains only one CAN controller(bx_CAN1) and SN65HVD233 as a CAN Transceiver. I could able to test the CAN controller by using "LOOPBACK Mode".
...
1
vote
0answers
18 views
Lines transferred from main memory to Cache
I'm studying Cache memories and I would like to know exactly how the lines are transferred from memory to cache.
Supposing I have a 32-bit machine with a 16kB directly mapped cache and 8 words per ...
0
votes
0answers
36 views
Snubber circuit for TRIAC
I have built TRIAC circuit below which I got off the internet. Without the snubber circuit works good, but with snubber the TRIAC is always on. I'm using 9v ac just for testing purposes. Can someone ...
1
vote
1answer
39 views
Pin change interrupt won't toggle OFF my LED
Friendly Note: I am a beginner :)
Microcontroller: Atmega328p LED = PORTB0 BUTTON = PORTB1
Aim: To have the button generate a pin change interrupt request which runs an ISR that toggles PORTB0 ...
0
votes
0answers
42 views
STM32F103C8 I2C BUSY flag reset
I'm using HAL to use I2C and somemtimes I'm getting HAL_BUSY flag, I read STM32F103 errata and added BUSY flag clear according this,
i2c busy flag clear
But I changed error handling little bit and is ...
-2
votes
1answer
43 views
Cross talk issue ADC PIC18F2458 [duplicate]
I have used the following configuration according the data sheet
FOSC/32, 12 TAD
I still get cross talk, I'm using 3 ADC Channels with USB, and When I use one Channel, other channels get affected I ...
0
votes
0answers
62 views
Writing USB Joystick for PIC18F using MikroC
I'm using PIC18F2458 as USB Joystick HID. The program works, but I have few problems.
Right now, The USB is not detected If I write less than 5 values ( Throttle, X,Y, 4 buttons). The current problem ...
0
votes
1answer
50 views
STM32L053R8 - Bare metal LED issues
I'm following a bare metal course, I have managed to set up the project within IAR, my project compiles and runs.
I'm attempting to get the user LED (LD2) to flash before I continue the course.
I'm ...
1
vote
1answer
138 views
How to share a variable between ISR and main-code?
I'm working on some embedded software and I ran into a problem and I cannot figure out why this block isn't working.
I set up interrupts to for several buttons, including a mechanical encoder. I used ...
1
vote
1answer
66 views
Execution of a piece of code in embedded
Can anyone explain to me step by step
What is the result of executing the code below:
DDRB = 0;
unsigned char temp;
temp = (PINB & (1 << 4)) >> 4;
-1
votes
1answer
81 views
Can I assume a compiler for a 32 bit microcontroller supports C99 variable-length arrays?
I'm making a C library for the embedded system community.
I was wondering: In your experiences, do most people use compilers that support C99 VLA?
1
vote
0answers
123 views
How do I know if my I2C interface is working properly?
I have an MSP430FR6989 (MSP-EXP430FR6989 launchpad) interfacing with a MAX30102 Pulse Oximeter and Heart Rate sensor IC via I2C, I have only one master and one slave.
According to the pseudo-code in ...
1
vote
1answer
61 views
Connect HC-05 and esp8266 with MQTT protocol
I trying to use Bluetooth HC-05 with esp8266 to connect with Mqtt broker (Raspberry Pi), I already know how to connect by Wi-Fi, because there are a lot of example code for it. But not for Bluetooth.
...
-3
votes
1answer
30 views
How can i find the AT24C256 reg_addr?
For i2c to eeprom (at24c256) how can I find the device address and register address?
...
0
votes
1answer
65 views
Using C++17 static inline members in embedded MSP432 application, program fails to launch as reset occurs
I am unable to debug my embedded software since I started using static objects.
I do not think that there is much difference in memory allocation/initialization between the classic static variables ...
0
votes
1answer
44 views
Two stepper motors at different speeds using potentiometer and Ardunio
I am trying to control two different motors using Arduino and some drivers. The problem I have is that using mills() (i need to use timer with out delay due to me wanting more than one motor at the ...
3
votes
0answers
102 views
ISR won't modify a global variable (IAR)?
First, some background on what I'm working on.
I have a custom board with ATmega324A that I designed as part of a project I'm working on. Originally, software for the uC was written for GCC in Atmel ...
1
vote
1answer
43 views
How does the JTAG TAP react to clock cycling, and why am I unable to get an instruction through?
I am writing a program for bit-banging a JTAG interface. As far as I understood the JTAG interface, it should act like this:
On clock rise, the TDI and TMS inputs are sampled, if Shift-IR or Shift-DR ...
0
votes
0answers
54 views
Microcontroller USART receiver doesn't work
I know it's some PIC(18F45K22) specific but I want to ask because I haven't been working for a few days.
Although I see the signal with oscilloscope on the RX pin, I could not any data in software.
...
0
votes
0answers
57 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 ...
2
votes
1answer
256 views
Understand an I2C clock line implementation
I am trying to understand a C function from a legacy project which is supposed to manage the clock line for an I2C interface. It basically does as follow:
Set pin to output: ...
0
votes
0answers
23 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
54 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 ...
0
votes
0answers
68 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
95 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 ...
2
votes
1answer
108 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
39 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
79 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
41 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
2answers
60 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
66 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
100 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
105 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
320 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
37 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
113 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
79 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 ...