AnsweredAssumed Answered

Interrupt not working

Question asked by ST MICROCONTOLLER on Dec 21, 2016
Latest reply on Jan 9, 2017 by travkin.roman

I am trying to run a code in which timer causes an interrupt and everytime interrupt is generated, a variable h is incremented, but it remains zero in quickwatch window. My code is written below in stvd and cosmic compiler.

 

#include "stm8s.h"
#include "stm8s_tim1.h"
#include "stm8s_itc.h"

 

#define TIM1_PSCRH (*(volatile uint8_t *)0x5260)
#define TIM1_CR1    (*(volatile uint8_t *)0x5250)
#define TIM1_ARRH    (*(volatile uint8_t *)0x5263)
#define TIM1_ARRL    (*(volatile uint8_t *)0x5264)
#define TIM1_PSCRL    (*(volatile uint8_t *)0x5261)
#define TIM1_IER (*(volatile uint8_t *)0x5254)

 

int h;

 

void main(void)
{
            //TIM1_SetCounter(5);enableInterrupts();GPIO_Config();
            //TIM1_DeInit();

 

TIM1_ARRH=0X55;
TIM1_ARRL=0X26;
TIM1_PSCRH = 0x3e;
TIM1_PSCRL = 0x80;
TIM1_CR1=0X81;
TIM1_IER=0X01;
enableInterrupts();
      while(1)
      {
        
       }
         }

 

INTERRUPT_HANDLER (TIM1_UPD_OVF_IRQHANDLER,23)
//@interrupt @far void TIM1_OVF_TRG_BRK_IRQ_Handler(void)
{
    h++;
}

 

    
#ifdef USE_FULL_ASSERT

 

/**
  * @brief  Reports the name of the source file and the source line number
  *   where the assert_param error has occurred.
  * @param file: pointer to the source file name
  * @param line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

 

  /* Infinite loop */
  while (1)
  {
  }
}
#endif

 

 

 

 

What is wrong with the code? Kindly help me.

Thank you.

Outcomes