Other Parts Discussed in Thread: C2000WARE
Hello, I'm trying to do a board bring up and I wanted to bring timer 0 interrupt first. I'm going through datasheet and following the instructions, but my interrupt won't be called.
#include <stdio.h>
#include "interrupts.h"
#include "F28379D device support/include/F2837xD_device.h"
#include "F28379D device support/include/F2837xD_piectrl.h"
#include "F28379D device support/include/F2837xD_pievect.h"
void main(void)
{
DINT;
EALLOW;
/*Setting system clock @1Mhz, INTOSC2*/
if (!ClkCfgRegs.MCDCR.bit.MCLKSTS) {
WdRegs.SCSR.bit.WDOVERRIDE = 1; //Enable WD editing
WdRegs.WDCR.bit.WDDIS = 1; //Disable WD
ClkCfgRegs.CLKSRCCTL1.bit.OSCCLKSRCSEL = 0x0; //INTOSC2 as clock source
asm(" RPT #10 || NOP"); //Wait 10 clock cycles
ClkCfgRegs.SYSPLLCTL1.bit.PLLCLKEN = 0; //Bypassing PLL
ClkCfgRegs.SYSCLKDIVSEL.bit.PLLSYSCLKDIV = 0; //Set system clock divider to /1
ClkCfgRegs.SYSPLLMULT.all = 0x01; //MULT of 1, this starts PLL
while(!ClkCfgRegs.SYSPLLSTS.bit.LOCKS); //Waiting until PLL isn't locked
ClkCfgRegs.SYSCLKDIVSEL.bit.PLLSYSCLKDIV = 11; //Setting divider to 10
WdRegs.WDCR.bit.WDDIS = 0; //Enable WD so it resets the CPU
DevCfgRegs.SYSDBGCTL.bit.BIT_0 = 1;
ClkCfgRegs.SYSPLLCTL1.bit.PLLCLKEN = 0; //Set PLL as system clock
DevCfgRegs.SYSDBGCTL.bit.BIT_0 = 0;
WdRegs.WDCR.bit.WDDIS = 1; //Disable WD
} else {
ESTOP0;
while(1);
}
/*===================================*/
/*Enable Timer0 interrupt in PIE*/
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; //Enable PIE
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; //Set bit for 1.7 interrupt
IER |= 1;
uint16_t* timer0_isr_p = 0x00000D4C;
*timer0_isr_p = &tim0_isr;
PieCtrlRegs.PIEACK.all = 0xFFFF;
/*==============================*/
/*Configure Timer0 for 1ms interrupt*/
CpuTimer0Regs.TPR.bit.TDDR = 10 - 1; // prescale to 100KHz
CpuTimer0Regs.PRD.all = 100; // Further prescale to 1KHz
CpuTimer0Regs.TCR.bit.TSS = 1; // Stop the timer0
CpuTimer0Regs.TIM.all = 100; // Load timer with PRD value
CpuTimer0Regs.TCR.bit.TIE = 1; // Enable interrupt
CpuTimer0Regs.TCR.bit.TSS = 0; // Start the timer0
/*==================================*/
/*Configure GPIO for testing purpose*/
/*==================================*/
EINT;
EDIS;
while (1)
{
}
}
This is my main.c code.
#include "interrupts.h"
#include "stdio.h"
interrupt void tim0_isr(void) {
printf("Hello");
}
and this is my interrupts.c code
I've checked the memory location 0x00000D4C and tim0_isr seems to be written there just fine. I've debbugged timer0 TIM register and it's updating the value just fine, so I'm curious what error am I making in my code?