Other Parts Discussed in Thread: SYSCONFIG,
Champs.
Please check my attached C file, I don't know why my ISR is never entered: INT_myADCA_4_ISR
Thanks.
//#############################################################################
//
// FILE: lab_main.c
//
// TITLE: C2000 Academy Lab Startup Project
//
//
// This example is a startup project for C2000 Academy lab.
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the
// distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Function Declarations
//
__interrupt void INT_myADCA_4_ISR(void);
//#############################################################################
//Rio Added
//
// Included Files
//
#include "board.h"
//
// Global variables and definitions
//
#define ADC_BUF_LEN 50
uint16_t DEBUG_TOGGLE = 1; // Used for real-time mode
uint16_t AdcBuf[ADC_BUF_LEN]; // ADC buffer allocation
//#############################################################################
//Rio Below is the DAC Type 1:
//https://dev.ti.com/tirex/explore/node?node=A__AVSjOwDYHkfv9LUHQuulzA__C2000-ACADEMY__3H1LnqB__LATEST
uint16_t DacOutput;
uint16_t DacOffset;
uint16_t SINE_ENABLE = 0;
// quadrature look-up table: contains 4 quadrants of sinusoidal data points
#define SINE_PTS 25
int QuadratureTable[SINE_PTS] = {
0x0000, // [0] 0.0
0x1FD4, // [1] 14.4
0x3DA9, // [2] 28.8
0x579E, // [3] 43.2
0x6C12, // [4] 57.6
0x79BB, // [5] 72.0
0x7FBE, // [6] 86.4
0x7DBA, // [7] 100.8
0x73D0, // [8] 115.2
0x629F, // [9] 129.6
0x4B3B, // [10] 144.0
0x2F1E, // [11] 158.4
0x100A, // [12] 172.8
0xEFF6, // [13] 187.2
0xD0E2, // [14] 201.6
0xB4C5, // [15] 216.0
0x9D61, // [16] 230.4
0x8C30, // [17] 244.8
0x8246, // [18] 259.2
0x8042, // [19] 273.6
0x8645, // [20] 288.0
0x93EE, // [21] 302.4
0xA862, // [22] 316.8
0xC257, // [23] 331.2
0xE02C // [24] 345.6
};
//*****************************************************************************
//Rio Added from LAB
//https://dev.ti.com/tirex/explore/node?node=A__AVSjOwDYHkfv9LUHQuulzA__C2000-ACADEMY__3H1LnqB__LATEST
//*****************************************************************************
__interrupt void INT_myADCA_4_ISR(void)
{
static uint16_t *AdcBufPtr = AdcBuf;
static volatile uint16_t LED_count = 0;
// Read the ADC Result
*AdcBufPtr++ = ADC_readResult(myADCA_RESULT_BASE, myADCA_SOC0);
// Brute Force the circular buffer
if (AdcBufPtr == (AdcBuf + ADC_BUF_LEN))
{
AdcBufPtr = AdcBuf;
}
// Toggle the pin
if(DEBUG_TOGGLE == 1)
{
GPIO_togglePin(myGPIOToggle);
}
if(LED_count++ > 25000) // Toggle slowly to see the LED blink
{
GPIO_togglePin(myBoardLED0_GPIO); // Toggle the pin
LED_count = 0; // Reset the counter
}
//NT_myADCA_4_ISR in the sysconfig
ADC_clearInterruptStatus(myADCA_BASE, ADC_INT_NUMBER4);
Interrupt_clearACKGroup(INT_myADCA_4_INTERRUPT_ACK_GROUP);
//DAC
// Write to DAC-B to create input to ADC-A0
static uint16_t iQuadratureTable = 0; // Quadrature table index
if(SINE_ENABLE == 1)
{
DacOutput = DacOffset + ((QuadratureTable[iQuadratureTable++] ^ 0x8000) >> 5);
}
else
{
DacOutput = DacOffset;
}
if(iQuadratureTable > (SINE_PTS - 1)) // Wrap the index
{
iQuadratureTable = 0;
}
DAC_setShadowValue(myDACB_BASE, DacOutput);
} // End of ADC ISR
//
// Main
//
void main(void)
{
// Device Initialization
Device_init();
// Initialize GPIO and configure the GPIO pin as a push-pull output
Device_initGPIO();
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
Interrupt_initModule();
// Initialize the PIE vector table
Interrupt_initVectorTable();
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
// Configure the GPIOs/ADC/PWM through SysConfig generated function found within board.c
Board_init();
EINT;
ERTM;
#if 1
// Loop Forever
for(;;)
{
// Turn on LED
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
// Delay for a bit.
//DEVICE_DELAY_US(500000);
// Turn off LED
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
// Delay for a bit.
//DEVICE_DELAY_US(500000);
}
#endif
}
//
// End of File
//
BR Rio