Questions tagged [c]
For questions pertaining to compiling C programs on the Raspberry Pi.
274
questions
0
votes
1
answer
52
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 :
...
0
votes
0
answers
37
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 ...
0
votes
0
answers
35
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 ...
0
votes
0
answers
85
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 ...
0
votes
0
answers
17
views
pari gp ínstallation in rpi
I am trying to compile one of a project with pari library dependency but i am facing below error while running the configuration file. Its installing just fine in ubuntu and windows but not here. I ...
1
vote
0
answers
103
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 ...
0
votes
1
answer
192
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 ...
1
vote
1
answer
41
views
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,...
2
votes
0
answers
149
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 ...
1
vote
2
answers
62
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 ...
1
vote
0
answers
32
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 ...
1
vote
1
answer
578
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 ...
1
vote
1
answer
47
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 ...
1
vote
1
answer
217
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 ...
-1
votes
1
answer
190
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>
#...
2
votes
1
answer
784
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"...
1
vote
0
answers
265
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 ...
0
votes
0
answers
121
views
500khz adc measurements using micropython
Following the "getting started" guide for the Pico, I know its possible to read the ADC at 500khz if you also do DMA. The example does it using C. Is it possible to do this in Micropython?
...
0
votes
1
answer
995
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 ...
0
votes
2
answers
346
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 ...
-1
votes
1
answer
513
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 (&...
1
vote
1
answer
658
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. ...
0
votes
0
answers
130
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 ...
1
vote
1
answer
647
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 ...
2
votes
1
answer
2k
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, ...
0
votes
0
answers
522
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)....
2
votes
0
answers
571
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 ...
0
votes
0
answers
36
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 ...
3
votes
1
answer
2k
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'...
1
vote
1
answer
230
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 ...
0
votes
1
answer
140
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.
...
1
vote
1
answer
357
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 ...
0
votes
2
answers
1k
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 ...
0
votes
1
answer
31
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 ...
0
votes
1
answer
64
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 ...
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 ...
0
votes
1
answer
456
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 ...
0
votes
1
answer
292
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 ...
-1
votes
1
answer
465
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.
2
votes
1
answer
181
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 <...
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:
...
0
votes
1
answer
181
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?
2
votes
2
answers
3k
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 ...
-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 ...
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 ...
1
vote
2
answers
172
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?
0
votes
1
answer
98
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 ...
0
votes
0
answers
128
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(...
1
vote
2
answers
619
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 ...
1
vote
1
answer
89
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 ...