In order for our digital embedded systems to interact with the analog world around us, they must convert those analog signals into a digital representation that microcontrollers can understand and process. Analog-to-digital converters (ADC) are used in nearly every embedded system to perform this conversion but quite frankly, they are potentially the worst peripheral to setup due to nearly endless options and complexity. The Renesas Synergy™ Platforms ADC Periodic Application Framework once again comes to the developers rescue and dramatically simplifies interfacing to the analog world.

  

 

The ADC Periodic Application Framework is designed to quickly setup analog measurements that sample preselected channels and store the samples in a buffer. The channels are sampled on their own and the primary application is only notified once the preconfigured sample number has been reached. The application is notified that the samples are complete through callback functions, which is a common theme throughout the Synergy Platform. The ADC Application Framework provides developers with a very powerful feature set. For example, developers can decide whether they want to use the GPT or the AGT to trigger the samples. Even better, developers concerned with efficiency, low power design and minimizing CPU intervention can use the DMA and DTC to keep the CPU hands-off and maximize efficiency.

 

Despite the powerful features included in the ADC Application Framework, getting the framework up and running is straight forward. Once again, from the Synergy Configuration, we select the thread that we want to include the ADC Periodic Application Framework. Within the Thread Stacks view, under Frameworks > Analog add the g_sf_adc_periodic framework. The end result, can be seen below:

 

 

As can be seen, this application framework has a few dependencies. The first, is the transfer driver that can be used to automate transferring the conversion results to different memory locations within the microcontroller. Second, there is the periodic timer that will drive the conversions. As I mentioned earlier, this can be either the GPT or the AGT but by default the GPT is used. Finally, there is the dependence on the ADC Driver.

 

The ADC driver requires a few additional configuration parameters in order to get the framework up and running. First, an interrupt priority must be configured for the end of scan. Next, a developer must decide on the required conversion resolution. The resolution capabilities vary from one Synergy microcontroller to the next but each supports 12-bits. The S7 can also support 8-bit and 10-bit resolution while the S3 and S1 support 14-bit. The ADC Driver properties allow a developer to set these values in addition to selecting which channels will be included in the conversions. The ADC’s channels available will vary based on the part and family used in an application. For example, every Synergy microcontroller supports channels 0 – 6. Channels 7 – 10 are only supported by the S3 and S1. Channels 11 - 15 are only supported on the S3. Looking through the driver properties reveals twenty-seven different channels in addition to an internal voltage and temperature channel.

 

 

 

 

Enabling a channel is as simple as going into the driver properties and changing a channel from Unused to Use in Group A or Use in Group B”. It’s that simple!

 

Next time we will investigate the IIC Framework. In the mean-time,

 

Live long and profit!

 

Professor_IoT

 

 

Hot Tip of the Week

If you are interested in seeing an Application Project that demonstrates a real world example of the ADC Periodic Framework, look no further than the Simple Tone Generator. This Application Project reads the potentiometer setting, on the DK-S124 Kit, to vary the frequency of a generated tone. The ADC Periodic Framework implements the periodic scan and illustrates the use of the associated callback function. You can find this Application Project from the Synergy Tools and Kits page here: https://www.renesas.com/en-us/products/synergy/tools-kits.html# and then select the Sample Program tab, expand the drop down list by clicking on the right arrow (“>”), then check the box for Analog Conversion Function and click on Search. The DK-S124 Simple Tone Generator project will show up at the top of the list.