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.

BeagleBone dmTimerCounter

Hello,

I try example dmTimercount and it works. After I create a new empty project and I import all files I need.

For example GPIO blink led I do it and it works but for dmtimer I have a problem with "cpu.c"

When I import it and I build I have error#18 expected a ")"

code come from starterware, no modification. Error is on line ...(stat));

unsigned int CPUIntStatus(void)
{
unsigned int stat;

/* IRQ and FIQ in CPSR */
asm(" mrs r0, CPSR\n\t"
" and %[result], r0, #0xC0" : [result] "=r" (stat));

return stat;
}

I found there's two files cpu.c in gcc and cgt but in cgt folder this function doesn't exist.

 

Thanks

  • david guilleman said:
    asm(" mrs r0, CPSR\n\t"
    " and %[result], r0, #0xC0" : [result] "=r" (stat));

    This is GCC inline assembler. I'd assume you are using TI's ARM-compiler which does not support this feature. Same for dmTimer-Example: the one for TI's compiler does not use any functions that require inline assembler, so I think you simply mixed some code for GCC and TI's compiler.

  • Ok so I need to take cpu.c in cgt folder. 

    If I open it, instead of fonction like for gcc to have status I have this:

    **
    ** Wrapper function for the IRQ status
    **
    */
    __asm(" .sect \".text:CPUIntStatus\"\n"
    " .clink\n"
    " .global CPUIntStatus\n"
    "CPUIntStatus:\n"
    " mrs r0, CPSR \n"
    " and r0, r0, #0xC0\n"
    " bx lr");

    This is not a function so how it works, it's compil one time ?

  • This seems to be some non-inline assembler code to be used by TI's compiler.

    But...why do you set up a completely new project? Why don't you simply use the working dmTimer-project?

  • I change cpu.c and it's ok. 

    I try to make some modifications on example but when debugging, if there's no .C when I step by step I can't see nothing.

    So I have put all .c I need for example in a new project to debug. Maybe I can do it more easy but I just begin on CCS and starterware.

    Best regards

  • My problem was when I paused I have

    No source available for "UndefInstHandler() at C:/ti\AM335X_StarterWare_02_00_01_01\binary\armv7a\cgt_ccs\am335x\beaglebone\dmtimer\Debug\dmtimerCounter.out:{3} 0x8000284c{4}" 


    I was thinking it's because I haven't .c in program. Isn't it ?

     

  • One more question. What's difference between files in cgt (code generation tools I suppose) and gcc (gnu compiler collection I supposed)

    It means in cgt for TI compiler and gcc for the other ?

  • david guilleman said:
    I try to make some modifications on example but when debugging, if there's no .C when I step by step I can't see nothing.

    Are you sure you're using debug-build really?

  • Yes I'm sure. I found problem come from enable interrupt in CPSR register.

    When I comment it, it works. You say ti compiler don't work with asm syntax.

    So where can I find and equivalent of

        /* Enable IRQ in CPSR */
        asm("    mrs     r0, CPSR\n\t"
            "    bic     r0, r0, #0x80\n\t"
            "    msr     CPSR_c, r0");

    I understand move CPSR in temp variable, clear IRQ disable bit flag and move in control register.

    Can I do it with HWREG( syntax ? If yes I don't find adress CPSR and CPSR_c in datasheet.

  • Nobody have an function to enable global interrupt and compile on ti compiler ?

    Thanks

  • I'd definitely recommend you to not to mix GCC and TI-ARM-compiler code and stay wit hthe examples only that fit to your compiler. Its everything there and you do not need to look for things that are shown just in the right example. What you are looking for is

    IntMasterIRQEnable();

    and it can be found in dmTimer example too.

  • Hi Hans and David,  I am getting a same error for lwip code. I use ev am335x with starterware, ccs5 and XDS100V2USB. when i run it run until certain point then stay there for ever, when i pause it stops at

    No source available for "UndefInstHandler()

     

    regards

    terrance

  • Hi Hans,

    I don't understand. I wan't to have all .C programs in my project from the example. No only links.

    So normally i can import gpio.c, gpio_v2.c ... which are call in example.

    You means i can't do this because in example source there's code not for ti compiler ?

    So if this code don't work with ti compiler, have you got some code to enable global interrupt for ti compiler.

    I just wan't to have all source in my projet .

    best regards

  • David,

    void IntMasterIRQEnable(void)

    void IntMasterIRQDisable(void)

    this function in interrupt.c whihc is part of the system.lib file which you already include inside the project configuration ,

    you also have to enable the GPIO interrupt before enable the global interrupt

  • Ok, thanks, I included system in my project and It works. But IntMasterIRQEnable use CPU.c and normally if I included CPU.C and Interrupt.C in my project instead of system.lib it is same... No ? And when I compile system I have no error with Ti compiler. But it works so I keep that.

    An other problem if I modify counter value for reload and initial, interrupt don't works. I try again with original value from example 0xFF000000u. It works. I change with any other value. No interrupt.

  • I have miss your first post, sorry. For undefinde handler, if I reset beaglebone and I reload program, it works. I have sometime this message so when I have I reset and I reload.

  • I precise something for my question. When I look TCCR register, and if I configure reload value to 0x000000FF. I see TCCR continue to count and each pass on 0x000000FF I have an interrupt. Is it normal ? Reload is not pout in TCCR register ? 

    I have just change in dmtimer example to on/off output instead of communication. With default value 0xFF000000 I have change every 700ms but if I put others values I have nothing. For example 0x000000FF;

  • Hi David,  The timer you configure works as upcounter or down counter? if it is up counter it count until tyhe register over flow, so differnt value make interrupt in differnmt time, some times your timer may be smalller than watch dog timer tehn it will reset.

     

    My post : Don't reset or reload,  just click restart button then see what is happening , monitor the program counter is it go back the original position or starting in different loaction

  • Thanks for your help. I use configuration from dmtimer example. So it's up counter and autoreload. If I understand, if I put 20000 in load value, each 20000 I must have an interrupt but TCCR continue until overflow ?

    Because here I have an interrupt on each passage to 20000.

  • Hi David, If it is upcounter then check whetehr it is 16bit or 32bit timer, if it 16bit timer then

    it will over flow after (0xFFFF-20000) machine cycle if ti is 32bit then (0xFFFFFFFF - 20000)

  • Hi, it's a 32 bits register. I want to have one interrupt for example each 0x0000FFFFu. I have change to compare mode mode but not better. I post my code if you see a mistake. TCCR continue over 0x0000FFFFu and make an interrupt next passage...

    
    #include "soc_AM335x.h"
    #include "beaglebone.h"
    #include "interrupt.h"
    #include "dmtimer_bis.h"
    #include "gpio_v2.h"
    #include<stdio.h>
    #include<math.h>
    
    /******************************************************************************
    **                      INTERNAL MACRO DEFINITIONS
    *******************************************************************************/
    #define TIMER_INITIAL_COUNT             (0x0000FFFFu)
    #define TIMER_RLD_COUNT                 (0x0000FFFFu)
    #define TIMER_TMAR_COUNT                (0x0000FFFFu)
    
    /*****************************************************************************
    **                INTERNAL FUNCTION PROTOTYPES
    *****************************************************************************/
    //static void Delay(unsigned int count);
    static void DMTimerAintcConfigure(void);
    static void DMTimerSetUp(void);
    static void DMTimerIsr(void);
    
    /******************************************************************************
    **                      INTERNAL VARIABLE DEFINITIONS
    *******************************************************************************/
    static volatile unsigned int flagIsr = 1;
    
    
    /*****************************************************************************
    **                INTERNAL FUNCTION DEFINITIONS
    *****************************************************************************/
    /*
    ** The main function. Application starts here.
    */
    int main()
    {
        /* This function will enable clocks for the DMTimer2 instance */
        DMTimer2ModuleClkConfig();
    
        /* Enable IRQ in CPSR */
        IntMasterIRQEnable();
    
        /* Register DMTimer2 interrupts on to AINTC */
        DMTimerAintcConfigure();
    
        /* Perform the necessary configurations for DMTimer */
        DMTimerSetUp();
    
        /* Enable the DMTimer interrupts */
        DMTimerIntEnable(SOC_DMTIMER_2_REGS, DMTIMER_INT_MAT_EN_FLAG);
    
        /* Start the DMTimer */
        DMTimerEnable(SOC_DMTIMER_2_REGS);
    
        /******************************************************************/
    
        while(1)
        {
    
        	if (flagIsr==1)
        	{
        		flagIsr=0;
        	}
    
        }
    
    }
    
    /*
    ** Do the necessary DMTimer configurations on to AINTC.
    */
    static void DMTimerAintcConfigure(void)
    {
        /* Initialize the ARM interrupt control */
        IntAINTCInit();
    
        /* Registering DMTimerIsr */
        IntRegister(SYS_INT_TINT2, DMTimerIsr);
    
        /* Set the priority */
        IntPrioritySet(SYS_INT_TINT2, 0, AINTC_HOSTINT_ROUTE_IRQ);
    
        /* Enable the system interrupt */
        IntSystemEnable(SYS_INT_TINT2);
    }
    
    /*
    ** Setup the timer for one-shot and compare mode.
    */
    static void DMTimerSetUp(void)
    {
        /* Load the counter with the initial count value */
        DMTimerCounterSet(SOC_DMTIMER_2_REGS, TIMER_INITIAL_COUNT);
    
        /* Load the load register with the reload count value */
        DMTimerReloadSet(SOC_DMTIMER_2_REGS, TIMER_RLD_COUNT);
    
        /* Load Compare value */
    	DMTimerCompareSet(SOC_DMTIMER_2_REGS, TIMER_TMAR_COUNT);
    
    	/* Compare mode with autoreload */
    	DMTimerModeConfigure(SOC_DMTIMER_2_REGS, DMTIMER_AUTORLD_CMP_ENABLE);
    }
    /*
    ** DMTimer interrupt service routine. This will send a character to serial
    ** console.
    */
    static void DMTimerIsr(void)
    {
    
        DMTimerIntDisable(SOC_DMTIMER_2_REGS, DMTIMER_INT_MAT_EN_FLAG);
        DMTimerIntStatusClear(SOC_DMTIMER_2_REGS, DMTIMER_INT_MAT_IT_FLAG);
        flagIsr = 1;
        DMTimerIntEnable(SOC_DMTIMER_2_REGS, DMTIMER_INT_MAT_EN_FLAG);
    }
    /******************************* End of file *********************************/
    

    Here timer register TCCR over reload value.

  • http://e2e.ti.com/support/embedded/starterware/f/790/p/302178/1056186.aspx#1056186

  • Ok, I tried to add in DmTimerSetUp:

    DMTimerPreScalerClkDisable(SOC_DMTIMER_2_REGS);
    DMTimerReset(SOC_DMTIMER_2_REGS);

    But not better. I read in post you link there's no really answer. I don't understand why TCCR isn't reload with good value and continue.

  • Sorry it works with this, I try it again

    DMTimerPreScalerClkDisable(SOC_DMTIMER_2_REGS);
    DMTimerReset(SOC_DMTIMER_2_REGS);

     

    Thanks

  • David, did you resolve this probelm?

  • Yes, I checked Verify answer