Hello BeagleBone experts,
I’m trying to use SPI or ADC to sample data deterministically at very high frequency something like 1Mhz. I have tried to gather information about both BB Black and BB AI, played with both but now have a feeling this may not be achievable.
Here are what I see plus some questions:
- Use PRU to control ADC on BB Black the max can get is 200khz.
- BB AI Arm5279 doesn’t have on chip ADC, it’s through I2C. What’s the maximum sampling rate?
- PRU doesn’t have I2C, so how to achieve PRU to control ADC on BB AI?
- SPI on BB Black max frequency is 48Mhz. SPI spec on BB AI has listed as “To Do”, what’s the maximum frequency there?
- PRU doesn’t have SPI, how to make sampling data consistently? Is there anything available to use PRU to control Arm on chip SPI?
- Saw some PRU bit bang code for SPI and I2C with many limitations basically not very useable for multiple slaves.
Appreciate all your answers.
I worked with the PRU and the I2C but never used the onboard ADC instead I used an I2C sensor. You might be able to use an external ADC if you want to use SPI. Here are the codes I have developed to control the I2C bus of the Beaglebone AI using the PRU code here I hope it helps!
If you need help on developing something similar for the SPI I would be happy to help!
Thank you so much for your reply and providing the PRU/I2C code. How fast can the sampling rate be? I’m not very familiar with PRU yet. I can set/read some GPIO pins directly from PRU through mapped registers. In your code, are you using PRU to map and access ARM registers directly to control the I2C and pass every sensor read sample result back to user space? Does that mean you can access all ARM registers from PRU directly including SPI too? If that’s case, there should be code developed for SPI already somewhere, right? I wonder why people use PRU digital IO to bit-banging SPI/I2C. See this discussion PRU - ADC on BBAI - #2 by Dennis_Bieber
The sampling rate is relatively low (a couple of kHz max), and I don’t think I2C will work for your application. It is limited by the mode of the I2C communication in Fast Mode for my implementation, but even the High-Speed Mode will not work.
Yes, I am writing directly into the register that controls the I2C bus (starting at address 0x4807 0000 for I2C1).
I guess you can do something similar for the SPI, I don’t know of any implementation yet, but I have not looked for it either.
I don’t know why people use bit-banging, maybe to avoid developing an SPI driver ?
Got it about the register address. Thanks for that. I thought bit-banging has more work than using those registers. I’m also wondering even use PRU to control SPI register directly, while sampling data, if there are interrupts at ARM side from many other things happening which as always, will the sampling data still has jitter? I may ask you for help when I get to it. Now I’m trying to get the ADC to work first. Thanks.