CLA Module

The Control Law Accelerator (CLA) API provides a set of functions to configure the CLA. The CLA is an independent accelerator with its own buses, ALU and register set. It does share memory, both program and data, with the main processor; it comes out of a power reset with no memory assets and therefore the C28x must configure how the CLA runs, which memory spaces it uses, and when code must run.

The primary use of the CLA is to implement small, fast control loops that run periodically, responding to specific trigger sources like the PWM or an ADC conversion in a deterministic (fixed and low latency) fashion.

group cla_api

This module is used for configurating CLA.

Defines

CLA_NUM_EOT_INTERRUPTS (8U)
CLA_TASKFLAG_1 (0x01U)

CLA Task 1 Flag.

CLA_TASKFLAG_2 (0x02U)

CLA Task 2 Flag.

CLA_TASKFLAG_3 (0x04U)

CLA Task 3 Flag.

CLA_TASKFLAG_4 (0x08U)

CLA Task 4 Flag.

CLA_TASKFLAG_5 (0x10U)

CLA Task 5 Flag.

CLA_TASKFLAG_6 (0x20U)

CLA Task 6 Flag.

CLA_TASKFLAG_7 (0x40U)

CLA Task 7 Flag.

CLA_TASKFLAG_8 (0x80U)

CLA Task 8 Flag.

CLA_TASKFLAG_ALL (0xFFU)

CLA All Task Flag.

Enums

enum CLA_TaskNumber

Values that can be passed to CLA_getPendingTaskFlag(), CLA_getTaskOverflowFlag(), CLA_getTaskRunStatus(), CLA_setTriggerSource(), CLA_registerEndOfTaskInterrupt(), and CLA_unregisterEndOfTaskInterrupt() as the taskNumber parameter.

Values:

enumerator CLA_TASK_1

CLA Task 1.

enumerator CLA_TASK_2

CLA Task 2.

enumerator CLA_TASK_3

CLA Task 3.

enumerator CLA_TASK_4

CLA Task 4.

enumerator CLA_TASK_5

CLA Task 5.

enumerator CLA_TASK_6

CLA Task 6.

enumerator CLA_TASK_7

CLA Task 7.

enumerator CLA_TASK_8

CLA Task 8.

enum CLA_MVECTNumber

Values that can be passed to CLA_mapTaskVector() as the claIntVect parameter.

Values:

enumerator CLA_MVECT_1 = 0x0U

Task Interrupt Vector 1.

enumerator CLA_MVECT_2 = 0x1U

Task Interrupt Vector 2.

enumerator CLA_MVECT_3 = 0x2U

Task Interrupt Vector 3.

enumerator CLA_MVECT_4 = 0x3U

Task Interrupt Vector 4.

enumerator CLA_MVECT_5 = 0x4U

Task Interrupt Vector 5.

enumerator CLA_MVECT_6 = 0x5U

Task Interrupt Vector 6.

enumerator CLA_MVECT_7 = 0x6U

Task Interrupt Vector 7.

enumerator CLA_MVECT_8 = 0x7U

Task Interrupt Vector 8.

enum CLA_Trigger

Values that can be passed to CLA_setTriggerSource() as the trigger parameter.

Values:

enumerator CLA_TRIGGER_SOFTWARE = 0U

CLA Task Trigger Source is Software.

enumerator CLA_TRIGGER_ADCA1 = 1U

CLA Task Trigger Source is ADCA1.

enumerator CLA_TRIGGER_ADCA2 = 2U

CLA Task Trigger Source is ADCA2.

enumerator CLA_TRIGGER_ADCA3 = 3U

CLA Task Trigger Source is ADCA3.

enumerator CLA_TRIGGER_ADCA4 = 4U

CLA Task Trigger Source is ADCA4.

enumerator CLA_TRIGGER_ADCAEVT = 5U

CLA Task Trigger Source is ADCAEVT.

enumerator CLA_TRIGGER_ADCB1 = 6U

CLA Task Trigger Source is ADCB1.

enumerator CLA_TRIGGER_ADCB2 = 7U

CLA Task Trigger Source is ADCB2.

enumerator CLA_TRIGGER_ADCB3 = 8U

CLA Task Trigger Source is ADCB3.

enumerator CLA_TRIGGER_ADCB4 = 9U

CLA Task Trigger Source is ADCB4.

enumerator CLA_TRIGGER_ADCBEVT = 10U

CLA Task Trigger Source is ADCBEVT.

enumerator CLA_TRIGGER_ADCC1 = 11U

CLA Task Trigger Source is ADCC1.

enumerator CLA_TRIGGER_ADCC2 = 12U

CLA Task Trigger Source is ADCC2.

enumerator CLA_TRIGGER_ADCC3 = 13U

CLA Task Trigger Source is ADCC3.

enumerator CLA_TRIGGER_ADCC4 = 14U

CLA Task Trigger Source is ADCC4.

enumerator CLA_TRIGGER_ADCCEVT = 15U

CLA Task Trigger Source is ADCCEVT.

enumerator CLA_TRIGGER_ADCD1 = 16U

CLA Task Trigger Source is ADCD1.

enumerator CLA_TRIGGER_ADCD2 = 17U

CLA Task Trigger Source is ADCD2.

enumerator CLA_TRIGGER_ADCD3 = 18U

CLA Task Trigger Source is ADCD3.

enumerator CLA_TRIGGER_ADCD4 = 19U

CLA Task Trigger Source is ADCD4.

enumerator CLA_TRIGGER_ADCDEVT = 20U

CLA Task Trigger Source is ADCDEVT.

enumerator CLA_TRIGGER_XINT1 = 29U

CLA Task Trigger Source is XINT1.

enumerator CLA_TRIGGER_XINT2 = 30U

CLA Task Trigger Source is XINT2.

enumerator CLA_TRIGGER_XINT3 = 31U

CLA Task Trigger Source is XINT3.

enumerator CLA_TRIGGER_XINT4 = 32U

CLA Task Trigger Source is XINT4.

enumerator CLA_TRIGGER_XINT5 = 33U

CLA Task Trigger Source is XINT5.

enumerator CLA_TRIGGER_EPWM1INT = 36U

CLA Task Trigger Source is EPWM1INT.

enumerator CLA_TRIGGER_EPWM2INT = 37U

CLA Task Trigger Source is EPWM2INT.

enumerator CLA_TRIGGER_EPWM3INT = 38U

CLA Task Trigger Source is EPWM3INT.

enumerator CLA_TRIGGER_EPWM4INT = 39U

CLA Task Trigger Source is EPWM4INT.

enumerator CLA_TRIGGER_EPWM5INT = 40U

CLA Task Trigger Source is EPWM5INT.

enumerator CLA_TRIGGER_EPWM6INT = 41U

CLA Task Trigger Source is EPWM6INT.

enumerator CLA_TRIGGER_EPWM7INT = 42U

CLA Task Trigger Source is EPWM7INT.

enumerator CLA_TRIGGER_EPWM8INT = 43U

CLA Task Trigger Source is EPWM8INT.

enumerator CLA_TRIGGER_EPWM9INT = 44U

CLA Task Trigger Source is EPWM9INT.

enumerator CLA_TRIGGER_EPWM10INT = 45U

CLA Task Trigger Source is EPWM10INT.

enumerator CLA_TRIGGER_EPWM11INT = 46U

CLA Task Trigger Source is EPWM11INT.

enumerator CLA_TRIGGER_EPWM12INT = 47U

CLA Task Trigger Source is EPWM12INT.

enumerator CLA_TRIGGER_TINT0 = 68U

CLA Task Trigger Source is TINT0.

enumerator CLA_TRIGGER_TINT1 = 69U

CLA Task Trigger Source is TINT1.

enumerator CLA_TRIGGER_TINT2 = 70U

CLA Task Trigger Source is TINT2.

enumerator CLA_TRIGGER_MXINTA = 71U

CLA Task Trigger Source is MXINTA.

enumerator CLA_TRIGGER_MRINTA = 72U

CLA Task Trigger Source is MRINTA.

enumerator CLA_TRIGGER_MXINTB = 73U

CLA Task Trigger Source is MXINTB.

enumerator CLA_TRIGGER_MRINTB = 74U

CLA Task Trigger Source is MRINTB.

enumerator CLA_TRIGGER_ECAP1INT = 75U

CLA Task Trigger Source is ECAP1INT.

enumerator CLA_TRIGGER_ECAP2INT = 76U

CLA Task Trigger Source is ECAP2INT.

enumerator CLA_TRIGGER_ECAP3INT = 77U

CLA Task Trigger Source is ECAP3INT.

enumerator CLA_TRIGGER_ECAP4INT = 78U

CLA Task Trigger Source is ECAP4INT.

enumerator CLA_TRIGGER_ECAP5INT = 79U

CLA Task Trigger Source is ECAP5INT.

enumerator CLA_TRIGGER_ECAP6INT = 80U

CLA Task Trigger Source is ECAP6INT.

enumerator CLA_TRIGGER_EQEP1INT = 83U

CLA Task Trigger Source is EQEP1INT.

enumerator CLA_TRIGGER_EQEP2INT = 84U

CLA Task Trigger Source is EQEP2INT.

enumerator CLA_TRIGGER_EQEP3INT = 85U

CLA Task Trigger Source is EQEP3INT.

enumerator CLA_TRIGGER_SDFM1INT = 95U

CLA Task Trigger Source is SDFM1INT.

enumerator CLA_TRIGGER_SDFM2INT = 96U

CLA Task Trigger Source is SDFM2INT.

enumerator CLA_TRIGGER_UPP1INT = 107U

CLA Task Trigger Source is UPP1INT.

enumerator CLA_TRIGGER_SPITXAINT = 109U

CLA Task Trigger Source is SPITXAINT.

enumerator CLA_TRIGGER_SPIRXAINT = 110U

CLA Task Trigger Source is SPIRXAINT.

enumerator CLA_TRIGGER_SPITXBINT = 111U

CLA Task Trigger Source is SPITXBINT.

enumerator CLA_TRIGGER_SPIRXBINT = 112U

CLA Task Trigger Source is SPIRXBINT.

enumerator CLA_TRIGGER_SPITXCINT = 113U

CLA Task Trigger Source is SPITXCINT.

enumerator CLA_TRIGGER_SPIRXCINT = 114U

CLA Task Trigger Source is SPIRXCINT.

enumerator CLA_TRIGGER_CLB1INT = 127

CLA Task Trigger Source is CLB1INT.

enumerator CLA_TRIGGER_CLB2INT = 128

CLA Task Trigger Source is CLB2INT.

enumerator CLA_TRIGGER_CLB3INT = 129

CLA Task Trigger Source is CLB3INT.

enumerator CLA_TRIGGER_CLB4INT = 130

CLA Task Trigger Source is CLB4INT.

Functions

void CLA_mapTaskVector(uint32_t base, CLA_MVECTNumber claIntVect, uint16_t claTaskAddr)

Map CLA Task Interrupt Vector

Each CLA Task (1 to 8) has its own MVECTx register. When a task is triggered, the CLA loads the MVECTx register of the task in question to the MPC (CLA program counter) and begins execution from that point. The CLA has a 16-bit address bus, and can therefore, access the lower 64 KW space. The MVECTx registers take an address anywhere in this space.

Parameters
  • base: is the base address of the CLA controller.

  • claIntVect: is CLA interrupt vector (MVECT1 to MVECT8) the value of claIntVect can be any of the following:

    • CLA_MVECT_1 - Task Interrupt Vector 1

    • CLA_MVECT_2 - Task Interrupt Vector 2

    • CLA_MVECT_3 - Task Interrupt Vector 3

    • CLA_MVECT_4 - Task Interrupt Vector 4

    • CLA_MVECT_5 - Task Interrupt Vector 5

    • CLA_MVECT_6 - Task Interrupt Vector 6

    • CLA_MVECT_7 - Task Interrupt Vector 7

    • CLA_MVECT_8 - Task Interrupt Vector 8

  • claTaskAddr: is the start address of the code for task

Return

None.

void CLA_performHardReset(uint32_t base)

Hard Reset

This function will cause a hard reset of the CLA and set all CLA registers to their default state.

Parameters
  • base: is the base address of the CLA controller.

Return

None.

void CLA_performSoftReset(uint32_t base)

Soft Reset

This function will cause a soft reset of the CLA. This will stop the current task, clear the MIRUN flag and clear all bits in the MIER register.

Parameters
  • base: is the base address of the CLA controller.

Return

None.

void CLA_enableIACK(uint32_t base)

IACK enable

This function enables the main CPU to use the IACK #16bit instruction to set MIFR bits in the same manner as writing to the MIFRC register.

Parameters
  • base: is the base address of the CLA controller.

Return

None.

void CLA_disableIACK(uint32_t base)

IACK disable

This function disables the main CPU to use the IACK #16bit instruction to set MIFR bits in the same manner as writing to the MIFRC register.

Parameters
  • base: is the base address of the CLA controller.

Return

None.

bool CLA_getPendingTaskFlag(uint32_t base, CLA_TaskNumber taskNumber)

Query task N to see if it is flagged and pending execution

This function gets the status of each bit in the interrupt flag register corresponds to a CLA task. The corresponding bit is automatically set when the task is triggered (either from a peripheral, through software, or through the MIFRC register). The bit gets cleared when the CLA starts to execute the flagged task.

Parameters
  • base: is the base address of the CLA controller.

  • taskNumber: is the number of the task CLA_TASK_N where N is a number from 1 to 8. Do not use CLA_TASKFLAG_ALL.

Return

True if the queried task has been triggered but pending execution.

uint16_t CLA_getAllPendingTaskFlags(uint32_t base)

Get status of All Task Interrupt Flag

This function gets the value of the interrupt flag register (MIFR)

Parameters
  • base: is the base address of the CLA controller.

Return

the value of Interrupt Flag Register (MIFR)

bool CLA_getTaskOverflowFlag(uint32_t base, CLA_TaskNumber taskNumber)

Get status of Task n Interrupt Overflow Flag

This function gets the status of each bit in the overflow flag register corresponds to a CLA task, This bit is set when an interrupt overflow event has occurred for the specific task.

Parameters
  • base: is the base address of the CLA controller.

  • taskNumber: is the number of the task CLA_TASK_N where N is a number from 1 to 8. Do not use CLA_TASKFLAG_ALL.

Return

True if any of task interrupt overflow has occurred.

uint16_t CLA_getAllTaskOverflowFlags(uint32_t base)

Get status of All Task Interrupt Overflow Flag

This function gets the value of the Interrupt Overflow Flag Register

Parameters
  • base: is the base address of the CLA controller.

Return

the value of Interrupt Overflow Flag Register(MIOVF)

void CLA_clearTaskFlags(uint32_t base, uint16_t taskFlags)

Clear the task interrupt flag

This function is used to manually clear bits in the interrupt flag (MIFR) register

Parameters
  • base: is the base address of the CLA controller.

  • taskFlags: is the bitwise OR of the tasks’ flags to be cleared CLA_TASKFLAG_N where N is the task number from 1 to 8, or CLA_TASKFLAG_ALL to clear all flags.

Return

None.

void CLA_forceTasks(uint32_t base, uint16_t taskFlags)

Force a CLA Task

This function forces a task through software.

Parameters
  • base: is the base address of the CLA controller.

  • taskFlags: is the bitwise OR of the tasks’ flags to be forced CLA_TASKFLAG_N where N is the task number from 1 to 8, or CLA_TASKFLAG_ALL to force all tasks.

Return

None.

void CLA_enableTasks(uint32_t base, uint16_t taskFlags)

Enable CLA task(s)

This function allows an incoming interrupt or main CPU software to start the corresponding CLA task.

Parameters
  • base: is the base address of the CLA controller.

  • taskFlags: is the bitwise OR of the tasks’ flags to be enabled CLA_TASKFLAG_N where N is the task number from 1 to 8, or CLA_TASKFLAG_ALL to enable all tasks

Return

None.

void CLA_disableTasks(uint32_t base, uint16_t taskFlags)

Disable CLA task interrupt

This function disables CLA task interrupt by setting the MIER register bit to 0, while the corresponding task is executing this will have no effect on the task. The task will continue to run until it hits the MSTOP instruction.

Parameters
  • base: is the base address of the CLA controller.

  • taskFlags: is the bitwise OR of the tasks’ flags to be disabled CLA_TASKFLAG_N where N is the task number from 1 to 8, or CLA_TASKFLAG_ALL to disable all tasks

Return

None.

bool CLA_getTaskRunStatus(uint32_t base, CLA_TaskNumber taskNumber)

Get the value of a task run status

This function gets the status of each bit in the Interrupt Run Status Register which indicates whether the task is currently executing

Parameters
  • base: is the base address of the CLA controller.

  • taskNumber: is the number of the task CLA_TASK_N where N is a number from 1 to 8. Do not use CLA_TASKFLAG_ALL.

Return

True if the task is executing.

uint16_t CLA_getAllTaskRunStatus(uint32_t base)

Get the value of all task run status

This function indicates which task is currently executing.

Parameters
  • base: is the base address of the CLA controller.

Return

the value of Interrupt Run Status Register (MIRUN)

void CLA_enableSoftwareInterrupt(uint32_t base, uint16_t taskFlags)

Enable the Software Interrupt for a given CLA Task

This function enables the Software Interrupt for a single, or set of, CLA task(s). It does this by writing a 1 to the task’s bit in the CLA1SOFTINTEN register. By setting a task’s SOFTINT bit, you disable its ability to generate an end-of-task interrupt For example, if we enable Task 2’s SOFTINT bit, we disable its ability to generate an end-of-task interrupt, but now any running CLA task has the ability to force task 2’s interrupt (through the CLA1INTFRC register) to the main CPU. This interrupt will be handled by the End-of-Task 2 interrupt handler even though the interrupt was not caused by Task 2 running to completion. This allows programmers to generate interrupts while a control task is running.

Parameters
  • base: is the base address of the CLA controller.

  • taskFlags: is the bitwise OR of the tasks for which software interrupts are to be enabled, CLA_TASKFLAG_N where N is the task number from 1 to 8, or CLA_TASKFLAG_ALL to enable software interrupts of all tasks

Note

  1. The CLA1SOFTINTEN and CLA1INTFRC are only writable from the CLA.

  2. Enabling a given task’s software interrupt enable bit disables that task’s ability to generate an End-of-Task interrupt to the main CPU, however, should another task force its interrupt (through the CLA1INTFRC register), it will be handled by that task’s End-of-Task Interrupt Handler.

Return

None.

void CLA_disableSoftwareInterrupt(uint32_t base, uint16_t taskFlags)

Disable the Software Interrupt for a given CLA Task

This function disables the Software Interrupt for a single, or set of, CLA task(s). It does this by writing a 0 to the task’s bit in the CLA1SOFTINTEN register.

Parameters
  • base: is the base address of the CLA controller.

  • taskFlags: is the bitwise OR of the tasks for which software interrupts are to be disabled, CLA_TASKFLAG_N where N is the task number from 1 to 8, or CLA_TASKFLAG_ALL to disable software interrupts of all tasks

Note

  1. The CLA1SOFTINTEN and CLA1INTFRC are only writable from the CLA.

  2. Disabling a given task’s software interrupt ability allows that task to generate an End-of-Task interrupt to the main CPU.

Return

None.

void CLA_forceSoftwareInterrupt(uint32_t base, uint16_t taskFlags)

Force a particular Task’s Software Interrupt

This function forces the Software Interrupt for a single, or set of, CLA task(s). It does this by writing a 1 to the task’s bit in the CLA1INTFRC register. For example, if we enable Task 2’s SOFTINT bit, we disable its ability to generate an end-of-task interrupt, but now any running CLA task has the ability to force task 2’s interrupt (through the CLA1INTFRC register) to the main CPU. This interrupt will be handled by the End-of-Task 2 interrupt handler even though the interrupt was not caused by Task 2 running to completion. This allows programmers to generate interrupts while a control task is running.

Parameters
  • base: is the base address of the CLA controller.

  • taskFlags: is the bitwise OR of the task’s whose software interrupts are to be forced, CLA_TASKFLAG_N where N is the task number from 1 to 8, or CLA_TASKFLAG_ALL to force software interrupts for all tasks

Note

  1. The CLA1SOFTINTEN and CLA1INTFRC are only writable from the CLA.

  2. Enabling a given task’s software interrupt enable bit disables that task’s ability to generate an End-of-Task interrupt to the main CPU, however, should another task force its interrupt (through the CLA1INTFRC register), it will be handled by that task’s End-of-Task Interrupt Handler.

  3. This function will set the INTFRC bit for a task, but does not check that its SOFTINT bit is set. It falls to the user to ensure that software interrupt for a given task is enabled before it can be forced.

Return

None.

void CLA_setTriggerSource(CLA_TaskNumber taskNumber, CLA_Trigger trigger)

Configures CLA task triggers.

This function configures the trigger source of a CLA task. The

taskNumber parameter indicates which task is being configured, and the trigger parameter is the interrupt source from a specific peripheral interrupt (or software) that will trigger the task.
Parameters
  • taskNumber: is the number of the task CLA_TASK_N where N is a number from 1 to 8.

  • trigger: is the trigger source to be assigned to the selected task.

Return

None.

The next few paragraphs describe configuration options that are accessible via the main processor (the C28x).

The CLA code is broken up into a main background task and a set of 7 tasks, each of which requires a trigger source either from a hardware peripheral or software. Each task begins at an address that is given by its vector register. The vector for the background task can be configured using the CLA_mapBackgroundTaskVector(), and the task’s vector is set using CLA_mapTaskVector(). The trigger source for all the tasks can be set with CLA_setTriggerSource(). If using a software trigger, the user must first enable the feature with CLA_enableIACK(), and then trigger the task with the assembly instruction,

align

center

__asm(” IACK #<Task>”); Task refers to the task to trigger; it is one less than the actual task. For example, if attempting to trigger task 1 you would issue,

align

center

__asm(” IACK #0”);

A task will only start to execute if it is globally enabled. This is done through CLA_enableTasks(). Once enabled, a task will respond to a peripheral trigger (if configured to do so), a software force (with the IACK instruction), or through CLA_forceTasks().

In this type of CLA, a background task is always running. It is enabled using CLA_enableBackgroundTask() and subsequently kicked off by CLA_startBackgroundTask(), or through a peripheral trigger (it takes the same trigger as task 8 on older CLAs). The user may enable the background task peripheral trigger feature using CLA_enableHardwareTrigger().

The tasks (1 to 7) have a fixed priority, with 1 being the highest and 7 the lowest. They will interrupt the background task, when triggered, in priority order. The user may query the status of all tasks with CLA_getAllTaskRunStatus() or a particular task with CLA_getTaskRunStatus() to determine if its pending, running or idle.

Each task (1 through 7) can issue an interrupt to the main CPU after it completes execution. This is configured through the PIE module, and registering the handler (ISR) for each end-of-task interrupt with CLA_registerEndOfTaskInterrupt().

The CLA can undergo a soft reset with CLA_performSoftReset() or emulate a power cycle or hard reset with CLA_performHardReset().

The CLA can access and configure a few configuration registers (the C28x can read but not alter these registers). A task can force another’s end-of-task interrupt to the main CPU by enabling that task’s software interrupt using CLA_enableSoftwareInterrupt() and subsequently forcing it using CLA_forceSoftwareInterrupt(). Its important to keep in mind that enabling a software interrupt for a given task disables its ability to generate an interrupt to the main CPU once it completes execution.

The code for this module is contained in driverlib/cla.c, with driverlib/cla.h containing the API declarations for use by applications.