This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
art Number: TMS320F280049C
Tool/software: Code Composer Studio
Good day! I have the following question:
I want to run the CLA interrupt task from the ADC. I want at the end of the ADC conversion to generate interrupts and for this interrupt CLA averaged the values of the ADC over the last 5 cycles (or any other task in CLA). I configured the interrupt generation at the end of the ADC conversion, starting the CLA task execution on this interrupt.
But I ran into the following problem: since the interrupt was generated, I need to report that I have processed it. This is done with the following line:
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
If I add this line to the coprocessor code (to the file with the .cla extension), I get the error: "# 20 identifier" PIEACK_GROUP1 "is undefine".
Thus, I still need to make the ADC interrupt handling function, in which there will be only one line: PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
It seems to me that this decision is not correct. Tell me, please, is this really true? And how do I get rid of a single line interrupt handler?
Below I give a part of the code of my program and the CLA program, as well as attach the archive with my project.
#include "main.h"
#include <math.h>
#include "project_1.h"
#include "CLAmath.h"
/*
uint16_t ADC_DATA_0[5] = {0, 0, 0, 0, 0};
float ADC_DATA_0_mean = 0;
float ADC_DATA_0_real = 0;
float ADC_DATA_0_reall = 0;
int i = 0;
*/
float x1 = 0.5f;
float x2 = 0.9f;
float x3 = 0.0f;
float x4 = 5.2f;
void adcA1ISR(void);
void main(void)
{
InitStartMCU();
InitPWM();
InitADC();
InitADCSOC();
InitCLA();
EALLOW;
PieVectTable.ADCA1_INT = &adcA1ISR; // Function for ADCA interrupt 1
EDIS;
IER |= M_INT1; // Enable group 1 interrupts
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
// Enable PIE interrupt
//
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
/*********************************************************************************************************************************************/
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0; // GPIO2 = GPIO2
GpioCtrlRegs.GPAPUD.bit.GPIO2 = 1; // Disable pullup on GPIO2
GpioCtrlRegs.GPADIR.bit.GPIO2 = 1; // Load output latch
EDIS;
/**********************************************************************************************************************************************/
while(1)
{
}
}
__interrupt void adcA1ISR(void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
CLA:
#include <stdint.h>
#include "f28004x_device.h"
#include "project_1.h"
#include "CLAmath.h"
/*
const float x11 = 5.3;
const float x12 = 5.3;
float x13;
float x14;
*/
const float div = 20480;
int i;
uint16_t ADC_DATA_0[5];
float ADC_DATA_0_real;
//-----------------------------------------------------------------------------
//
// Task 1 - FIR Filter
//
// Description: A low pass Finite Impulse Response (FIR) filter.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task1 ( void )
{
if (i>=4) {
i = 0;
}
else {
i++;
}
ADC_DATA_0[i] = AdcaResultRegs.ADCRESULT0;
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
ADC_DATA_0_real = CLAdiv(( ADC_DATA_0[0] + ADC_DATA_0[1] + ADC_DATA_0[2] + ADC_DATA_0[3] + ADC_DATA_0[4] ) * 3.3, div);
}
//-----------------------------------------------------------------------------
//
// Task 2 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task2 ( void )
{
}
//-----------------------------------------------------------------------------
//
// Task 3 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task3 ( void )
{
}
//-----------------------------------------------------------------------------
//
// Task 4 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task4 ( void )
{
}
//-----------------------------------------------------------------------------
//
// Task 5 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task5 ( void )
{
}
//-----------------------------------------------------------------------------
//
// Task 6 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task6 ( void )
{
}
//-----------------------------------------------------------------------------
//
// Task 7 - One Time Initialization Task
//
// Description: This task will clear out the delay line and reset the index
// and any flags
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task7 ( void )
{
}
//-----------------------------------------------------------------------------
//
// Background Task
//
// Description: This task will buffer the filtered output in a circular buffer
//
//-----------------------------------------------------------------------------
/*******************************************************************************************/
/*
__attribute__((interrupt("background"))) void Cla1BackgroundTask ( void )
{
while(1)
{
if (f_filteredValueReady == true)
{
//
// Reset the flag
//
f_filteredValueReady = false;
//
// store the filtered output. Make this portion un-interruptible
//
__disable_interrupts();
buffer[index++] = filter_out;
__enable_interrupts();
//
// Since BUFFER_SIZE is a power of two, we can use unsigned modulo
// arithmetic to wrap the index around
//
index = index & (BUFFER_SIZE - 1U);
}
}
}
*/
/*******************************************************************************************/
//
// End of File
//
Sal Pezzino, thanks!
But this did not quite solve my problem. If I do as you tell me, then I get rid of the error described above with #define, but my program falls into an endless Illegal loop, which is associated with the need to write the string PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; (probably it must be written in the main program code).
I registered these lines here
// Enable PIE interrupt
//
// PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
those. I have disabled interrupt 1 of group 1, so there is no interrupt for the CPU, but this interrupt exists to start the execution of the CLA task.
This solution works, I hope I correctly understood the cause of the problem.