Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lizard Labs Peripheral Reflex System

Similar presentations

Presentation on theme: "Lizard Labs Peripheral Reflex System"— Presentation transcript:

1 Lizard Labs Peripheral Reflex System
EFM32 Training Module Welcome to Lizard Labs. This training module will explain how the Peripheral Reflex System allows EFM32 peripherals to interact without CPU involvement. 1

2 Peripheral Reflex System
Z Z Z Z Brain Z Z The Peripheral Reflex System, PRS, is inspired by human body reflexes. The most well-known example of a human body reflex is the knee-jerk reflex; when a certain area below the patella is striked with a small hammer, the leg muscle contracts instantly and involuntarily. This happens automatically because the sensory nerve is connected directly to the motor nerve in the spine, without going the longer way through the brain. Such reflexes enables the body to react faster when in danger. Sensor nerve Motor nerve Spine

3 Peripheral Reflex System
Z Z Z Z ARM Cortex-M3 processor Z Z Peripheral reflex system On an EFM32, the Peripheral Reflex System offers a direct connection between peripherals without having to involve the CPU. As with human body reflexes, the peripheral reflex system enables autonomous, fast and predictable interaction between peripherals. EFM32 microcontrollers feature a wide selection of low energy peripherals. Each peripheral is designed to operate autonomously, so the CPU core can be put to sleep while the peripherals perform their tasks. To let the CPU to spend even more time in sleep, the Peripheral Reflex System enables one peripheral to trigger an action on another peripheral without involving the CPU. Timer ADC

4 Reflexes versus Interrupts
ARM Cortex-M3 processor CPU IRQ Energy Efficient Peripherals The traditional approach for interaction between peripherals is to use interrupts. This example shows a Timer that is used to trigger periodic A/D conversions. Once per sample period the timer will generate an interrupt to the CPU. Then the CPU must process the interrupt and start the A/D converter. Timer ADC

5 Reflexes versus Interrupts
ARM Cortex-M3 processor UNKNOWN DELAY CPU IRQ Energy Efficient Peripherals There are several disadvantages with this method. If the CPU is asleep, it must wake up before the interrupt request can be processed. And if the CPU is already busy processing another interrupt, it must finish this before the timer interrupt can be processed. In both these situations, the latency from the timer to the conversion is affected, resulting in jitter on the sampling frequency. Timer ADC

6 Reflexes versus Interrupts
ARM Cortex-M3 processor HIGH CURRENT CONSUMPTION UNKNOWN DELAY CPU IRQ Energy Efficient Peripherals It is also important to acknowledge that a large portion of the active mode current consumption is caused by the CPU. Timer ADC

7 Reflexes versus Interrupts
Z Z Z ARM Cortex-M3 processor Energy Efficient Peripherals When using the Peripheral Reflex System, the Timer can be configured to trigger the A/D conversion directly. When leaving the CPU out of the control loop, predictable timing is ensured. It also allows the CPU to be put to sleep. Timer PRS ADC

8 Peripheral Reflex System
Z Z Z ARM Cortex-M3 processor PRS Producers PRS Consumers Timer GPIO ADC DAC Peripheral Reflex System The Peripheral Reflex System can be seen as a network of wires that are routed between the different EFM32 peripherals. When using PRS, two peripherals connect to the same PRS channel; one as a producer, the other as a consumer. A PRS producer is a peripheral that generates a reflex signal on a PRS channel, while a PRS consumer is a peripheral that is triggered by a reflex signal. Each PRS channel selects one producer, while several consumers can be set up to listen to the same PRS channel. The number of PRS channels varies between 4 to 12 on the different device families. Some peripherals can act as both a producer and a consumer, enabling complex PRS event chains to be set up.

9 Peripheral Reflex System
Z Z Z ARM Cortex-M3 processor PRS Producers PRS Consumers Timer GPIO ADC DAC Peripheral Reflex System Here, two typical examples of PRS usage are shown. As you can see, a TIMER is configured as a producer on one of the PRS channels, while the A/D converter is a consumer on the same channel. The timer is generating PRS trigger signals with a fixed interval so the A/D converter can sample at a given rate. On another PRS channel, a GPIO input pin is configured as producer and the D/A converter as a consumer. This enables the EFM32 to output a voltage when triggered by an external event such as a trigger signal from another chip, a button push, or similar. PRS enables both these tasks to happen simultaneously, while the CPU is sleeping. Now, let us take a closer look at how PRS is used to trigger periodic A/D conversions while the EFM32 is in Energy Mode 1.

10 Example: ADC samples to RAM
Peripheral Reflex System Timer Start conversion Overflow Analog input DMA Request Direct Memory Access RAM Sample done Sample Data Sample Data The TIMER peripheral is selected as producer on one of the PRS channels. The TIMER is set up to count forever, and wrap around each time it overflows. On every overflow, a PRS trigger pulse is generated. The A/D converter is configured to perform one sample of a single channel when triggered by PRS. PRS can also trigger a scan mode conversion. In scan mode, a pre-configured set of ADC channels are sampled. This example also shows that DMA can be used to store the sampled data in memory. It is important to understand that data transfers are not part of the Peripheral Reflex System, but that DMA can be a very useful complement to PRS when data transfers are required. If DMA is not used, the ADC must wake the CPU with an interrupt when sample data is ready. A software example that shows how to implement this without DMA support is found in application note AN0021 Analog to Digital Converter, while AN0013 on DMA shows how to implement this with DMA support. Configuration summary: PRS: - Producer on channel #n: TIMER overflow TIMER: no PRS setup ADC: - Sample on PRS channel #n Additionally, DMA is configured to move ADC data to RAM when available. SW Examples: AN0021 Analog to Digital Converter AN0013 Direct Memory Access

11 Example: Pulse width measurement
Timer Analog input + Reset & Start Peripheral Reflex System ACMP Capture Overflow Reference - Reference Analog input Reflex signal Another example of PRS use is pulse width measurement. Here the analog comparator and the timer is used to measure pulse length of analog pulses, or pulses with a lower voltage level than the EFM32. The analog comparator output is high as long as the input is higher than the reference input. Routing the ACMP output to the TIMER through PRS, allows using the TIMER to measure how long the input signal is higher than the reference level. This example shows several of the advanced features of PRS. The PRS output of the ACMP is a level signal that is high as long as the ACMP output is high. The TIMER is configured to take different actions on the positive and the negative edge. When the PRS signal goes high, the counter is reset and starts counting from zero. When the PRS signal goes low, the timer counter value is captured. All this can be done while the EFM32 is in Energy Mode 1 and the CPU is sleeping. When the timer value is captured, an interrupt can wake the CPU so the measured length can be processed. Optionally, DMA can be used to fetch the captured data, enabling a measurement of several pulses between each wake-up. An example of how to implement this in software is found in application note AN0025 on the Peripheral Reflex System. Configuration summary: PRS: Producer = ACMP Edge detector = off Timer: Input = PRS (select prs channel) Input positive edge: reset&start Input negative edge: stop Compare/Capture channel: capture mode Compare/Capture channel: capture on input negative edge TIMER Count value Reset & Start Capture Reset & Start Capture SW Example: AN0025 Peripheral Reflex System

12 Peripherals With PRS Support
Reflex Producers ACMP ADC DAC GPIO RTC BURTC TIMER LETIMER LESENSE UART USART USB VCMP Reflex Consumers ADC DAC TIMER LESENSE UART USART PCNT Reflex signals This list presents the wide selection of peripherals that can be used with the Peripheral Reflex System. As you can see from these two quite long lists, PRS gives you lots of options for configuring direct interaction between different peripherals. To further extend the usability of PRS, most producers can trigger reflex channels on different events. One example of this is the USART, which can generate a reflex signal on one channel when a byte transmitted, and a PRS signal on another channel when a byte is received. Consumers can also perform different tasks when triggered by a reflex signal. The previous slides have already mentioned the ADC, where one reflex channel can trigger a single channel conversion and another reflex channel can trigger a scan mode conversion. The TIMER was also used as an example of a peripheral that can do different tasks on the positive and negative edge of a reflex signal.

13 PRS and Energy Modes ARM Cortex-M processor ARM Cortex-M3 processor
CPU and Memory Clock Management Energy Management ARM Cortex-M processor ARM Cortex-M3 processor Memory Protection Unit Memory Protection Unit Embedded Trace Macrocell High Freq Crystal Osc High Freq RC Osc Voltage Regulator Voltage Comparator Low Freq Crystal Osc Low Freq RC Osc Brown-out Detector Power-on Reset Flash Program Memory RAM Memory Debug Interface DMA Ultra Low Freq RC Osc Auxiliary RC Osc Auxiliary RC Osc Back-up Power Domain Peripheral Reflex System 32-bit bus Serial Interfaces I/O Ports Timers and Triggers Analog Modules Security USART UART External Bus Interface TFT Driver Timer/ Counter Low Energy Sensor IF ADC DAC AES Accelerator Low Energy Timer Real Time Counter Low Energy UART I2C External Interrupt General Purpose I/O LCD Controller Operational Amplifier PRS supports operation down to Energy Mode 3. When using PRS in low energy modes, it is important to acknowledge that both the producer and consumer peripheral must be able to operate in the wanted energy mode. For the example where periodic A/D conversions are triggered by the TIMER, we can read from the color codes in the block diagram that both peripherals are available down to EM1, so in this case any lower energy mode can not be used. The pulse width measurement example uses the analog comparator and the TIMER. The ACMP is available down to EM3, but since the TIMER requires Energy Mode 1 or above, the EFM32 can not use any energy mode below Energy Mode 1. Pulse Counter Watchdog Timer USB Pin Reset GPIO Wake-up Analog Comparator Backup RTC Available down to: EM0 Run Mode EM1 Sleep EM2 Deep Sleep EM3 Stop Mode EM4 Shutoff Mode

14 PRS API in emlib Use emlib API functions to configure PRS:
1) Configure producer as normal 2) Configure PRS channel 3) Configure consumer Emlib includes API functions for configuring PRS. When emlib is used, three simple steps will configure PRS: The first step is to configure the producer peripheral as normal. Just as if PRS is not used. Then, use the PRS API functions to configure the PRS channel itself as well as selecting a producer signal. Note that PRS_SourceSignalSet takes two input values to select the producer. One parameter to select the producer itself, and one to select a specific reflex signal from the chosen peripheral. Please refer to the device family reference manual for a complete list of reflex signals. The last step is to configure the consumer peripheral. Use the consumer peripheral API to select which reflex channel a consumer monitors, and which actions to take when a reflex signal is detected.

15 PRS on external pins PRS channels 0-3 can be routed to external pins
Useful when debugging autonomous peripherals Timer ADC PRS output on some channels can be routed to external pins. This allows PRS to connect to external devices. Routing a PRS signal to an external pin can also be a useful tool when debugging peripherals that operate while the CPU is asleep. In this example, two PRS channels are used. The first channel is used by the TIMER to trigger the A/D converter, and the second channel is used by the A/D converter to signal when the conversion is done. When routing these two PRS channels to external pins, you can connect an instrument and measure the delay from a sample is triggered to the sample is done.

16 PRS advantages Summary Energy Efficient Autonomous Highly configurable
Fast Predictable latency Highly configurable Finally, let us summarize the advantages of PRS quickly: PRS saves energy by letting peripherals communicate directly while the CPU is sleeping. PRS offers fast and predictable timing between peripherals. And PRS is highly configurable.

17 Thank you for watching this lesson from Lizard Labs. For more information, go to the Silicon Labs website. 17

Download ppt "Lizard Labs Peripheral Reflex System"

Similar presentations

Ads by Google