STM8S interrupt service routine execution problem

Status
Not open for further replies.

Briez

Member level 5
Joined
Nov 30, 2012
Messages
83
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Activity points
1,835
I am new to stm8s microcontroller programming but I am well known programmer of pic16 and avr microcontroller. Now a days I am learning the programming of stm8s microcontroller so I have made a program for 8bit timer4 module and tried to simulate using STVD simulator but I couldn't find my program counter executing my interrupt service routine. I have seen ST Standard peripheral library for code development but still I can't make efficient code for timer4.

Can any one please help how to write and execute ISR vector for timer4?

I am using STVD and COSMIC as a compiler.
 

Code:
 INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23)
 {
  /* In order to detect unexpected events during development,
     it is recommended to set a breakpoint on the following instruction.
  */
 }
 

Thank you for help. I tried this one also but couldn't get into is. At building the project it shows me 2 errors.
1) missing )
2) old style argument declaration
 
Last edited:

Post your code because we have nothing to talk about. Be sure, STVD and Cosmic work fine.
Did you forgot global IT turn on?
Code:
rim();
 

It shows me an error missing prototypes while I write rim();

I have written code like,


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostm8s103.h>
 
Void main() 
{
 
   PD_DDR=0XFF;
 
   TIM4_PSCR=0X03;
    TIM4_ARR=0X02;
    TIM4_IER=1;
    TIM4_CR1=1;
 
   rim() ;
 
while(1)
  {
 
  }
} 
 
INTERRUPT_HANDLER (TIM4_UPD_OVF_IRQHandler,23)
{
 
  PD_ODR=! PD_ODR;
  TIM4_SR=0;
}

 
Last edited by a moderator:

Hard to say. I'm using IAR Workbench. For stm8s header stm8s.h should be included.
 

ok. I included stm8s.h and stm8s_conf.h but still PC cant jump in ISR.

And if i want to try IAR workbench for stm8 then from where can i download it? Provide me link for its .crk also?
 

It is necessary also uncomment #define for mcu type selection in stm8s.h.
 

I did uncomment on stm8s003 as I want to make code for that uC.

But still program doesn't work.
 

When I didn't include stm8s.h file it shown an error prototype missing for rim (); but now after including that file no errors and no warning for build.

But my program counter couldn't jump into isr.
 

In the debug session when I manually update value of irq23 to 1 in I/O stimulation window, my program counter jumps to
Code:
 @far @interrupt void NonHandledInterrupt (void)
and returns to main (). Why does this happens?
 

I test this code with IAR and it work, in free run and under ST-LINK debugger. may be also it is necessary to select mcu type in project settings.
Code:
#include "iostm003.c"
#include "stm8s.h" 
 
void main() 
{
  PD_DDR=0xff; //conf as output
  PD_CR1=0xff; //push-pull|pullup

 
    TIM4->PSCR=0X03;
    TIM4->ARR=0X02;
    TIM4->IER=1;
    TIM4->CR1=1;
    rim() ;
 
while(1)
  {


  }
} 
 
INTERRUPT_HANDLER (TIM4_UPD_OVF_IRQHandler,23)
{
 
  PD_ODR = !PD_ODR;
  TIM4->SR1=0;
}
 

I don't have file iostm8s003.c to include.

I have iostm8s103.h or iostm8s.h.

So is there any problem with this?
 

I think the deal not in "iostm" - probably the problem in simulator. In IAR software simulation interruptions are processed after manual setting in "Interrupt setup" menu - rim() and IER do not affect on this.

Code:
#include "stm8s.h" 
 
void main() 
{
  GPIOD->DDR=0xff; //conf as output
  GPIOD->CR1=0xff; //push-pull|pullup

 
    TIM4->PSCR=3;
    TIM4->ARR=2;
    TIM4->IER=1;
    TIM4->CR1=1;
    rim() ;
 
while(1)
  {


  }
} 
 
INTERRUPT_HANDLER (TIM4_UPD_OVF_IRQHandler,23)
{
 
  GPIOD->ODR = 0xff^GPIOD->ODR;
  TIM4->SR1=0;
}
 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…