Questions tagged [c]

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

Filter by
Sorted by
Tagged with
-3 votes
0 answers
51 views

How to create c/c++ program that runs on startup?

I am new to raspberry pi. I have been stuck on this problem for a few days, but haven't managed to find a solution to this problem although I know it has to be possible. Basically I need a way to ...
user avatar
1 vote
1 answer
105 views

Can't generate PWM output on RP2040 other than square waves

I was playing with PWM on the RP2040. I can do square waves, but pretty much everything else does not work. I have recorded the PWM output with a sound card at 44100 Hz in order to verify it visually. ...
user avatar
0 votes
1 answer
93 views

how to power motors correctly on raspberry pi pico

I was using my raspberry pi pico and testing motors, and it worked just fine(pins was in GND + 3v3 pins). Then I wanted to use On/Off function in C, And i used the pin GP28_A2 to use it. But it wont ...
user avatar
0 votes
0 answers
39 views

C programming - Cannot open /dev/ttyS0 in blocking mode

I am trying to open /dev/ttyS0 in order to write over serial GPIO pin 8. I am using the Raspberry Pi Zero W and noted something strange. When I try to open dev/ttyS0 in nonblocking mode, I am able to ...
user avatar
1 vote
1 answer
61 views

rPi Pico IRQ with callback freezes Pico

I am trying to configure rp2040 function gpio_set_irq_enabled_with_callback on Pico using Arduino IDE with installed Arduino mbed OS because i need some libraries. When called interrupt happens but ...
user avatar
  • 21
0 votes
1 answer
63 views

How to store an array in flash memory (only) using the pico sdk?

The RP2040 on my board (Seeeduino XIAO) comes with 2MB of flash ram. How can I store an array that is too large to fit into RAM in flash, using C and the pico sdk? As the array exceeds a certain size, ...
user avatar
0 votes
0 answers
45 views

Why does Pi Pico duplicate and mix-up characters received over UART when programmed in C?

I have a Raspberry Pi Pico whose Tx and Rx pins are wired to the Rx and Tx pins of a Wemos D1 Mini development board. The Wemos and the Pico are powered via an external 5V power supply (common ground)....
user avatar
0 votes
0 answers
135 views

How do I use the TinyUSB module in my local c/c++ projects of RP2040?

I am trying to set the pico in usb device mode. The example code given work fine, but as per my application I want to use the tinyUSB module locally. How do I do that? Consider the example of pico-...
user avatar
0 votes
0 answers
87 views

use internal clock (ROSC) to set system clock (clk_sys) to run at 32 MHz in RP2040

I am trying to set the system clock of my RP2040 to 32MHz using the internal clock(rosc) as source clock. When the pico board is powered on, the ROSC's frequency is around 5 MHz which lies in the ...
user avatar
0 votes
0 answers
23 views

what is the project structure of a c/c++ project for rp2040(pico)?

When we make a project for STM32 environments, we get a structure where all the header and .c files are stored in separate directories like src, include, etc which depends on the IDE that is being ...
user avatar
0 votes
0 answers
26 views

Message printed multiple times when pressing hard button with RaspBerry Pi

I'm trying to print a message every time a button is pressed, and so far it's working fine, but the message is printed several times (somewhere around 4000 times) and I'd like it to be printed only ...
user avatar
0 votes
1 answer
379 views

Pi Pico: Software Reset using the C SDK?

I'm looking for a method/function to be able to reset a Raspberry Pi Pico via programming, using the Pic's C SDK. Is this possible? There is a way to do it using python using machine.reset() but I can'...
user avatar
1 vote
1 answer
104 views

Reading MCP23S17 port expander with pigpio

I'm trying to read from a handful of switches connected to a MCP23S17 port expander using pigpio, however I'm not getting any useful results. Whatever my switch values, I have 0 returned. I've checked ...
user avatar
0 votes
1 answer
65 views

Can ioctl(file,I2C_SMBUS,&args) be used to read MCP3221?

I've been using C code based on a convenient linux_i2c-dev.h, but there seems to be no function to read 2 bytes without sending a command byte first. I want the code to work on both PI3s & PI4s. ...
user avatar
1 vote
1 answer
139 views

Is t possible/feasible to use android's NDK toolchain to cross-compile for Pi?

That's it, really. I have an x86_64 host that already cross-compiles a C application for android's 4 supported architectures, could I use the existing toolchain to build armeabi-v7a for a Pi (running ...
user avatar
  • 151
-1 votes
2 answers
773 views

Communication Raspberry Pico and 3B+

I recently bought a Raspberry Pico to increase the capacities of my oldest Pi3B + tenfold in terms of sensors, buttons, LEDs, GPIO, etc. But I can not find for the moment any protocol or Bus allowing ...
user avatar
0 votes
1 answer
28 views

Pin 16 not lighting up

First time actually using the hedears on my raspberry pi zero w. These headers were soldered on when I got it. When I connect my red lead to the 5v pin, it lights up, so the circuit's correct. When I ...
user avatar
  • 109
0 votes
1 answer
38 views

Understand the plumbing behind running RasberryPI code from Freenove in Python

I have downloaded some pre-made code from Freenove - https://github.com/Freenove/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi Freenove uses WiringPi. So I downloaded WiringPi and ran build. Question ...
user avatar
0 votes
0 answers
81 views

Running "make" Produces Fatal Error [duplicate]

I'm currently trying to get my raspberry pi setup with a VPN. To do so I needed a DNS provider, and so I'm trying to use No-IP's services, and after downloading their files and running a make to start ...
user avatar
0 votes
1 answer
175 views

Do `pthreads` work on the Pico with the native c++ SDK without posix?

I am trying to port AprilTags to the Pi Pico. This has a dependancy on pthreads. As is outlined in this SO question pthreads needs a posix layer. However there is this youtube video showing it working ...
user avatar
0 votes
1 answer
91 views

How to set an initial value of a variable of struct in C? [closed]

Im making a library for a raspberry pi program and im running into trouble of a struct variable having an initial value. myLib.h typedef struct { int startingNumber = 0; // this throw an error in ...
user avatar
-1 votes
1 answer
194 views

Pi 4 doesn't recognize .o file format? [closed]

Was trying to compile some .c files along with one .o file using gcc, and it failed with an error message saying: .o file format not recognized. The same files got compiled on centOS vm though.
user avatar
  • 1
1 vote
1 answer
106 views

my spidev code does not store the receive data

So i am using a trimmed down version of this code to do a spi transaction usin spidev. Here is my code /* * spi-driver-speed.c * 2016-11-23 * Public Domain */ #include <stdio.h> #include <...
user avatar
0 votes
1 answer
919 views

How to read any connected DS18B20 temperature sensors with C/C++

I'm new to the Raspberry Pi ecosystem so pardon me if I'm talking nonsense. I want to read the temperature data from the connected DS18B20 sensors using C/C++. I followed this schema to connect them: ...
user avatar
0 votes
1 answer
97 views

Shutdown from C program

I'd love to do a proper shutdown of the Pi from a program (written in C) so that the only thing left to do is pull the power plug. Is this possible?
user avatar
2 votes
2 answers
2k views

How do I implement an interrupt service routine on Raspberry Pi?

There are several libraries like WiringPi, RPi and pigpio, claiming to implement interrupt handling for GPIO signals. But as far as I can estimate, they all do polling on the pins, therefore implement ...
user avatar
  • 23
-1 votes
1 answer
508 views

Raspberry Pi Software Driven servo control with PWM using C and Wiring Pi LIbrary

I'm trying to get my raspi zero to move an SG90 PWM driven servo. I have achieved this with python already using the gpiozero library, so I know my hardware works but I am trying to do it with C using ...
user avatar
  • 19
0 votes
2 answers
49 views

What happens shortly after boot to affect timers?

I have a program that has ill effects if run from .bashrc and I've dug deeper and found a minimal reproducible example. The code below will print the elapsed time every second. If I run this program ...
user avatar
1 vote
2 answers
81 views

Raspberry Pi - stdin at boot with rc.local

If I run a program via rc.local I get no access to the keyboard or monitor with stdin and stdout. How can I get around this?
user avatar
0 votes
1 answer
77 views

Camera, splitter and encoder in OpenMAX

I want to access camera and get both encoded and not-encoded video from it in my C++ application. As I'm targetting Raspberry Pi Zero, I want it to be as efficient as possible, so I decided to use ...
user avatar
  • 101
0 votes
0 answers
75 views

CAN communication between arduino and raspberry pi

I am trying to communicate between Raspberry Pi and Arduino. In arduino I am using this program to transmit #include <SPI.h> #include <mcp_can.h> const int spiCSPin = 10; MCP_CAN CAN(...
user avatar
1 vote
2 answers
376 views

Writing to framebuffer on C is very slow (Raspberry Pi) [closed]

I want to make a very intensive simulation and need the most power the Raspberry Pi gives me. So I flashed Raspberry Pi OS Lite (without Desktop) onto an Micro SD Card and wrote to the framebuffer in ...
user avatar
1 vote
1 answer
60 views

Unable to control GPIO from the code

I am using raspberry pi 4b along with Freenova kit. I am trying to make the LED blink however it does not blink instead it is ON of the time. I have tried different code (C,Python,Java) but none of it ...
user avatar
  • 23
0 votes
1 answer
37 views

Deinitialize GPIO access on I2C channels

On webpage http://abyz.me.uk/rpi/pigpio/examples.html you can find Tiny GPIO Access that defines minimal set of C functions needed to control the GPIO without needing root privileges (it uses /dev/...
user avatar
  • 419
3 votes
3 answers
5k views

Controlling Raspberry Pi GPIO with c and Python

I was searching for C and Python Libraries which support Pi4.
user avatar
  • 53.5k
0 votes
0 answers
199 views

using GSL with raspberry pi

I am trying to use gsl in the raspberry pi but every time I try to compile I get the following error: gcc -L/usr/local/lib -lgsl -o interface example.o -pthread -lgsl -lcblas -lm pkg-config --cflags -...
user avatar
1 vote
1 answer
176 views

UART - wiringSerial.h vs standard Linux open/close

I'm making an application that uses the UART port from the 40pin headers and I found online that there's a library called wiringSerial.h I was wondering what's the difference between wiringSerial.h ...
user avatar
  • 131
1 vote
1 answer
183 views

popen() vs netcat

I'm writing a RPi based surveillance solution that, among other things, starts video feeds on demand. In my very first attempt I wrote a pretty simple TCP server that listen for a connection collect ...
user avatar
  • 112
0 votes
1 answer
284 views

Raspberry Pi 4 - BCM2835 Library - SPI1 - data mode 1

I use the BCM2835 library to communicate in SPI with an ADC. The SPI0 interface is already used by a touch screen (https://www.pi-shop.ch/pitft-plus-480x320-3-5-tft-touchscreen-fuer-raspberry-pi-model-...
user avatar
0 votes
0 answers
40 views

Can't get to toggle leds with WiringPi library in C

So I got my python code to run that basically just toggles the LED, but now I tried enabling the GPIO via WiringPi library in C but it doesn't work. Considering python code runs, there isn't really ...
user avatar
  • 3
0 votes
0 answers
55 views

Graphing out the sensor data in a C-based application

So my setup basically includes STM32 as an MCU to which a temperature sensor and an nrfl2401 radio module are hooked. On the receiving end, I am thinking of having a Raspberry pi as an MCU hooked to ...
user avatar
  • 3
1 vote
2 answers
3k views

Rpi Neo-6M / Neo-8M GPS Module Setup / Fix / Update Problems

Hi i'm tryng to change the update rate of my gps tracker(neo 6m ublok) i know the byte that i need to send are 0xB5,0x62,0x06,0x08,0x06,0x00,0xC8,0x00,0x01,0x00,0x01,0x00,0xDE,0x6A i've tried echo -e &...
user avatar
  • 23
0 votes
0 answers
83 views

How to prevent libvlc from opening a new window for every mp4 in playlist?

My requirement is that a list of mp4 files play sequentially in the same window. The aim is to produce a simple animated face, specific characteristics being added programmatically to the list. ...
user avatar
0 votes
1 answer
24 views

code gets stock in keypad function

i am doing this project where i want to put a keypad and take in password from a user and then open the door or not. i used C but every time i call the keypad function in my code the code will not ...
user avatar
  • 1
0 votes
0 answers
51 views

Cannot get the exact wireless protocol at a raspberrypi 4b using header wireless.h

I've created a programm in C that runs on raspberry pi4B in order to get the wifi protocol that is supported. The version of raspbian is : Distributor ID: Raspbian Description: Raspbian GNU/Linux ...
user avatar
  • 113
0 votes
1 answer
280 views

I want to mmap the GPIO on Raspberry Pi 4b+ but get invalid argument. (Running Raspbian Buster)

// The c code shown here works: int fd = open("/dev/gpiomem", O_FLAGS); printf("fd = %d\n", fd); long int* addr = mmap(0, 0x1000, PROT_RDWR, ...
user avatar
2 votes
1 answer
742 views

How to write 16 bit data to device address using the i2c wiringpi lib

I am trying to write 16 bit data to i2c device . As there are no registers specified to write to the slave device, I am not able to use the built-in wiringPiI2CWriteReg16 Api. Can some one guide me ...
user avatar
0 votes
1 answer
125 views

Program won't continuously read a value from a function

I'm in the midst of a school project and having trouble with reading ADC values from an MCP3004. I have it done in two different ways but one of them won't work. Using wiringPi.h and mcp3004.h, all ...
user avatar
2 votes
2 answers
2k views

WiFi packet sniffer for RPi in c++

We are currently working on a project, where we want to see the packets sent over WiFi. We are using an RPi zero w as a sniffer, and we have managed to use ioctl calls to get ssid and other ...
user avatar
1 vote
1 answer
296 views

Writing to GPIO 1 (ID_SC) witth Pigpiod C interface

I am writing a general-purpose stepper motor driver C shared library for the Raspberry Pi using PIGPIO (pigpiod C interface) for 4 to 7 motors using A4988 drivers. I designed an interface board (...
user avatar
  • 13

1
2 3 4 5 6