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.

Problem while configuring Timer 0

Other Parts Discussed in Thread: OMAPL138

Hi,

I'm using the Tiner 0 on the OMAP L138 chip.I'm using the C6748 chip alone (stand alone mode).I'm using the timer in the 32 bit unchained mode.I configured the timer to operate every 2 secs.I also mapped the timer interrupt to GPIO Bank 1, Pin 10.With the 2 sec configuration , I was able to observe the pulse on the Oscilloscope.When I put breakpoints within the ISR it hit at that line of code.

How ever when  I reduced the the timer period to 625 us, I was not able to observe any pulse.When I put breakpoints within the timer ISR it did not hit at that line of code.Iam getting a message like this No source available for "UTL_halt() at 0x11803c28" .

I'm using the XDS100v2 JTAG emulator.

This is the piece of code for the timer 0

#include"OMAP_Timer.h"
#include"Filter_Developmentcfg.h"

#define DISABLE_INTR_MASK (0x00000000)
#define ENABLE_INTR_MASK (0x00000080)

#define INTRMUXREG1 (volatile unsigned int *)(0x01800104)
#define INTRMUXREG2 (volatile unsigned int *)(0x01800108)
#define INTRMUXREG3 (volatile unsigned int *)(0x0180010C)

#define TIMER0_34EVENT (0X40000000)

void HDW_Intr_Initialise()
{
HWI_enable();
C62_disableIER(DISABLE_INTR_MASK);
C62_enableIER(ENABLE_INTR_MASK);

*(INTRMUXREG1) = TIMER0_34EVENT;

}


/*-------------------------Timer0 Registers-------------------------*/

#define Timer0_REVID (volatile unsigned int *)(0x01C20000)
#define Timer0_EMUMGT (volatile unsigned int *)(0x01C20004)
#define Timer0_GPINTGPEN (volatile unsigned int *)(0x01C20008)
#define Timer0_GPDATGPDIR (volatile unsigned int *)(0x01C2000C)
#define Timer0_TIM12 (volatile unsigned int *)(0x01C20010)
#define Timer0_TIM34 (volatile unsigned int *)(0x01C20014)
#define Timer0_PRD12 (volatile unsigned int *)(0x01C20018)
#define Timer0_PRD34 (volatile unsigned int *)(0x01C2001C)
#define Timer0_TCR (volatile unsigned int *)(0x01C20020)
#define Timer0_TGCR (volatile unsigned int *)(0x01C20024)
#define Timer0_WDTCR (volatile unsigned int *)(0x01C20028)
#define Timer0_REL12 (volatile unsigned int *)(0x01C20034)
#define Timer0_REL34 (volatile unsigned int *)(0x01C20038)
#define Timer0_CAP12 (volatile unsigned int *)(0x01C2003C)
#define Timer0_CAP34 (volatile unsigned int *)(0x01C20040)
#define Timer0_INTCTLSTAT (volatile unsigned int *)(0x01C20044)
#define Timer0_CMP0 (volatile unsigned int *)(0x01C20060)
#define Timer0_CMP1 (volatile unsigned int *)(0x01C20064)
#define Timer0_CMP2 (volatile unsigned int *)(0x01C20068)
#define Timer0_CMP3 (volatile unsigned int *)(0x01C2006C)
#define Timer0_CMP4 (volatile unsigned int *)(0x01C20070)
#define Timer0_CMP5 (volatile unsigned int *)(0x01C20074)
#define Timer0_CMP6 (volatile unsigned int *)(0x01C20078)
#define Timer0_CMP7 (volatile unsigned int *)(0x01C2007C)

/*-----------------------------------------------------------------*/

#define CLEAR_REG (0x00000000)

/*---------------------TGCR REG ENABLE MACRO-----------------------*/

#define ENABLE_TIM34RS (0x00000002)
#define ENABLE_TIMMODE_32UC (0x00000004)
#define ENABLE_PS_COUNT16 (0x00000F00)
/*-----------------------------------------------------------------*/

/*------------------------PRD REG MACRO----------------------------*/
#define MODE34_PRD_2S (0x002DC6C0) //2 SECS
#define MODE34_PRD_1S (0x0016E360) //1 SECS
#define MODE34_PRD_1_2S (0x000B71B0) //0.5 SECS
#define MODE34_PRD_625uS (0x000003AA) //625 uSECS
#define MODE34_PRD_250uS (0x00000177) //250 uSECS
/*-----------------------------------------------------------------*/

/*------------------------TCR REG MACRO-----------------------------*/
#define ENAMODE34_CONT (0x00800000)
/*------------------------------------------------------------------*/

/*-----------------------INTCTLSTAT REG MACRO-----------------------*/
#define ENABLE_INT34 (0x00010000) //PRDINTEN34 BIT
/*------------------------------------------------------------------*/

/*-----------------------GPIO_01 REG MACRO-------------------------*/

#define GPIOBANKDIRECTION_01 (volatile unsigned int *)(0x01E26010)
#define GPIOBANKOUTPUT_01 (volatile unsigned int *)(0x01E26014)
#define GPIOSETDATA_01 (volatile unsigned int *)(0x01E26018)
#define GPIOCLRDATA_01 (volatile unsigned int *)(0x01E2601C)

/*------------------------------------------------------------------*/

/*-----------------------PIN MEX REGISTER---------------------------*/
#define PINMUXREG_02 (volatile unsigned int *)(0x01C14128)
/*------------------------------------------------------------------*/

/*----------------------BANK 1 PIN 10 MACRO--------------------------*/

#define PINMUX02_SEL_GPIO (0x00400000)
#define GPIO_01_BANK1PIN10_SET (0x04000000)
#define GPIO_01_BANK1PIN10_CLR (0xFBFFFFFF)
/*------------------------------------------------------------------*/
/**/

void Timer_Register_Clear()
{

*(Timer0_TGCR) = (CLEAR_REG);
*(Timer0_PRD34) = (CLEAR_REG);
*(Timer0_TCR) = (CLEAR_REG);
*(Timer0_INTCTLSTAT) = (CLEAR_REG);

}

void Timer_Initialize()
{
Timer_Register_Clear();

*(Timer0_TGCR) = (ENABLE_PS_COUNT16|ENABLE_TIMMODE_32UC|ENABLE_TIM34RS);
*(Timer0_PRD34) = (MODE34_PRD_625uS);
*(Timer0_TCR) = (ENAMODE34_CONT);
*(Timer0_INTCTLSTAT) = (ENABLE_INT34);

}

void GPIO_Initialize()
{
*(PINMUXREG_02) = PINMUX02_SEL_GPIO;
*(GPIOBANKDIRECTION_01) = *(GPIOBANKDIRECTION_01) & (0x01FFFFFF);
}

void Timer0_ISR()
{
int i;
*(GPIOBANKOUTPUT_01) = GPIO_01_BANK1PIN10_SET;
for(i=0;i<10;i++);
*(GPIOBANKOUTPUT_01) = GPIO_01_BANK1PIN10_CLR;
for(i=0;i<10;i++);
HWI_enable();
}

  • Hi Jose,

    Cannot guess why it should not work for 625 us.

    Which code you use? it belongs to which package?

    A while ago, I have used the timer example which comes with the OMApl138 starterware package and able to change the time period.

    Please vist this thread too :http://e2e.ti.com/support/dsp/omap_applications_processors/f/42/p/339219/1184825

    Would you please try out that and reply??

    Regards,

    Shankari

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    --------------------------------------------------------------------------------------------------------

     

     

  • Hi Shankari,

    I checked with different timer period ranges for the code I posted above.The code seems to be working fine for 100 mS. I'm not really sure if this happens because the ISR routine is stored in the slower memory of the chip.If so, what will I have to do to speed up the ISR fetch process.

    I'm not really sure what You mean by package.I'm guessing you mean an evaluation board.I am using a custom board for my application.I developed the code from the data sheet available on TI's site.

    Regards,

    Jose

  • Hi Jose,

    I mean, TI had already released a software package , i.e. OMAPL138 Starterware which encloses the working and tested sample code of timer.

    You can either use that code or refer to it and compare with your own code.

    If you install the starterware package you will find the source code at path, "..\ti\OMAPL138_StarterWare_1_10_04_01\examples\lcdkOMAPL138\timer"

    timer.c

    #include "uart.h"
    #include "hw_uart.h"
    #include "interrupt.h"
    #include "soc_OMAPL138.h"
    #include "hw_syscfg0_OMAPL138.h"
    #include "timer.h"
    #include "lcdkOMAPL138.h"
    #include "uartStdio.h"
    
    #ifndef _TMS320C6X
    #include "cpu.h"
    #endif
    
    /******************************************************************************
    **                      INTERNAL MACRO DEFINITIONS
    *******************************************************************************/
    #define STR_LEN                        (13)
    #define TMR_PERIOD_LSB32               (0x07FFFFFF)
    #define TMR_PERIOD_MSB32               (0x0)
    
    /******************************************************************************
    **                      INTERNAL FUNCTION PROTOTYPES
    *******************************************************************************/
    static void TimerIsr(void);
    static void TimerSetUp64Bit(void);
    static void TimerIntrSetUp(void);
    
    /******************************************************************************
    **                      INTERNAL VARIABLE DEFINITIONS
    *******************************************************************************/
    static unsigned char cntArr[9] = {'8', '7', '6', '5', '4', '3', '2', '1', '0'};
    static volatile unsigned int secCnt = 0;
    static volatile unsigned int flagIsrCnt = 0;
    
    /******************************************************************************
    **                          FUNCTION DEFINITIONS
    *******************************************************************************/
    int main(void)
    {
        /* Set up the UART2 peripheral */
        UARTStdioInit();
    
        /* Set up the Timer2 peripheral */
        TimerSetUp64Bit();
    
        /* Set up the AINTC to generate Timer2 interrupts */
        TimerIntrSetUp();
    
        /* Enable the timer interrupt */
        TimerIntEnable(SOC_TMR_2_REGS, TMR_INT_TMR12_NON_CAPT_MODE);
    
    #ifndef _TMS320C6X
        /* Switch to non privileged mode; This is done for demonstration purpose */
        CPUSwitchToUserMode();
    #endif
    
        /* Send the first String */
        UARTPuts("Tencounter: 9", -1);
    
        /* Start the timer. Characters from cntArr will be sent from the ISR */
        TimerEnable(SOC_TMR_2_REGS, TMR_TIMER12, TMR_ENABLE_CONT);
    
        /* make sure all the characters from cntArray from ISR */
        while(secCnt < 9)
        {
            /* Replace previous number each time the timer interrupt occurs */
            if(flagIsrCnt)
            {
                UARTPutc('\b');
                UARTPutc(cntArr[secCnt]);
                secCnt++;
                flagIsrCnt = 0;
            }
        }
    
        /* Disable the timer. No more timer interrupts */
        TimerDisable(SOC_TMR_2_REGS, TMR_TIMER12);
    
        /* Halt the program */
        while(1); 
    } /* ** Timer Interrupt Service Routine */ static void TimerIsr(void) { /* Disable the timer interrupt */ TimerIntDisable(SOC_TMR_2_REGS, TMR_INT_TMR12_NON_CAPT_MODE); #ifdef _TMS320C6X /* Clear interrupt status in DSPINTC */ IntEventClear(SYS_INT_T64P2_TINTALL); #else /* Clear the interrupt status in AINTC */ IntSystemStatusClear(SYS_INT_TIMR2_ALL); #endif TimerIntStatusClear(SOC_TMR_2_REGS, TMR_INT_TMR12_NON_CAPT_MODE); /* Signal application to print a new character */ flagIsrCnt = 1; /* Enable the timer interrupt */ TimerIntEnable(SOC_TMR_2_REGS, TMR_INT_TMR12_NON_CAPT_MODE); } /* ** Setup the timer for 64 bit mode */ static void TimerSetUp64Bit(void) { /* Configuration of Timer */ TimerConfigure(SOC_TMR_2_REGS, TMR_CFG_64BIT_CLK_INT); /* Set the 64 bit timer period */ TimerPeriodSet(SOC_TMR_2_REGS, TMR_TIMER12, TMR_PERIOD_LSB32); TimerPeriodSet(SOC_TMR_2_REGS, TMR_TIMER34, TMR_PERIOD_MSB32); } /* ** Set up the ARM Interrupt Controller for generating timer interrupt */ static void TimerIntrSetUp(void) { #ifdef _TMS320C6X /* Initialize the DSPINTC */ IntDSPINTCInit(); /* Register the Timer ISR */ IntRegister(C674X_MASK_INT4, TimerIsr); /* Map Timer interrupts to DSP maskable interrupt */ IntEventMap(C674X_MASK_INT4, SYS_INT_T64P2_TINTALL); /* Enable DSP interrupt in DSPINTC */ IntEnable(C674X_MASK_INT4); /* Enable DSP interrupts */ IntGlobalEnable(); #else /* Initialize AINTC and register timer interrupt */ IntAINTCInit(); /* Register the Timer ISR */ IntRegister(SYS_INT_TIMR2_ALL, TimerIsr); /* Set the channel number for Timer interrupt, it will map to IRQ */ IntChannelSet(SYS_INT_TIMR2_ALL, 2); /* Enable IRQ for ARM (in CPSR)*/ IntMasterIRQEnable(); /* Enable AINTC interrupts in GER */ IntGlobalEnable(); /* Enable IRQ in AINTC */ IntIRQEnable(); /* Enable timer interrupts in AINTC */ IntSystemEnable(SYS_INT_TIMR2_ALL); #endif }


    Regards,

    Shankari

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.
    --------------------------------------------------------------------------------------------------------

  • Hi Shankari,

    Yes that did help.Thank You.

    Regards,

    Jose