Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c]

For questions pertaining to compiling C programs on the Raspberry Pi.

0
votes
0answers
17 views

Generating multiple square waves simultaneously

I'm trying to generate 2 simultaneous square waves (50% duty cycle PWM signals) to step two stepper motors (STEP signal to separate motor drivers) on the Raspberry Pi Zero W. I use GPIO12 and GPIO19, ...
1
vote
1answer
34 views

How to access to I2C software with wiringpi library-

I want to use I2C software instead hardware I2C. Because a buggy parto of the I2C related with clock stretching. I can enable in boot.txt adding this: dtoverlay=i2c-gpio,bus=3 It would create a /...
0
votes
1answer
33 views

RaspberryPi getting error after reading some serial Input, using rs232 and C Language

my raspberry keep getting error after reading some serial input, like this: i'm using Library wiringPi with this sample code: #include <stdio.h> #include <string.h> #include <errno.h&...
1
vote
0answers
32 views

wine on exagear fail on libc6_2.19-18

have installed exagear but when wine try to unpack this still block me: for solving i try this on /bin/bash in the guest image /opt/exagear/images/debian-8: sudo dpkg -i libc6_2.19-18+deb8u10_i386....
1
vote
1answer
130 views

Imprecise result after bitwise operation on GPIO registers

I am using a Raspberry Pi(Model 1 B+) and an oscilloscope in order to program SPI with C. I am doing this by using direct access to the GPIO register. Like this: https://elinux.org/...
-1
votes
1answer
204 views

Showing an image on HDMI (DSI, HDMI screens connected)

I have a Raspberry Pi 3B device connected to a LCD '7 (7 inches LCD, its a touch screen I believe that's called DSI not sure) and also a HDMI screen. By default Raspbian considers the LCD as the ...
0
votes
0answers
114 views

wiringPi (C) , MCP23S17 , and interrupts

I've enjoyed using the wiringPi C library in various ways. Used it with vanilla GPIO, with its interrupt-handling feature, with MCP3008, MCP23017, and now the MCP23S17. However, I'm a bit stumped on ...
0
votes
0answers
52 views

Can't find c library for libxml2

I am trying to compile a C program that uses libxml2, it compiles OK (so the C headers are present) but the link fails with the message cc test.o -llibxml2 -lm -o test /usr/bin/ld: cannot find -...
0
votes
1answer
42 views

Blink doesn't work (code in C)

I am newbie to Raspberry Pi. Here is the script I want to see work: #include <stdio.h> #include <wiringPi.h> #define LED 0 int main (void) { wiringPiSetupGpio() ; // also tried ...
0
votes
1answer
46 views

C Interrput every rsing edge 100kHz

i've a 100kHz signal and i want to detect every rising edge. I'm using ISR but edge isn't detected and when detected it's 46µs after the edeg. How to do? [EDIT] Here's the code with pigpio library: ...
0
votes
0answers
55 views

Decoding a 74HC595 Shift Register bus with GPIO

I'm trying to decode an existing serial Bus communication used to drive 74HC595 (Shift register). 74HC595 Bus lines are: Latch : (When falling edge data are acquireq by the shift register, when ...
0
votes
1answer
137 views

How to run a C program at boot time [duplicate]

I have a project and it is running a c program on the PI. The program is meant to start running at startup. So far I have tried to do this with rclocal, but this is depricated. Afterwards I tried ...
0
votes
3answers
45 views

Pi freezes after softPwm

I'm building a robot car as a beginner project with a Raspberry Pi 3 Model B. It was easily possible to control the motors with help of the wiringPi library in C. To adjust the speed of my car I want ...
0
votes
0answers
98 views

How to read data from PIR sensor which is controlled by relay i2c?

There are my first steps with RPi and i2c. I use expander pcf8574 and I would like to drive a relay to control LED and PIR sensor. When the state on sensor is HIGH, LED should be turn on. I wrote a ...
0
votes
0answers
211 views

How could I write a C function using the wiringPi SPI library to read the X and Y measurements from this 2-axis inclinometer?

How would one use the wiringPi SPI library (http://wiringpi.com/reference/spi-library/) to get the x and y readings from this SCA100T inclinometer? I understand that the function wiringPiSPIDataRW() ...
0
votes
1answer
165 views

Interface AD7193 with Raspberry Pi

I have been trying to interface an ADC with raspberry Pi namely AD7193 via SPI . For that I have enabled my SPI and installed spidev on my pi. but i dont know what to do next in order to get the ...
1
vote
0answers
358 views

How to Read LDR Input with Raspberry Pi's GPIO Pins in C? [closed]

Using an LDR and the below circuit diagram, I am trying to read the amount of light that the LDR is receiving. My primary goal is to detect a change when an object passes over the LDR to trigger an ...
0
votes
1answer
151 views

AVFrame YUV420P to dispmanx VC_IMAGE_YUV420

I'm using ffmpeg for decoding a video with h264_mmal encoder. And all test videos are in YUV420P color encoding. Also I'm using dispmanx for drawing frames from a video. Only problem which I have is ...
0
votes
0answers
35 views

can't execute uart communication

I'd like to execute uart communication but I didn't succeed it. I use raspberrypi2 and the OS is ubuntu14.04. I show the procedure that I executed. [1]I directly connected GPIO14 (Tx (pin 8)) to ...
0
votes
1answer
207 views

Cross-compiling with nfs-mount as sysroot fails due to absolute links

I want to cross-compile C++-applications for the raspi using the rpi-tools, CMake and a raspbian sysroot I'm exporting via nfs from a running raspi. My CMake-toolchain-file is OK, header-files and ...
0
votes
1answer
479 views

Playing audio in C?

Every audio engine I've tried (SoLoud, cAudio, openal-soft) hasn't worked on my pi zero. I just want to be able to play audio in a program without too much hassle. I can use a system call like system("...
0
votes
0answers
47 views

Program inexplicably terminates upon calling open()

I have code that is attempting to open /dev/mem for mapping a peripheral register for manual usage. Specifically, I am attempting to access the UART registers directly. I have a function called ...
1
vote
1answer
1k views

Where is -lEGL -lGLESv2

I'm trying to install an OpenVG library, but when I start to make it I get the error. ... gcc -L/opt/vc/lib -lEGL -lGLESv2 -ljpeg -shared -o libshapes.so oglinit.o libshapes.o /usr/bin/ld: cannot ...
0
votes
1answer
345 views

Rotary encoder is giving less PPR reading

I am testing 400 PPR(Pulses Per Revolution) rotary encoder using code.I am rotating it by using the hand. I have connected Phase A and Phase B and also, ground and Vcc properly. The code is giving ...
1
vote
2answers
1k views

Size of serial port read size in c

I have a Raspberry Pi 3 and I'm currently use read(2) system call to read data from serial port. At this moment, I'm reading byte by byte from port with; rc = read(uart_fd, &byte, 1); I'm ...
3
votes
1answer
191 views

Does select/multithreading make sense when dealing with multiple DS18B20 and GPIO reads simultaneously?

As you may know, DS18B20 is not the quickest sensor and answers after around 750ms delay but, afaik, 1-wire is a relatively quick bus. I have multiple sensors connected to the board, which means if I ...
2
votes
1answer
227 views

How to run a persistent program at boot which prints to console?

I have program built for a drone project where my pi needs to start reading when the pi is booted up. I have substituted a simple C program instead call myloopprogram located at the root folder ~. It ...
1
vote
2answers
625 views

C library for controlling 16x16 ws2812b led matrix using Raspberry Pi

Where can I find a C/C++ library to control a 16x16 ws2812b led matrix using a Raspberry Pi? There exists a C code for Unicorn HAT HD here but the unicorn HAT HD uses four GPIO pins as data pins (pin ...
1
vote
0answers
2k views

PWM with wiringPi library and C in order to blink an LED at a given frequency

I am working with the wiringPi library with C on a Raspberry Pi 3 Model B and attempting to understand and develop a model so that I can predict the blinking behavior of an LED connected to GPIO #18, ...
1
vote
1answer
93 views

UART program on RPI 3 is not waiting for response

#include <stdio.h> // perror #include <sys/mman.h> // mmap #include <sys/types.h> // fd open #include <sys/stat.h> // fd open #include <fcntl.h> ...
1
vote
1answer
77 views

Magmatic sensor's error in MPU9150

I coded the following program to get the acceleration, gyro, and magnetic sensor values by using a MPU9150 that is connected to a Raspberry Pi 2 via I2C. I can get the proper acceleration and gyro ...
2
votes
1answer
414 views

Can GPIO mode be changed at once for more than one pin?

I'm currently trying to understand the pigpio library and I found it supports reading from and writing to more than one GPIO pin at once. However can it do the same with pin mode? I'm asking the ...
0
votes
1answer
192 views

Text overlay over video stream when saving to file system

I'am using raspberry pi zero as controller which communicate over UART with external board with five sensors. What I need is a way to save video stream from raspicam to filesystem with embedded text (...
2
votes
1answer
3k views

How to enable SPI1 and SPI0 at the same time?

I have installed a LCD screen that use my SPI0 bus and I2C but i want to connect my RFID reader to the same raspberry. My lcd screen can you see here: https://www.adafruit.com/product/1601 SPI1 will ...
0
votes
1answer
463 views

Wiringpi interrupts

If I make an interrupt and use a goto statement to go from the interrupt function to the main function will I start running into problems: with the flow of my program and with bugs. Will I start ...
0
votes
3answers
115 views

incorrect values shows up in ultrasonic output in a fixed position

I am using below code to get the distance from an ultrasonic sensor. when the sensor is pointed to the wall with no change in its position, after some correct values some incorrect values will show ...
0
votes
1answer
55 views

L293D wiring only works when 6v ground connected to 5v live

I have the following code which I use to run some DC motors on the Raspberry Pi with an L293D H-Bridge. I should be able to control which motor is driven and in which direction. #include <stdio.h&...
0
votes
2answers
184 views

PIGPIO PWM Unreliable

I have written a small C application to do PWM for some motors connected to a Raspberry Pi. I am using the PiGPIO library. The code as follows: int[] FWD = {MOTOR1_FWD, MOTOR2_FWD}; int[] BCK = {...
0
votes
2answers
137 views

An unknown error when programing with bcm2835 (i2c)

Forgive my broken english. I am using a RaspberryPI 3b+. I have written a program using the bcm2835 C library and I have found that none of my code worked. Even printf(). (there is no error when I ...
0
votes
0answers
329 views

RPI Python vs C application speeds

I have developed a software in Python (2.7) that uses pigpio to provide a waveform signal to a GPIO that runs a transmitter circuit. The frequency of the transmitter pulse (primary signal) is less ...
1
vote
1answer
986 views

glibconfig.h no such file or directory

I just installed glib in Raspbian(Debian version). I want to read a config file using glib. I am trying to write a C application in Codeblocks and I use the header #include <glib.h> But I ...
1
vote
1answer
117 views

Logic to print text in SSD1306

I was writing a program for my SSD1306 oled display from scratch without any third party. I have successfully initialized the display. But I dont know the logic to turn on the pixels for a particular ...
1
vote
0answers
233 views

How deep can a virtual machine like VirtualBox emulate Raspberry Pi?

Currently I have the firmware code for a device running on Raspberry Pi. I want to use a linux computer that I have to test the device out using a virtual machine like Virtual Box (To connect it to ...
1
vote
0answers
92 views

Cross Compile on maxOS fails linking System library (CMake), but other libraries succeed

tl;dr - CMake fails at linker not finding System library with precompiled RaspberryPi toolchain when other libraries work So I've been fighting this for a few days, and I believe I'm nearing the end ...
4
votes
1answer
150 views

Can't find out why my program won't read analog values (Using MCP3004)

I am using wiringPi and C. I have a flame sensor and a MCP3004 ADC. Here is the program that I wrote, but I can't figure out why it won't read the analog values from the flame sensor. #include <...
0
votes
1answer
426 views

WiringPi digitalRead don't works everytime

I'm using digitalRead of wiringPi to detect packet received in CAN chip, so i'm send data and wait for falling edge of the can interrupt pin as you can see here: gettimeofday(&t1, NULL); ...
0
votes
1answer
225 views

Communication between C and C# program on RPI3

I have a question i wondered by myself if it is possible to communicate between a C# and C programm. I want to use the C# program for the user interface and then send commands to the C program that ...
0
votes
0answers
569 views

raspberry pi : bcm2835 to wiringPi

I have the following SPI sample code, which it write and reads data from a register. #include <bcm2835.h> #include <stdio.h> #include <unistd.h> #define PIN RPI_GPIO_P1_24 #...
0
votes
1answer
102 views

Using I2C and the adapters

I am trying to use the GPIO pins for I2C communication between the master and the slaves and have been using this page as a reference for me on how to do it. The code is run from userspace daemon. So ...
0
votes
1answer
422 views

Raspberry Pi Baremetal Programming

Just few days ago I bought Rasberry Pi 3 for education, and try my best at low-level programming. For now I wrote a simple GPIO code to set low and high level on controller's pin. My functions can ...