I am getting a signal at 1 GPIO which i need to read at an interval of exactly 10^ (-6) seconds. I am using wiringpi.h in C and the issue is that digitalRead() also takes some time thus i am not able to ensure exact timing. Please Suggest a solution
My 2 cents:
Similar to the Arduino (8 bit AVR based uC) recommendation I would look at the far more capable STM32 series from ST microelectronics.
- There are at least two good Arduino API ports here and here,
- Great support forum
- Inexpensive: ~$2 for the cheapest breakout boards - "Bluepill" and a reusable ST Link V2 clone programmer
- Plethora of periperials like SPI, I2C, USART, USB, DMA and sophisticated Timers with a 32 bit ARM Cortex M0/M3/M4 CPU
With a bit of ramp up you could use a combination of DMA, Timers and CPU logic to acquire from GPIO pins, condition, compress and stream out the data via USB, possibly even to a Raspberry Pi.
Using PlatformIO with VSCode/Atom makes development much easier
I think a simple sequential logic circuit can easily do the job in a couple of steps.
Get a 32 MHz clock.
Every 1 uS clock one bit data input to a D type flip flop and feed its output to a serial to 8 bit parallel register.
Every 8 uS clock the parallel register contents into a flash memory.
For an Electronics Enggr major undergrad, I think it is much easier to do the above 3 steps using sequential logic than debugging a messy mpu/mcu macro assembly program.
Using amtel/arm/stm mpu/mcu/ etc, you still need to read one bit every uS, and do the serial to parallel job before storing the 8 bit word to some flash memory. In other words, just wasting time and money.
The advantage of using logic circuit is that Rpi can directly oversee and control everything, without losing one bit of data. Once Rpi starts the bit D flip flop + flash memory reader, it can leave it standalone reading bit non stop into the flash memory, which Rpi can come back any time to read the flash, like it is a 1Gbit long FIFO or circular buffer.
My electronics skills are very rusty. Perhaps we can pass the question to the Electronics and Arduino Stack Exchange and see what they think.
By the way, don't say that 1uS is fast, because those EE guys talking nS/pS everyday would LOL!
After reading the answer from @Shreyas Murali, I think I need to point out that I don't encourage any electronic enggr beginners to learnt basic logic gates circuit design, for the same reason that newbies should not learn assembly language hoping to earn a living, because over these years hardware has become so fast that even "slow" C in mcu becomes fast enough for tasks in real life. There is no need to use assembly language which might run fast but the much longer development time is not worth it.
IN short, life is too short to learn things that could not earn you a living.
Rpi Raspbian is not realtime OS and as such is very weak in real time IO.
My first Arduino is Decimilla and last Arduino Due (ARM Cortex-M3).
Now the ugly Arduino vendors are suing each other, and I don't want to hear the name XYZduino any more.
To do realtime tasks, I would start a fresh with something like STM32 Blue Pill, which I all the things I dream but Rpi will not give, even Rpi4, 5, 6 (USART x 3, I2C x 2, SPI x 2, Can x 1, ...).
What I want is humble, only more UART/SPI/I2C channels. I actually had them when I played with small guys like PyBoard, ...