Other Parts Discussed in Thread: CONTROLSUITE
Hello,
today I have been setting up the External interrupt peripheral on Concerto device with an unexpected operation. What I have done can be summarized as follows:
--ARM
1- CLKSYS Configuration, Timer0 and GPIO Configuration to blink a LED in each interrupt —> Works fine
2- I proceded to give to C2000 the control to all GPIOs that I am going to use —> It does not alter the function explained above.
--C200
1- GPIO Configuration as Input or Output according to what I need.
2- XINT1,XINT2,XINT3 and CpuTimer0 Interrupts configuration.
Before any XINT configuration I tested the system blinking a LED on C2000 too and everything ran as I expected. However, when I added the XINT configuration everything broke down. LEDs do not blink and when I resume the ARM device after the CPU Reset it is reseting all the time whilst C2000 is running but the LED doesn't blink.
P.S. The XINT configuration was extracted from the ControlSuite XINT Example
Could someone explain to me what have I done wrong?
The code is attached below
//###########################################################################
// FILE: Lab2_M3.c
//###########################################################################
//
#include <string.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_gpio.h"
#include "inc/hw_types.h"
#include "inc/hw_sysctl.h"
#include "driverlib/debug.h"
#include "driverlib/flash.h"
#include "driverlib/ipc.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h" // new in Lab2_M3
extern unsigned long RamfuncsLoadStart;
extern unsigned long RamfuncsRunStart;
extern unsigned long RamfuncsLoadSize;
//*****************************************************************************
// The interrupt handler for timer0 interrupt.
//*****************************************************************************
void Timer0IntHandler(void)
{
static unsigned int toggle = 0;
// Clear the timer interrupt.
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
if(toggle == 0)
{
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, 0); // LD3 ON
toggle = 1;
}
else
{
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, ~0); // LD3 OFF
toggle = 0;
}
}
//*****************************************************************************
// Blink LED LD3
//*****************************************************************************
void main(void)
{
// Disable Protection
HWREG(SYSCTL_MWRALLOW) = 0xA5A5A5A5;
// Sets up PLL, M3 running at 75 MHz and C28 running at 150 MHz
SysCtlClockConfigSet(SYSCTL_USE_PLL | (SYSCTL_SPLLIMULT_M & 0xF) |
SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_2 |
SYSCTL_XCLKDIV_4);
// Copy time critical code and Flash setup code to RAM
// This includes the following functions: InitFlash();
// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart
// symbols are created by the linker. Refer to the device .cmd file.
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
FlashInit();
// Enable timer 0 used by this example.
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
// Configure the timer0 as 32-bit periodic timer.
TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);
TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet(SYSTEM_CLOCK_SPEED)/8);
// Send boot command to allow the C28 application to begin execution
//IPCMtoCBootControlSystem(CBROM_MTOC_BOOTMODE_BOOT_FROM_FLASH);
// Enable clock supply for GPIOC
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
// Give C28 control of Port C pin 6
/* GPIOPinConfigureCoreSelect(GPIO_PORTC_BASE, GPIO_PIN_6, GPIO_PIN_C_CORE_SELECT);
GPIOPinConfigureCoreSelect(GPIO_PORTD_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 , GPIO_PIN_C_CORE_SELECT);
GPIOPinConfigureCoreSelect(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 , GPIO_PIN_C_CORE_SELECT);
GPIOPinConfigureCoreSelect(GPIO_PORTF_BASF, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 , GPIO_PIN_C_CORE_SELECT);*/
//GPIOPinConfigureCoreSelect(GPIO_PORTA_BASE, GPIO_PIN_0, GPIO_PIN_C_CORE_SELECT);
// Disable clock supply for the watchdog modules
SysCtlPeripheralDisable(SYSCTL_PERIPH_WDOG1);
SysCtlPeripheralDisable(SYSCTL_PERIPH_WDOG0);
// Setup the interrupts for the timer timeouts.
IntEnable(INT_TIMER0A);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
IntRegister(INT_TIMER0A, Timer0IntHandler);
// Enable the timers.
TimerEnable(TIMER0_BASE, TIMER_A);
// Enable processor interrupts.
IntMasterEnable();
// Set up the Pin for LED LD3
GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_7);
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, ~0);
while(1);
}
//###########################################################################
// FILE: Lab1_C28.c
//###########################################################################
//
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
#include <string.h>
extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsLoadSize;
extern Uint16 RamfuncsRunStart;
#define C28_FREQ 150 //C28 CPU frequency in MHz
interrupt void cpu_timer0_isr(void);
interrupt void xint1_isr(void);
interrupt void xint2_isr(void);
interrupt void xint3_isr(void);
void main(void)
{
InitSysCtrl(); // Init C28 core
EALLOW;
//CONTROL
GpioG1CtrlRegs.GPAMUX2.bit.GPIO26 = 0; // Set as GPIO
GpioG1CtrlRegs.GPAMUX2.bit.GPIO27 = 0; // Set as GPIO
GpioG1CtrlRegs.GPAMUX2.bit.GPIO28 = 0; // Set as GPIO
GpioG1CtrlRegs.GPAMUX2.bit.GPIO29 = 0; // Set as GPIO
GpioG1CtrlRegs.GPAMUX2.bit.GPIO30 = 0; // Set as GPIO
GpioG1CtrlRegs.GPAMUX2.bit.GPIO31 = 0; // Set as GPIO
GpioG1CtrlRegs.GPBMUX1.bit.GPIO32 = 0; // Set as GPIO
GpioG1CtrlRegs.GPBMUX1.bit.GPIO33 = 0; // Set as GPIO
GpioG1CtrlRegs.GPBMUX1.bit.GPIO34 = 0; // Set as GPIO
//XINT
GpioG1CtrlRegs.GPAMUX2.bit.GPIO21 = 0; // Set as GPIO
GpioG1CtrlRegs.GPAMUX2.bit.GPIO22 = 0; // Set as GPIO
GpioG1CtrlRegs.GPAMUX2.bit.GPIO23 = 0; // Set as GPIO
//CONTROL
GpioG1CtrlRegs.GPADIR.bit.GPIO26 = 1; // GPIO26 as output -- CLK1
GpioG1CtrlRegs.GPADIR.bit.GPIO27 = 1; // GPIO27 as output -- ENABLE1
GpioG1CtrlRegs.GPADIR.bit.GPIO28 = 1; // GPIO28 as output -- ERROR1
GpioG1CtrlRegs.GPADIR.bit.GPIO29 = 1; // GPIO29 as output -- CLK2
GpioG1CtrlRegs.GPADIR.bit.GPIO30 = 1; // GPIO30 as output -- ENABLE2
GpioG1CtrlRegs.GPADIR.bit.GPIO31 = 1; // GPIO31 as output -- ERROR2
GpioG1CtrlRegs.GPBDIR.bit.GPIO32 = 1; // GPIO32 as output -- CLK3
GpioG1CtrlRegs.GPBDIR.bit.GPIO33 = 1; // GPIO33 as output -- ENABLE3
GpioG1CtrlRegs.GPBDIR.bit.GPIO34 = 1; // GPIO34 as output -- ERROR3
//XINT
GpioG1CtrlRegs.GPADIR.bit.GPIO21 = 0; // GPIO21 as input -- ERROR1_IN
GpioG1CtrlRegs.GPADIR.bit.GPIO22 = 0; // GPIO22 as input -- ERROR2_IN
GpioG1CtrlRegs.GPADIR.bit.GPIO23 = 0; // GPIO23 as input -- ERROR3_IN
GpioG1CtrlRegs.GPAQSEL2.bit.GPIO21 = 0;
GpioG1CtrlRegs.GPAQSEL2.bit.GPIO22 = 0;
GpioG1CtrlRegs.GPAQSEL2.bit.GPIO23 = 0;
GpioG1CtrlRegs.GPCDIR.bit.GPIO70 = 1; // GPIO70 as output
EDIS;
GpioG1DataRegs.GPCDAT.bit.GPIO70 = 1; // turn off LED
GpioG1DataRegs.GPADAT.bit.GPIO26 = 1;
GpioG1DataRegs.GPADAT.bit.GPIO27 = 1;
GpioG1DataRegs.GPADAT.bit.GPIO28 = 0;
GpioG1DataRegs.GPADAT.bit.GPIO29 = 1;
GpioG1DataRegs.GPADAT.bit.GPIO30 = 1;
GpioG1DataRegs.GPADAT.bit.GPIO31 = 0;
GpioG1DataRegs.GPBDAT.bit.GPIO32 = 1;
GpioG1DataRegs.GPBDAT.bit.GPIO33 = 1;
GpioG1DataRegs.GPBDAT.bit.GPIO34 = 0;
// Copy time critical code and Flash setup code to RAM
// This includes the following functions: InitFlash();
// The RamfuncsLoadStart, RamfuncsLoadSize and RamfuncsRunStart
// symbols are created by the linker. Refer to the device .cmd file.
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
InitFlash();
InitPieCtrl();
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &cpu_timer0_isr;
PieVectTable.XINT1 = &xint1_isr;
PieVectTable.XINT2 = &xint2_isr;
PieVectTable.XINT3 = &xint3_isr;
EDIS;
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, C28_FREQ, 125000);
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
PieCtrlRegs.PIEIER1.bit.INTx4 = 1; // Enable PIE Group 1 INT4
PieCtrlRegs.PIEIER1.bit.INTx5 = 1; // Enable PIE Group 1 INT5
PieCtrlRegs.PIEIER12.bit.INTx1 = 1; // Enable PIE Group 12 INT1
IER |= 1;
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
/****************************************************************************
* GPIO ASSIGNAMENT TO XINT
*****************************************************************************/
EALLOW;
GpioG1TripRegs.GPTRIP4SEL.bit.GPTRIP4SEL = 0x15; //Map Trip Input 4(XINT1) to
// PA0_GPIO0
GpioG1TripRegs.GPTRIP5SEL.bit.GPTRIP5SEL = 0x16; //Map Trip Input 5(XINT2) to
// PA1_GPIO1
GpioG1TripRegs.GPTRIP6SEL.bit.GPTRIP6SEL = 0x17;
EDIS;
/*****************************************************************************
* EXTERNAL INTERRUPT CONFIGURATION
*****************************************************************************/
// POLARITY
XIntruptRegs.XINT1CR.bit.POLARITY = 1; // Rising edge interrupt
XIntruptRegs.XINT2CR.bit.POLARITY = 1; // Rising edge interrupt
XIntruptRegs.XINT2CR.bit.POLARITY = 1; // Rising edge interrupt
// Enable
XIntruptRegs.XINT1CR.bit.ENABLE = 1; // Enable XINT1
XIntruptRegs.XINT2CR.bit.ENABLE = 1; // Enable XINT2
XIntruptRegs.XINT3CR.bit.ENABLE = 1; // Enable XINT3
CpuTimer0Regs.TCR.bit.TSS = 0; // start T0
while(1);
}
interrupt void cpu_timer0_isr(void)
{
GpioG1DataRegs.GPCDAT.bit.GPIO70 ^= 1; // Toggle LED
GpioG1DataRegs.GPADAT.bit.GPIO26 ^= 1;
GpioG1DataRegs.GPADAT.bit.GPIO29 ^= 1;
GpioG1DataRegs.GPBDAT.bit.GPIO32 ^= 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // ACK PIE – Int
}
interrupt void xint1_isr(void)
{
GpioG1DataRegs.GPCDAT.bit.GPIO70 ^= 1;
// Acknowledge this interrupt to get more from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
interrupt void xint2_isr(void)
{
GpioG1DataRegs.GPCDAT.bit.GPIO70 ^= 1;
// Acknowledge this interrupt to get more from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}