Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [c]

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

Filter by
Sorted by
Tagged with
1 vote
2 answers
207 views

Current proper way to interface GPIO from C code?

I've done a lot of googling and it's only confused me further; the old /sys/class/gpio way is deprecated and there's a rag-tag bunch of libraries that appear to have sprung up, none of which have much ...
John U's user avatar
  • 181
0 votes
1 answer
82 views

It is possible to set I2C bus speed programmatically without the bcm2835 library?

All, I've ported a C++ OLED library from the bcm2835 library to use i2c-smbus to prevent having to run the executable as root. (not the best from a security standpoint). However, i2c-smbus and ioctl() ...
David C. Rankin's user avatar
0 votes
1 answer
148 views

The 'i2c_write_blocking' function in Pico SDK

I am confused... I'm using the i2c_write_blocking function, but getting a strange result: If I do this - everything works as it should; i.e. I can read the values back from CONFIG_REG, and they match ...
Seamus's user avatar
  • 22.2k
0 votes
0 answers
39 views

Control Signal Raspbery Pi

I have a project to generate DCC signal so it needs to be used bts7960 to control the signal and connected to Raspberry Pi 3B. But, unfortunately the signal wave is not like digital signal perfectly. ...
Naufal Yanu Kusdianto's user avatar
1 vote
0 answers
56 views

How do I directly process live raw camera data on the GPU without it passing though the CPU?

My understanding of the how a Raspberry Pi camera attached to the CSI port of the Pi works is that the raw data from it ends up directly in the GPU where it is slightly processed and compressed before ...
Curtis's user avatar
  • 11
1 vote
0 answers
228 views

Raspberry Pi Pico w bluetooth doesn't pair

I'm trying to set up bluetooth with the pico w with the c/c++ sdk for it to communicate wirelessly with my laptop. I'm using btstack's and rasberry pi's example of spp_streamer.c. Also shown here. The ...
gringott capt's user avatar
1 vote
2 answers
773 views

One time timer interrupt? (Pico W, C/C++)

Is there a way to set a one time timer interrupt on the Raspberry Pi Pico? I.e. in code, I would be able to tell the hardware timer to interrupt me in a specified period of time. Example pseudocode ...
alex's user avatar
  • 21
0 votes
1 answer
252 views

Get package temperature of a Raspberry Pi pico using C

I'm working on a Raspberry Pi pico and I'm using the C pico-sdk. I want to get the temperature of my package so I followed the datasheet of the rp2040 (page 565) and I've used the following code : ...
Bibibou's user avatar
  • 13
0 votes
0 answers
108 views

Raspberry Pi Pico W lwIP http request takes too long at altcp_connect()

Problem I successfully build and run a TLS client Example (picow_tls_client_background executable) from the GitHub, however a simple http GET request takes about 20 seconds. It does not actually ...
Ngdgvcb's user avatar
0 votes
0 answers
178 views

Can't connect via to server from http C client Pico W lwIP

I just try for already 3 days to make a http GET request, used a lot of examples, but all of them do not work. The code below, I checked, succesfully connects to WiFi, and resolves dns - obtains ip ...
isagsadvb's user avatar
1 vote
1 answer
798 views

Update software of a Pico remotely

I'm using a raspberry Pi Pico and I'm struggling to find if it's possible to update my script remotely (I cannot use neither SWD or USB). Currently my new firmware (can be .uf2, .bin or .hex file) is ...
Bibibou's user avatar
  • 13
1 vote
0 answers
108 views

bash who command does not give datetime correctly on testing

Edit : We are still looking for differences that would explain why who does not work on testing for user lines (it works for boot lines for instance), this is differences on the code for following ...
JoelCrypto's user avatar
0 votes
1 answer
655 views

How to receive data longer than 32bytes through PICO UART?

I have wrote a code to process data received in a PICO from Raspi PI. I have a slider which sends number to the PICO(through UART) to set some values. If the slider is dragged slowly or clicked the ...
Paul Jose's user avatar
0 votes
1 answer
98 views

SOLVED Raspberry Pi 4 missing reverse ticks from AB encoder

I posted this on stack exchange, but it isn't getting much traction so I'm posting here, hopefully someone has run into this before! I am writing a program to control a robot in C using a raspberry pi,...
Zico's user avatar
  • 9
2 votes
0 answers
361 views

Pico Debugger can upload code once but not twice (when touching sysclk)

I've been playing around with the new Pico Debugger, and it is very nice. I have been running into some issues when using an external GPIO clock as the debugger does not seem able to detect the CPU's ...
Edwin Shepherd's user avatar
1 vote
2 answers
129 views

Why 10% CPU when sleep() on Pi 1B

I'm writing a simple application in C to handle switching relays on an old Pi 1B. When the Pi is supposed to wait for the next action to handle, I use the sleep() system call. I checked with top, only ...
D.Bugger's user avatar
  • 111
1 vote
0 answers
55 views

Respond to GPIO in fastest way possible

I'm trying to respond to a trigger from a ~1MHz clock and I'm having trouble doing this in the time required (under 400ns). I'm using a Raspberry Pi 3b+ and I've seen benchmarks of 50Mhz+ for toggling ...
Robin Elvin's user avatar
1 vote
1 answer
1k views

How do I check the memory written into a Raspberry Pi Pico W from the compiler?

I'm uploading a simple C program into a Raspberry Pi Pico and I would like to check the memory this program is occupying in the Pico. The program only has an empty main function. What I want to do is ...
bro's user avatar
  • 21
1 vote
1 answer
57 views

Using C on RPI to Initiate a File Transfer from Raspberry Pi to PC [closed]

As the title suggests, I would like to have the RPI initiate a file transfer to the PC. I am thinking to make a system() call inside the C code running on the RPI. I have established an SSH connection ...
Robin Y's user avatar
  • 21
1 vote
1 answer
546 views

Identify the Pico core at runtime

Using the C/C++ Pico SDK, how can I find out which core my code is running on? (Specifically, I'd like to use lwIP's LWIP_ASSERT_CORE_LOCKED, which requires a thread or core identifier to determine ...
Christoph Wintersteiger's user avatar
-1 votes
1 answer
335 views

fatal error: dht11.h: No such file or directory

I have written the following code: // wiring schema: // DHT11 --> Raspberry Pi // PIR --> Raspberry Pi // Servo Motor --> Raspberry Pi #include <stdio.h> #include <stdlib.h> #...
MartWal's user avatar
3 votes
1 answer
1k views

High Impedance (Hi-Z) state for Pico GPIO

Using a Pico [RP2040], I wish to interface to a data bus which is (already) pulled high. (Based on the contents of the address bus) I want to put data on the data bus [ie. "memory mapped i/o"...
BlueChip's user avatar
1 vote
0 answers
372 views

Pico C programming: Make all projects use the USB port

I'm in the learning process for the RPi Pico using the C SDK. So far, the interesting examples I've followed output their results over the serial port. I've learned that some of the examples include a ...
Seamus's user avatar
  • 22.2k
0 votes
1 answer
2k views

Raspberry Pico SDK - I2C Write to one Register Address (to set mode) then Read data from 2nd Register Address

I'm a bit confused by i2c_write_blocking() and how to specify the device_address, register_address and data to prime a device for reading and then to read data from another 2nd_register_address in the ...
David C. Rankin's user avatar
0 votes
2 answers
685 views

How to simultaneously control over 200 GPIO pins while maintaining timing accuracy

I am currently using a raspberry pi zero, which I connect directly to my computer via usb. I have connected eight MCP23017 GPIO expander chips, which is the maximum amount you can connect to a single ...
Yes's user avatar
  • 169
-1 votes
1 answer
712 views

Why is GCC not able to compile file on arm64 Raspbian Bullseye?

I tried to run a simple program with gcc on my Raspbian 64bit on Pi 4. Is there something wrong with my gcc installation? pi@RPi64: $ cat h.c #include <stdio.h> int main (void) { printf (&...
bomben's user avatar
  • 309
1 vote
1 answer
917 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. ...
Evgeniy Berezovsky's user avatar
0 votes
0 answers
185 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 ...
Zhendos's user avatar
1 vote
1 answer
761 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 ...
tmajz's user avatar
  • 21
2 votes
1 answer
3k 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, ...
Evgeniy Berezovsky's user avatar
0 votes
0 answers
636 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)....
straits's user avatar
2 votes
0 answers
738 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 ...
user8737703's user avatar
0 votes
0 answers
44 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 ...
lukkasremondi's user avatar
2 votes
2 answers
3k 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'...
Murderous Turd's user avatar
1 vote
1 answer
297 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 ...
nullPainter's user avatar
0 votes
1 answer
170 views

SOLVED 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. ...
Codemeister's user avatar
1 vote
1 answer
459 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 ...
vesperto's user avatar
  • 151
0 votes
2 answers
2k 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 ...
Arthur Dodin's user avatar
0 votes
1 answer
32 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 ...
Thom's user avatar
  • 117
0 votes
1 answer
105 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 ...
Manu Chadha's user avatar
0 votes
0 answers
82 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 ...
Shaun the Sheep's user avatar
0 votes
1 answer
574 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 ...
Edwin Shepherd's user avatar
0 votes
1 answer
1k 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 ...
DrakeJest's user avatar
-1 votes
1 answer
577 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.
Steve's user avatar
  • 1
2 votes
1 answer
245 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 <...
DrakeJest's user avatar
0 votes
1 answer
2k 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: ...
Alexandre A.'s user avatar
0 votes
1 answer
230 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?
user120300's user avatar
4 votes
3 answers
6k 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 ...
void's user avatar
  • 43
-1 votes
1 answer
1k 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 ...
Dyskord's user avatar
  • 119
0 votes
2 answers
50 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 ...
user120300's user avatar

1
2 3 4 5 6