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.

Configuração do timer

Good day I'm trying to make a program that when the code enters a loop it enables the led there a timer that counts a time and then disable the timer turns off the LED timer enables the new account a while back and disable the timer to the beginning and is well but I can not set the timer to set to 32bits I chained the following excerpt from the program and a part of the configuration wrong know that most do not know what is happening or missing, the to look at me please .

 

#include "stdio.h"
#include "c6x.h"
#include "cslr.h"
#include "cslr_gpio.h"
#include "cslr_intc.h"
#include "cslr_psc_C6747.h"
#include "cslr_syscfg_C6747.h"
#include "cslr_tmr.h"
#include "soc_C6747.h"
#include "tistdtypes.h"

//=========================================================================================
//                              VARIAVEIS GLOBAL
//=========================================================================================
// sys config registers overlay                                              
CSL_SyscfgRegsOvly   sysRegs  = (CSL_SyscfgRegsOvly)(CSL_SYSCFG_0_REGS);
// Psc register overlay                                                      
CSL_PscRegsOvly      psc1Regs = (CSL_PscRegsOvly)(CSL_PSC_1_REGS);
// Gpio register overlay                                                     
CSL_GpioRegsOvly     gpioRegs = (CSL_GpioRegsOvly)(CSL_GPIO_0_REGS);
//Interrupt Controller Register Overlay                                     
CSL_IntcRegsOvly intcRegs = (CSL_IntcRegsOvly)CSL_INTC_0_REGS;

CSL_TmrRegsOvly tmr0Regs = (CSL_TmrRegsOvly)CSL_TMR_0_REGS;
CSL_TmrRegsOvly tmr1Regs = (CSL_TmrRegsOvly)CSL_TMR_1_REGS;

//=========================================================================================
//                         PROTOTIPO DE FUNÇAO EXTERNA
//=========================================================================================
extern void intcVectortable(void);

//=========================================================================================
//                           PROTOTIPOS DE SUBROTINA
//=========================================================================================
static void delay(Uint32 count);
static void setup_TIMER0(void);
static void setup_TIMER1(void);




//=========================================================================================
//
//======================================================================================================================
volatile Int32 status = 0;

//======================================================================================================================
//                                CONSTANTES
//======================================================================================================================
const unsigned int TIMER_PERIOD = 0xFFFFFFFF;

//======================================================================================================================
//                                 DEFINIÇÕES
//======================================================================================================================
#define MAX_BLINK      10

//======================================================================================================================
//                                SUB ROTINAS
//======================================================================================================================
void GPIOCONFIGURE(void)
{
    Uint32  teste = 0;
    Uint32  ledBlinkCount = 0;
    volatile Uint32 temp  = 0;
    volatile Uint32 pscTimeoutCount = 0;

//===================== Habilita a escrita nos registros ===============================================================
    sysRegs->KICK0R = 0x83e70b13;
    sysRegs->KICK1R = 0x95A4F1E0;

//============================ Habilita os gpios =======================================================================
    sysRegs->PINMUX14 = ((CSL_SYSCFG_PINMUX14_PINMUX14_27_24_GPIO0_8)  << (CSL_SYSCFG_PINMUX14_PINMUX14_27_24_SHIFT));
    sysRegs->PINMUX15 = ( (CSL_SYSCFG_PINMUX15_PINMUX15_11_8_GPIO0_12) << (CSL_SYSCFG_PINMUX15_PINMUX15_11_8_SHIFT) );

//============================ Desabilita a escrita nos registros ======================================================
    sysRegs->KICK0R = 0x83e70b13;
    sysRegs->KICK1R = 0x95A4F1E0;

//===================================== CONFIGURA OS GPIOS =============================================================
    gpioRegs->BANK[0].DIR &= ~(CSL_GPIO_DIR_DIR_IN << CSL_GPIO_DIR_DIR12_SHIFT);                   //SAIDA

    temp = gpioRegs->BANK[0].DIR;
    temp = ((temp & CSL_GPIO_DIR_DIR8_MASK) | (CSL_GPIO_DIR_DIR_IN << CSL_GPIO_DIR_DIR8_SHIFT) ); // ENTRADA
    gpioRegs->BANK[0].DIR |=temp;

//===================================== INICIALIZA PORTAIS =============================================================
    temp = gpioRegs->BANK[0].SET_DATA;
    temp = ( (temp & CSL_GPIO_SET_DATA_SET12_MASK) |(CSL_GPIO_SET_DATA_SET_SET << CSL_GPIO_SET_DATA_SET12_SHIFT));
    gpioRegs->BANK[0].SET_RIS_TRIG |= temp;
}
//==================================== CONFIGURAÇÃO DO TIMER ===========================================================
void setup_TIMER0(void)
{
    CSL_FINST(tmr1Regs->TIM12,TMR_TIM12_TIM12,RESETVAL);  //LIMPA O REGISTRO TIM12

    CSL_FINST(tmr1Regs->TIM34,TMR_TIM34_TIM34,RESETVAL);  //LIMPA O REGISTRO TIM32

    tmr0Regs->TGCR = CSL_FMKT(TMR_TGCR_TIMMODE,32BIT_UNCHAIN)
                     | CSL_FMKT(TMR_TGCR_TIM12RS,NO_RESET)
                     | CSL_FMKT(TMR_TGCR_TIM34RS,NO_RESET)
                     | CSL_FMK(TMR_TGCR_PSC34,0x1);


                         
    CSL_FINS(tmr0Regs->PRD12,TMR_PRD12_PRD12,TIMER_PERIOD);

                       
    CSL_FINS(tmr0Regs->PRD34,TMR_PRD34_PRD34,TIMER_PERIOD);

   
    CSL_FINS(tmr0Regs->TCR,TMR_TCR_CLKSRC12,0x0);

    CSL_FINS(tmr0Regs->TCR,TMR_TCR_CLKSRC34,0x0);
}
void setup_TIMER1 (void)
{
                      
    CSL_FINST(tmr1Regs->TIM12,TMR_TIM12_TIM12,RESETVAL);

                     
    CSL_FINST(tmr1Regs->TIM34,TMR_TIM34_TIM34,RESETVAL);

 
    tmr1Regs->TGCR = CSL_FMKT(TMR_TGCR_TIMMODE,32BIT_UNCHAIN)
                     | CSL_FMKT(TMR_TGCR_TIM12RS,NO_RESET)
                     | CSL_FMKT(TMR_TGCR_TIM34RS,NO_RESET)
                     | CSL_FMK(TMR_TGCR_PSC34,0x1);

                    
    CSL_FINS(tmr1Regs->PRD12,TMR_PRD12_PRD12,TIMER_PERIOD);

                  
    CSL_FINS(tmr1Regs->PRD34,TMR_PRD34_PRD34,TIMER_PERIOD);
   


    CSL_FINS(tmr1Regs->TCR,TMR_TCR_CLKSRC12,0x0);

    CSL_FINS(tmr1Regs->TCR,TMR_TCR_CLKSRC34,0x0);
}
   



//======================================================================================================================
//                            PROGRAMA PRINCIPAL
//======================================================================================================================
void main (void)
{

    volatile Uint32 teste = 50;
    volatile Uint32 temp  = 0;
   
    GPIOCONFIGURE();
    setup_TIMER0();
    setup_TIMER1();

    while(1)
    {

    temp = gpioRegs->BANK[0].CLR_DATA;
    temp = ( (temp & CSL_GPIO_CLR_DATA_CLR12_MASK) |(CSL_GPIO_CLR_DATA_CLR_CLR << CSL_GPIO_CLR_DATA_CLR12_SHIFT) );
    gpioRegs->BANK[0].CLR_DATA |= temp;
   

    CSL_FINS(tmr1Regs->PRD12,TMR_PRD12_PRD12,0xFFFFFFFF);

                  
    CSL_FINS(tmr1Regs->PRD34,TMR_PRD34_PRD34,0xFFFFFFFF);



    CSL_FINST(tmr0Regs->TCR,TMR_TCR_ENAMODE12,EN_CONTRELOAD);

    CSL_FINST(tmr0Regs->TCR,TMR_TCR_ENAMODE34,EN_CONTRELOAD);

                                 
    CSL_FINST(tmr1Regs->TCR,TMR_TCR_ENAMODE12,EN_CONTRELOAD);

                                 
    CSL_FINST(tmr1Regs->TCR,TMR_TCR_ENAMODE34,EN_CONTRELOAD);



    CSL_FINST(tmr0Regs->TCR,TMR_TCR_ENAMODE12,DISABLE);

   
    CSL_FINST(tmr0Regs->TCR,TMR_TCR_ENAMODE34,DISABLE);

 
    CSL_FINST(tmr1Regs->TCR,TMR_TCR_ENAMODE12,DISABLE);

  
    CSL_FINST(tmr1Regs->TCR,TMR_TCR_ENAMODE34,DISABLE);


    temp = gpioRegs->BANK[0].SET_DATA;
       temp = ( (temp & CSL_GPIO_SET_DATA_SET12_MASK) |(CSL_GPIO_SET_DATA_SET_SET << CSL_GPIO_SET_DATA_SET12_SHIFT) );
    gpioRegs->BANK[0].SET_DATA |= temp; 
   
    CSL_FINS(tmr1Regs->PRD12,TMR_PRD12_PRD12,0xFFFFFFFFF);

                  
    CSL_FINS(tmr1Regs->PRD34,TMR_PRD34_PRD34,0xFFFFFFFFF);




      /* Enable TIMER0 1:2 side, one shot mode                                  */
    CSL_FINST(tmr0Regs->TCR,TMR_TCR_ENAMODE12,EN_CONTRELOAD);

    /* Enable TIMER0 3:4 side, one shot mode                                  */
    CSL_FINST(tmr0Regs->TCR,TMR_TCR_ENAMODE34,EN_CONTRELOAD);

    /* Enable TIMER1 1:2 side, one shot mode                                  */
    CSL_FINST(tmr1Regs->TCR,TMR_TCR_ENAMODE12,EN_CONTRELOAD);

    /* Enable TIMER1 3:4 side, one shot mode                                  */
    CSL_FINST(tmr1Regs->TCR,TMR_TCR_ENAMODE34,EN_CONTRELOAD);



    CSL_FINST(tmr0Regs->TCR,TMR_TCR_ENAMODE12,DISABLE);

  
    CSL_FINST(tmr0Regs->TCR,TMR_TCR_ENAMODE34,DISABLE);


    CSL_FINST(tmr1Regs->TCR,TMR_TCR_ENAMODE12,DISABLE);


    CSL_FINST(tmr1Regs->TCR,TMR_TCR_ENAMODE34,DISABLE);










}

  • Leandro,

    1) I noticed that on the timer0 setup function, you are putting the timer1 TIM registers.. I think that is probably not intended.

    "   CSL_FINST(tmr1Regs->TIM12,TMR_TIM12_TIM12,RESETVAL);  //LIMPA O REGISTRO TIM12

       CSL_FINST(tmr1Regs->TIM34,TMR_TIM34_TIM34,RESETVAL);  //LIMPA O REGISTRO TIM32"

    2) Also, did you followed the timer configuration procedure as explained in the timer user guide and make sure you are not missing any configuration registers?

    3) which timer mode are you trying to use 64bit, 32-bit chained or 32-bit unchained? 

    4) some tips, ensure that the PSC is enabled for the Timer instance that you are using.

    regards,

    miguel


  • Hi Leandro,

    Has your query been resolved? Please reply or else as a part of process we need to close the thread.

     

    Best Regards,

    Ankit Agrawal