I have a couple of questions regarding the Analog-to-Digital Converter (ADC) configuration in Particleboard P0, P1 and P2.
For P1, I couldn't find specific information about its ADC in the documentation. However, P1 employs the STM32F205RGY6 microcontroller, which has 3 ADCs with 16 channels in total. P1, on the other hand, only provides 13 pins for ADC usage. Does this mean that P1 doesn't utilize all of the three ADCs on the STM32F205RGY6? If so, how many ADCs does P1 actually use? Or it uses all these three ADCs, but just use parts of the channels?
Regarding P0, it also uses the STM32F205RGY6 MCU and offers only 8 pins for ADC input. Similar to P1, does P0 also utilize a subset of the available ADCs on the STM32F205RGY6? If so, how many ADCs are utilized by P0? Or it also uses all these three ADCs, but just use parts of the channels?
Moving on to P2, I noticed that it has 6 ADC input pins as specified in the datasheet.
However, when I reviewed the datasheet for the Realtek RTL8721DM, I found that it provides 7 ADC channels.
Does this imply that P2 utilizes 6 out of the 7 ADC channels available on the RTL8721DM? I'm particularly interested in interleaving ADCs to enhance the sampling rate. Will P2 support such an arrangement?
Thank you for your assistance in clarifying these details.
On STM32 devices,
analogRead() uses two ADC blocks in the MCU running in parallel, and averages the output. The number of channels available in as specified in the datasheets, 8 on the Photon/P0 and 13 on the P1. The other channels are not available for use as ADC inputs. It is possible to use all three ADCs and DMA from user firmware, but there is no support in Device OS for doing so.
On the P2 and Photon 2, there are 6 pins that can be used for ADC. The 7th ADC input is used for VBAT_MEAS for measuring the battery voltage.
If you need a lot of ADCs, the best option is to add a SPI or I2C ADC chip.
Thank you so much for your reply!
I have some questions about particle photon, which offers 8 pins for ADC input. I wonder are all of these pins connected ADC1? Are there any pins mapped to ADC2?
On STM32 devices, the mapping between an ADC pin and its hardware ADC (1-3) is done in software.
An ADC input on the Photon are read simultaneously by both ADC1 and ADC2 and the values averaged when
analogRead() is called.
If you implement custom ADC reading you could simultaneously read any three pins at the same time using the three ADC channels, but there is no support for this in Device OS. It can be done from user firmware, however, with a lot of low-level STM32-specific code.
I'm currently delving into the Device OS firmware for the Particle Photon so as to customize ADC, and have encountered some problems. I am specifically looking to understand the ADC pin mapping and functionality for the Photon. However, I'm facing some confusion:
device-os/platform/MCU directory, the code appears to be tailored for Photon 2. Is there a separate section or repository for the original Photon?
hal/src directory doesn't seem to contain specific source files for the Photon either:
Could you please point me in the right direction to find the ADC pin mapping and functionality specifically for the Particle Photon within the Device OS firmware? Any guidance on navigating the codebase or documentation would be greatly appreciated.
develop branch in device-os only supports Gen 3 and later platforms.
To work with the Photon 1, look at the
Also look at the photonAudio repo. Example 3 shows how to use the ADC in DMA mode on STM32 devices. It can be done entirely from user firmware without having to modify Device OS. Also, the STM32 standard peripheral library is available to user firmware which makes it much easier.
The only caveat is that a special technique is necessary if you need to handle an interrupt. The photonAudio example shows how to do it using attachSystemInterrupt.
I have another question about the buffer size. I try to increase the buffer size to 48KB, but it cannot be compiled.
When I use 10KB or 20KB, it has no problem. I wonder why the buffer cannot be larger? And how large the buffer can be?
The free RAM on the Photon 1 is around 55K, so depending on the RAM usage in the rest of your program, it's not surprising that 20K works and 48K doesn't.
And you can't use everything report\ed from
System.freeMemory() because the system needs some (especially if you use listening mode) and also because of general use and fragmentation.