blackfin system services

32
The World Leader in High Performance Signal Processing Solutions Blackfin System Services Presented By: David Lannigan

Upload: pantech-prolabs-india-pvt-ltd

Post on 19-Jul-2015

520 views

Category:

Technology


3 download

TRANSCRIPT

The World Leader in High Performance Signal Processing Solutions

Blackfin System Services

Presented By: David Lannigan

2

About this Module

This module discusses the System Services software available for the Blackfin family of processors.

It is recommended that users should have some understanding of the Blackfin architecture, a basic knowledge of software terminology and experience in embedded systems.

3

Module Outline

OverviewWhat are system services?Benefits of using system services

Highlight functionality of each serviceDynamic Power ManagementExternal Bus Interface Unit (EBIU)Interrupt ManagerDeferred Callback ServiceDMA ManagerFlag ControlTimer ControlPort Control

Simple examples using the services

4

What are System Services?

Software libraryProvides functionality common to embedded systems

Simple, efficient access intoPLL, DMA, interrupt controllers, timers, flags etc.

Improved interrupt performanceDeferred callbacks

Callable from ‘C’ or assemblyCommon APIs across Blackfin processors

ADSP-BF531, BF532, BF533, BF534, BF536, BF537ADSP-BF561

Leveraged by applications, device drivers etc.Standalone environmentVDK environment

5

Benefits To Using System Services

Faster time to marketTested and proven softwareShorter learning curveLess re-invention

Modular softwareBetter compatibilitySimplifies integration efforts

PortabilityAPIs identical across Blackfin processors

Both single-core and multi-core processorsLeverage processor roadmap

Transition quickly to new processorsAccess to device driver portfolio

ADI device drivers built on top of system servicesFull source code provided

6

System Architecture

Application

DeviceDriver

RTOS (optional)

DeviceDriver

DeviceDriver

System Services

7

System Services

Port Control

Deferred CallbackDMA Manager

Interrupt Manager

Dynamic Power

EBIU (SDRAM)

Flag Control Timer Control

8

Dynamic Power Management Service

Controls Phase-Locked Loop (PLL) and internal voltage regulatorSingle function call to

Change operating modesFull-on, active, sleep, deep sleep and hibernate

Change core and system clock frequencies (CCLK and SCLK)Clock frequency priorityVoltage level automatically adjusted accordingly

Lowered whenever possible to maximize power savingsRaised when performance requires

Maximize CCLK and SCLK for given voltage levelVoltage level priorityClocks raised to max safe frequency

Automatically controls EBIU service

Port Control

Deferred CallbackDMA Manager

Interrupt Manager

Dynamic Power

EBIU (SDRAM)

Flag Control Timer Control

9

External Bus Interface Unit (EBIU)

Initializes SDRAM settingsConfigures SDRAM controller

Logic to calculate new valuesChanging SCLK frequencies

Works in concert with Power Management ServiceAutomatically adjusts settings for SCLK frequency changes

Port Control

Deferred CallbackDMA Manager

Interrupt Manager

Dynamic Power

EBIU (SDRAM)

Flag Control Timer Control

10

Using EBIU and Power Management

Application shouldInitialize the EBIU serviceInitialize the Power Management serviceCall Power Management functions as needed

Such asadi_pwr_SetFreq();adi_pwr_MaxFreqForVolt();adi_pwr_SetPowerMode();

Port Control

Deferred CallbackDMA Manager

Interrupt Manager

Dynamic Power

EBIU (SDRAM)

Flag Control Timer Control

11

Dynamic Power Management API

Initialization/TerminationADI_PWR_RESULT adi_pwr_Init(); // Initializes the power serviceADI_PWR_RESULT adi_pwr_Terminate(); // Terminates the power service

Frequency and Voltage ControlADI_PWR_RESULT adi_pwr_Control(); // Sets/queries a configuration parameterADI_PWR_RESULT adi_pwr_SaveConfig(); // Saves the power configurationADI_PWR_RESULT adi_pwr_LoadConfig(); // Loads a power configuration

ADI_PWR_RESULT adi_pwr_SetVoltageRegulator(); // Adjusts the internal voltage regulatorADI_PWR_RESULT adi_pwr_SetMaxFreqforVolt(); // Set the max clock freqs for voltage levelADI_PWR_RESULT adi_pwr_SetFreq(); // Sets the core and system clock frequenciesADI_PWR_RESULT adi_pwr_AdjustFreq(); // Adjusts the core and system clock frequenciesADI_PWR_RESULT adi_pwr_GetFreq(); // Gets the core and system clock frequencies

Operating ModesADI_PWR_RESULT adi_pwr_SetPowerMode(); // Place processor in specified operating modeADI_PWR_RESULT adi_pwr_GetPowerMode(); // Gets the current operating mode

12

EBIU Service API

Initialization/TerminationADI_EBIU_RESULT adi_ebiu_Init(); // Initializes the EBIU serviceADI_EBIU_RESULT adi_ebiu_Terminate(); // Terminates the EBIU service

EBIU ControlADI_EBIU_RESULT adi_ebiu_Reset(); // Resets the EBIU module to power-up settingsADI_EBIU_RESULT adi_ebiu_Control(); // Sets/queries module settingsADI_EBIU_RESULT adi_ebiu_AdjustSDRAM(); // Recalculates and apply settings for SCLK changes

EBIU ConfigurationADI_EBIU_RESULT adi_ebiu_LoadConfig(); // Loads a set of controller settingsADI_EBIU_RESULT adi_ebiu_SaveConfig() // Saves a set of controller settings

13

Dynamic Power Example

Dynamic PowerService

Change frequencies,voltage, operating

mode

EBIUService

Phase LockedLoop (PLL)

SDRAM

VoltageRegulator

Adjust timings

14

Interrupt Manager Service

Core Event Controller (CEC)Hook/Unhook interrupt handlers into Interrupt Vector Groups (IVG)Supports handler chaining

System Interrupt Controller (SIC)Mapping of peripheral interrupts to IVGEnable/disable passing to core event controllerEnable/disable wakeup of core event controller

Utility functionsCritical region protectionInterrupt Mask Register (IMASK) control

Port Control

Deferred CallbackDMA Manager

Interrupt Manager

Dynamic Power

EBIU (SDRAM)

Flag Control Timer Control

15

Interrupt Manager API

Initialization/TerminationADI_INT_RESULT adi_int_Init(); // Initializes the interrupt managerADI_INT_RESULT adi_int_Terminate(); // Terminates the interrupt manager

Core Event Controller FunctionsADI_INT_RESULT adi_int_CECHook(); // Hooks a handler into an IVG chainADI_INT_RESULT adi_int_CECUnhook(); // Unhooks a handler from an IVG chain

System Interrupt Controller FunctionsADI_INT_RESULT adi_int_SICEnable(); // Allows interrupt to be passed to the CECADI_INT_RESULT adi_int_SICDisable(); // Disallows interrupt to be passed to the CECADI_INT_RESULT adi_int_SICSetIVG(); // Sets the IVG to which a peripheral is mappedADI_INT_RESULT adi_int_SICGetIVG(); // Gets the IVG to which a peripheral is mappedADI_INT_RESULT adi_int_SICWakeup(); // Allows the interrupt to wakeup the processorADI_INT_RESULT adi_int_SICInterruptAsserted(); // Tests if an interrupt is asserted

Utility Functionsvoid *adi_int_EnterCriticalRegion(); // Enters a critical region of codevoid adi_int_ExitCriticalRegion(); // Exits a critical region of codevoid adi_int_SetIMaskBits(); // Sets bits in IMASK registervoid adi_int_ClearIMaskBits(); // Clears bits in IMASK register

16

Interrupt Manager Example

System InterruptController (SIC)

RTC

Minute Interrupt

Main program

InterruptHandler

InterruptManager

Core EventController (CEC)

17

What’s a Callback?

Call made to a function outside the normal flow of program execution

Response to an asynchronous event (hardware interrupt)Callback Function

Regular ‘C’ callable functionTakes some action based on the event

Types of CallbacksLive

Call to the function is made immediatelyCallback function typically executes at hardware interrupt timeNegative impact to performance (higher interrupt latency)

DeferredCall to the function is deferred to some later point in timeCallback function executes at software interrupt timePositive impact to performance (lower interrupt latency)

18

Deferred Callback Manager

Reduce time spent in hardware Interrupt Service Routines (ISR)Service hardware, queue the callback and exit

Map callback services to different IVG levelsUser specifies level(s)

Typically lower than hardware levelsPrioritization within each level

Urgent callbacks processed firstOperating environments

Standalone systemsCallbacks execute before “normal” user code

VDK based systemsCallbacks run at software interrupt thread

Port Control

Deferred CallbackDMA Manager

Interrupt Manager

Dynamic Power

EBIU (SDRAM)

Flag Control Timer Control

19

Deferred Callback Service API

Initialization/TerminationADI_DCB_RESULT adi_dcb_Init(); // Initializes the deferred callback serviceADI_DCB_RESULT adi_dcb_Terminate(); // Terminates the deferred callback service

Callback Queue Server ControlADI_DCB_RESULT adi_dcb_Open(); // Opens a callback queueADI_DCB_RESULT adi_dcb_Close(); // Closes a callback queueADI_DCB_RESULT adi_dcb_Control(); // Changes settings of a callback queue

ADI_DCB_RESULT adi_dcb_Post(); // Posts a callback to a queueADI_DCB_RESULT adi_dcb_Remove(); // Removes callbacks from a queue

20

DMA Manager

Controls and schedules DMASupports both peripheral and memory DMAUser control of DMA channel mappings/priority, traffic control

Comprehensive support for DMA modesDescriptor chaining (large, small)

Queues descriptor jobsAutobuffering (called circular buffers)

MemCopy functionsDMA transfers rather than core accessOne dimensional and two dimensional

Optional callbacks on completionLive or deferred

Port Control

Deferred CallbackDMA Manager

Interrupt Manager

Dynamic Power

EBIU (SDRAM)

Flag Control Timer Control

21

DMA Manager APIInitialization/TerminationADI_DMA_RESULT adi_dma_Init(); // Initializes the DMA managerADI_DMA_RESULT adi_dma_Terminate(); // Terminates the DMA manager

Channel ControlADI_DMA_RESULT adi_dma_Open(); // Opens a channel for useADI_DMA_RESULT adi_dma_Close(); // Closes a channelADI_DMA_RESULT adi_dma_Control(); // Configures a channelADI_DMA_RESULT adi_dma_Queue(); // Posts a chain of descriptors to a channelADI_DMA_RESULT adi_dma_Buffer(); // Provides a one-shot or circular job to a channel

Memory Stream ControlADI_DMA_RESULT adi_dma_MemoryOpen(); // Opens a memory streamADI_DMA_RESULT adi_dma_MemoryClose(); // Closes a memory streamADI_DMA_RESULT adi_dma_MemoryCopy(); // Performs a one-dimensional memory transferADI_DMA_RESULT adi_dma_MemoryCopy2D(); // Performs a two-dimensional memory transfer

Channel MappingsADI_DMA_RESULT adi_dma_SetMapping(); // Sets the mapping of a channel to a peripheralADI_DMA_RESULT adi_dma_GetMapping(); // Gets the mapping of a channel to a peripheral

22

Memory DMA Example

SourceOpen memory stream

and copy dataMain program

CallbackFunction

DMAManager

Destination

DMAController

Callback uponcompletion

Do another copy

23

Flag Control Service

Controls general purpose programmable flags (GPIO)All hardware capabilities exposed

Set directionSet/clear/toggle levelSense level

Provides callback capabilityCallback function invoked upon trigger condition

Level sensitiveHigh/low

Edge sensitiveRising/falling/either

Live or deferred

Port Control

Deferred CallbackDMA Manager

Interrupt Manager

Dynamic Power

EBIU (SDRAM)

Flag Control Timer Control

24

Flag Control API

Initialization/TerminationADI_FLAG_RESULT adi_flag_Init(); // Initializes the flag serviceADI_FLAG_RESULT adi_flag_Terminate(); // Terminates the flag service

Flag ControlADI_FLAG_RESULT adi_flag_Open(); // Opens a flag for useADI_FLAG_RESULT adi_flag_Close(); // Closes a flagADI_FLAG_RESULT adi_flag_SetDirection(); // Configures the flag for input or outputADI_FLAG_RESULT adi_flag_Set(); // Sets a flag to logical 1ADI_FLAG_RESULT adi_flag_Clear(); // Sets a flag to logical 0ADI_FLAG_RESULT adi_flag_Toggle(); // Toggles the current value of a flagADI_FLAG_RESULT adi_flag_Sense(); // Senses the value of a flag

Flag Callback ControlADI_FLAG_RESULT adi_flag_InstallCallback(); // Installs a callback for sensing flag changesADI_FLAG_RESULT adi_flag_RemoveCallback(); // Removes a callback from a flagADI_FLAG_RESULT adi_flag_SetTrigger(); // Sets the trigger condition for a flag callbackADI_FLAG_RESULT adi_flag_SuspendCallbacks(); // Temporarily suspend callbacks for a flagADI_FLAG_RESULT adi_flag_ResumeCallbacks(); // Resume callbacks for a flag

25

Flag Control Example

Pushbuttonon EZ-Kit

Configure flag as an inputand install callback

Main program

CallbackFunction

Flag Control ProgrammableFlag

Callback upontrigger condition

26

Timer Control Service

Controls operation of timersFull access into all modes and features

Core timerCount, period, scale, auto-reload

Watchdog timerSelect timeout event, reset counter

General purpose timersPWM, WidthCapSimultaneous enable/disable

Provides callback capabilityCallback function upon timer expirationLive or deferred

Port Control

Deferred CallbackDMA Manager

Interrupt Manager

Dynamic Power

EBIU (SDRAM)

Flag Control Timer Control

27

Timer Control API

Initialization/TerminationADI_TMR_RESULT adi_tmr_Init(); // Initializes the timer serviceADI_TMR_RESULT adi_tmr_Terminate(); // Terminates the timer service

Timer ControlADI_TMR_RESULT adi_tmr_Open(); // Opens a timer for useADI_TMR_RESULT adi_tmr_Close(); // Closes a timerADI_TMR_RESULT adi_tmr_Reset(); // Resets a timer to power-up settingsADI_TMR_RESULT adi_tmr_GetPeripheralID(); // Gets the peripheral ID for a timer

ADI_TMR_RESULT adi_tmr_CoreControl(); // Controls the core timer

ADI_TMR_RESULT adi_tmr_WatchdogControl(); // Controls the watchdog timer

ADI_TMR_RESULT adi_tmr_GPControl(); // Controls a general purpose timerADI_TMR_RESULT adi_tmr_GPGroupEnable(); // Simultaneously enables/disables a group of timers

Timer Callback ControlADI_TMR_RESULT adi_tmr_InstallCallback(); // Installs a callback for a timerADI_TMR_RESULT adi_tmr_RemoveCallback(); // Removes a callback from a timer

28

Port Control Service

Controls assignment of muxed pinsApplicable to ADSP-BF534, ADSP-BF536, ADSP-BF537 only

Operation largely transparent to applicationsApplication need only initialize port controlNo other application involvement required

Automatically accessed by drivers and other servicesExamples

PPI driverData width, frame sync pins etc.

Timer serviceInput clocks/output signals

Flag serviceConfigures as appropriate for flag pins

Port Control

Deferred CallbackDMA Manager

Interrupt Manager

Dynamic Power

EBIU (SDRAM)

Flag Control Timer Control

29

Port Control API

Initialization/TerminationADI_PORTS_RESULT adi_ports_Init(); // Initializes the port control serviceADI_PORTS_RESULT adi_ports_Terminate(); // Terminates the port control service

Peripheral Based ControlADI_PORTS_RESULT adi_portsEnablePPI(); // Configures pins for PPI operationADI_PORTS_RESULT adi_portsEnableSPI(); // Configures pins for SPI operationADI_PORTS_RESULT adi_portsEnableSPORT(); // Configures pins for SPORT operationADI_PORTS_RESULT adi_portsEnableUART(); // Configures pins for UART operationADI_PORTS_RESULT adi_portsEnableCAN(); // Configures pins for CAN operationADI_PORTS_RESULT adi_portsEnableTimer(); // Configures pins for timer operationADI_PORTS_RESULT adi_portsEnableGPIO(); // Configures pins for flag operation

Profile Based ControlADI_PORTS_RESULT adi_ports_SetProfile(); // Sets a muxing profileADI_PORTS_RESULT adi_ports_GetProfile(); // Gets a muxing profile

30

Include filesC:\Program Files\Analog Devices\VisualDSP 4.0\Blackfin\include\services

Source filesC:\Program Files\Analog Devices\VisualDSP 4.0\Blackfin\lib\src\services

LibrariesC:\Program Files\Analog Devices\VisualDSP 4.0\Blackfin\lib

ExamplesC:\Program Files\Analog Devices\VisualDSP 4.0\Blackfin\EZ-KITs\ADSP-BF533\Services

C:\Program Files\Analog Devices\VisualDSP 4.0\Blackfin\EZ-KITs\ADSP-BF537\Services

C:\Program Files\Analog Devices\VisualDSP 4.0\Blackfin\EZ-KITs\ADSP-BF561\Services

DocumentationDevice Driver and System Services User Manual

Blackfin Technical Library at www.analog.com

Device Driver and System Services User Manual Addendum (Sept 2005)ftp://ftp.analog.com/pub/tools/patches/Blackfin/VDSP++4.0/

Finding the System Services

31

Conclusion

System services provide:Faster development

Stable software base for application developmentFewer variables

Less re-inventionDon’t need to create everything from scratch

Modular softwareBetter compatibility

Resource control is managed by the system servicesEasier integration

Multiple software components working concurrentlyPortability

Code portable to other Blackfin processors

32

Additional Information

DocumentationDevice Drivers and System Services Manual for Blackfin Processors

−http://www.analog.com/processors/resources/technicalLibrary/manuals/index.htmlDevice Drivers and System Services Addendum (Sept 2005)

− ftp://ftp.analog.com/pub/tools/patches/Blackfin/VDSP++4.0/

For questions, click “Ask A Question” button