cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Start STM counter for SPC560B64 controller

bhagyashri
Associate
Posted on November 11, 2016 at 12:29

Hi,

We are using SPC560B64 controller and want to start STM_0, unable to start STM counter. Please provide us the sample code for STM timer start.

Regards,

Bhagyashri
2 REPLIES 2
procolo
Senior
Posted on November 14, 2016 at 08:24

Hello,

current version of SPC5Studio supports STM driver for RLA architecture. Driver comes with his own test application for all supported platform includind spc560b. Simply import it using the wizard, generate and you will get the code you need.

the STM counter start code is located in stm_lld_enable function

void stm_lld_enable (STMDriver *stmd){

  uint8_t i;

  /* set the prescaler */

  stmd->stm_tagp->CR.R = (stmd->prescaler-1U) << 8 ;

  /* set compare register and enable channels */

  for (i=0; i<stmd->noofchannels;i++){

    if (stmd->stm_ch_config[i].enabled == TRUE){

      /* set compare register */

      stmd->stm_tagp->CH[i].CMP.B.CMP = stmd->stm_ch_config[i].counter;

      /* clear  interrupt flag */

      stmd->stm_tagp->CH[i].CIR.B.CIF = STM_CCR_CIF_CLEAR;

   /* enable channel */

      stmd->stm_tagp->CH[i].CCR.B.CEN = STM_CIR_CEN_ENABLE;

    }

  }

  /* reset counter */

  stmd->stm_tagp->CNT.R     = 0x00000000U;

  /*enable STM */

  stmd->stm_tagp->CR.B.TEN  = STM_CR_TEN_ENABLE;

}

Regards

procolo
Senior
Posted on November 14, 2016 at 08:25