Presentation on theme: "Lizard Labs Peripheral Reflex System"— Presentation transcript:
1 Lizard Labs Peripheral Reflex System EFM32 Training ModuleWelcome to Lizard Labs. This training module will explain how the PeripheralReflex System allows EFM32 peripherals to interact without CPU involvement.1
2 Peripheral Reflex System ZZZZBrainZZThe 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 nerveMotor nerveSpine
3 Peripheral Reflex System ZZZZARM Cortex-M3 processorZZPeripheral reflex systemOn 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.TimerADC
4 Reflexes versus Interrupts ARM Cortex-M3 processorCPUIRQEnergy Efficient PeripheralsThe 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.TimerADC
5 Reflexes versus Interrupts ARM Cortex-M3 processorUNKNOWN DELAYCPUIRQEnergy Efficient PeripheralsThere 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.TimerADC
6 Reflexes versus Interrupts ARM Cortex-M3 processorHIGH CURRENT CONSUMPTIONUNKNOWN DELAYCPUIRQEnergy Efficient PeripheralsIt is also important to acknowledge that a large portion of the active mode current consumption is caused by the CPU.TimerADC
7 Reflexes versus Interrupts ZZZARM Cortex-M3 processorEnergy Efficient PeripheralsWhen 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.TimerPRSADC
8 Peripheral Reflex System ZZZARM Cortex-M3 processorPRS ProducersPRS ConsumersTimerGPIOADCDACPeripheral Reflex SystemThe 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 ZZZARM Cortex-M3 processorPRS ProducersPRS ConsumersTimerGPIOADCDACPeripheral Reflex SystemHere, 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 SystemTimerStart conversionOverflowAnalog inputDMA RequestDirect Memory AccessRAMSample doneSample DataSample DataThe 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 overflowTIMER:no PRS setupADC:- Sample on PRS channel #nAdditionally, DMA is configured to move ADC data to RAM when available.SW Examples:AN0021 Analog to Digital ConverterAN0013 Direct Memory Access
11 Example: Pulse width measurement TimerAnalog input+Reset & StartPeripheral Reflex SystemACMPCaptureOverflowReference-ReferenceAnalog inputReflex signalAnother 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 = ACMPEdge detector = offTimer:Input = PRS (select prs channel)Input positive edge: reset&startInput negative edge: stopCompare/Capture channel: capture modeCompare/Capture channel: capture on input negative edgeTIMER Count valueReset & StartCaptureReset & StartCaptureSW Example: AN0025 Peripheral Reflex System
12 Peripherals With PRS Support Reflex ProducersACMPADCDACGPIORTCBURTCTIMERLETIMERLESENSEUARTUSARTUSBVCMPReflex ConsumersADCDACTIMERLESENSEUARTUSARTPCNTReflex signalsThis 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 MemoryClock ManagementEnergy ManagementARM Cortex-M processorARM Cortex-M3 processorMemory ProtectionUnitMemory Protection UnitEmbedded Trace MacrocellHigh FreqCrystal OscHigh FreqRC OscVoltage RegulatorVoltage ComparatorLow FreqCrystal OscLow FreqRC OscBrown-outDetectorPower-onResetFlashProgram MemoryRAMMemoryDebugInterfaceDMAUltra Low Freq RC OscAuxiliaryRC OscAuxiliaryRC OscBack-up Power DomainPeripheral Reflex System32-bit busSerial InterfacesI/O PortsTimers and TriggersAnalog ModulesSecurityUSARTUARTExternal Bus InterfaceTFTDriverTimer/ CounterLow Energy Sensor IFADCDACAESAcceleratorLow Energy TimerReal Time CounterLow EnergyUARTI2CExternalInterruptGeneralPurposeI/OLCDControllerOperational AmplifierPRS 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.PulseCounterWatchdogTimerUSBPinResetGPIOWake-upAnalogComparatorBackupRTCAvailable down to:EM0Run ModeEM1SleepEM2Deep SleepEM3Stop ModeEM4Shutoff Mode
14 PRS API in emlib Use emlib API functions to configure PRS: 1) Configure producer as normal2) Configure PRS channel3) Configure consumerEmlib 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 peripheralsTimerADCPRS 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 FastPredictable latencyHighly configurableFinally, 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