AnsweredAssumed Answered

Facing problem in Peripheral Timer verification in ADSP 21489

Question asked by satya on May 12, 2012
Latest reply on Jun 6, 2012 by satya
Branched to a new discussion

Hello,

 

I want to use peripheral timer in ADSP 21489. As per guidelines from hardware and programming reference manual  I'm  initialized the PLL and Timer registers and interrupt to get the service of timer.

 

A code was given below please go through that and help me if i left something required for working of peripheral timer.

PLL and Timer are two separate C file in my project.

#include <def21489.h>

#include <cdef21489.h>

#define NOP asm volatile("nop;")

void initPLL(){

  int i;

    *pPMCTL= PLLM16|DIVEN|PLLD8;

   *pPMCTL|= PLLBP;

   *pPMCTL^= DIVEN;

    //Wait for around 4096 cycles for the pll to lock.

    for (i=0; i<5000; i++)

          NOP;

     *pPMCTL^= PLLBP;

    //Wait for around 15 cycles for the output dividers to stabilize.

     for (i=0; i<16; i++)

          NOP;

           }

   

#include <stdio.h>

#include <def21489.h>

#include <cdef21489.h>

#include <signal.h>

#include <21489.h>

#include <sysreg.h>

#include <SRU.h>

 

int count = 0;

extern void initPLL(void);

void GPTimer0_Isr();

void initTimer(void);

   main()

 

{

    while(1)

    {

   

    *pPICR0 |= P2I;

   

    initPLL();

   

//    SRU2 (TIMER0_O, TIMER0_I);

   

       

    initTimer();

   

    interrupt(SIG_GPTMR0, GPTimer0_Isr);

           

    if ((*pTMSTAT & TIM0IRQ) ==0)

   

    {

        printf (" hello this is only trial \n");

       

       

    }

//        *pTMSTAT = TIM0IRQ;

   

    }

   

}

 

void initTimer (void)

{

   

//    int i , period ;

         

    *pTMSTAT |= TIM0DIS;

       

    *pTM0CTL = TIMODEEXT|PULSE|PRDCNT|IRQEN;

   

    *pTM0PRD = 0x1000;

   

    *pTMSTAT |= TIM0EN;

   

//    period = *pTM0PRD;

   

       

//    for (i=0;i <= period; i++)

//    {

       

//     GPTimer0_Isr();

   

//    }

   

 

}

 

void GPTimer0_Isr()

{

       

   

    printf ("  count is %d\n", count);

   

    count++;

   

//    *pTMSTAT &= TIM0IRQ;

 

}

Outcomes