Part Number: TMS320F28379D
Tool/software: TI C/C++ Compiler
Hi,
I´am facing some difficulties with changing from RAM to FLASH:
Timer0 gets called ever sec and an GPIO gets Toggled. Before the Timer gets Enabled the Gpio gets Toggled 5 times.
If I download the programm to the FLASH everything works fine. But if i restart the Controller. The GPio Toggles 5 time (which is not Timer0 controlled) but after this nothing happens,
It seems to me that the memcpy isrfnc is the problem. The ISR is linked via the isr.cmd
#include "F28x_Project.h"
#include "F2837xD_Ipc_drivers.h"
extern uint16_t isrfuncLoadStart;
extern uint16_t isrfuncLoadEnd;
extern uint16_t isrfuncRunStart;
extern uint16_t isrfuncLoadSize;
__interrupt void cpu_timer0_isr(void);
#pragma CODE_SECTION(cpu_timer0_isr,"isrfunc")
#ifdef _FLASH
extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsLoadSize;
extern Uint16 RamfuncsRunStart;
#endif
void main(void)
{
#ifdef _FLASH
EALLOW;
Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0;
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
memcpy(&isrfuncRunStart, &isrfuncLoadStart, (uint32_t)&isrfuncLoadSize); // Copy ISR routine to a specified RAM location to determine the size
EDIS;
#endif
InitSysCtrl();
InitGpio();
EALLOW;
GpioCtrlRegs.GPADIR.bit.GPIO31 = 1;
GpioDataRegs.GPACLEAR.bit.GPIO31 = 1;
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;
GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1;
EDIS;
EALLOW;
ClkCfgRegs.CLKSRCCTL3.bit.XCLKOUTSEL = 0; // *8 = SYSCLK
ClkCfgRegs.SYSCLKDIVSEL.bit.PLLSYSCLKDIV = 0;
ClkCfgRegs.LOSPCP.bit.LSPCLKDIV = 0; // Set LSPCKL (Clock for UART) to SYSCKL (=160MHz)
GpioCtrlRegs.GPCMUX1.bit.GPIO73 = 3;
EDIS;
DINT;
InitPieCtrl();
//
// Disable CPU interrupts and clear all CPU interrupt flags:
//
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.TIMER0_INT = &cpu_timer0_isr;
EDIS;
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 160, 100000);
CpuTimer0Regs.TCR.all = 0x4000;
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
int i;
for(i=0;i<5;i++)
{
GpioDataRegs.GPBSET.bit.GPIO34 = 1;
GpioDataRegs.GPASET.bit.GPIO31 = 1;
DELAY_US(1000*500);
GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1;
GpioDataRegs.GPACLEAR.bit.GPIO31 = 1;
DELAY_US(1000*500);
}
IER |= M_INT1;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
}
__interrupt void cpu_timer0_isr(void)
{
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;
CpuTimer0.InterruptCount++;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
With kind regards
Manuel