Topic : Questions on creating interrupt using Rlink on chip STM8S

Forum : ST7/STM8

Original Post
Post Information Post
September 7, 2010 - 5:52am
Guest

Hi as i read on the various topics bout interrupt, i had some other questions, so anyone please help.

1. can we just name the interrupt name to our reference?
e.g.

void Timer3Interrupt (void) interrupt 4
{
my codes........
}

2. From my datasheet, there's no specific vector address or what so ever for me to reference to the interrupt vectors. So does that means I can really choose any interrupt number (like my example) even though i'm using a timer interrupt?

Replies
Post Information Post
+1
0
-1
September 7, 2010 - 9:57am
Guest

hi ppl,

is my question make no sense?

erm.. i'm now rying to program an STM8 chip, using ride7.

I need to use the timer interrupt as i'm trying to control the pwm.

please i need help.

+1
0
-1
September 7, 2010 - 2:06pm
Raisonance Support Team

Hi,

Just have a look at the STM8 data sheet (be careful, there are 2 different documents) that you can find from the Ride7 "Documentation" window.
Search for the IRQ mapping and you will have the timer interrupt number.

Regards,

+1
0
-1
September 8, 2010 - 11:25am
Guest

Hi Bruno,

I manage to locate the IRO number. Thanks for that

As i used timer1 CC interrupt; below is my init code.

TIM1_CCMR1= TIM1_CCMR_OCM_OCxPE; // OC1 PWM output compare mode 1
TIM1_CCER1= TIM1_CCER1_CC1E; // OC1 enable output pin
TIM1_BKR|= TIM1_AOE; // automatic output control modes enable

TIM1_CR1|= TIM1_CR1_CEN; // timer 1 enable

my interrupt codes;

void TIM1_CC_Interrupt (void) interrupt 12 {

switch_all_LEDs_on; // NO - switch LEDs on
TIM1_IER&=~TIM1_IER_CC1IE; // disable Capture/compare interrupt
return;
}

i just unable to enter to the interrupt codes

please help...

+1
0
-1
September 9, 2010 - 9:20am
Raisonance Support Team

Hi,

Can you try with the examples from the ST Firmware Library? They are given along with the RKit-STM8 and will provide helpful (and working) examples that you can follow to understand why yours isn't working.

Regards,

+1
0
-1
September 13, 2010 - 10:48am
Guest

hi bruno, i had yet to solved the interrupt problem, so i need more of your advice. I'll be more clear this time. From what i had know, i had created an interrupt using timer. i checked the address from the Memory View, it's correct, it jumpt to the interrupt address i want. But the problem is the codes did not worked... on top of that there's this pop up message saying: No response from the DTC (Data Transfer Component) Terminating debug session.

Below are my codes, please advice if anything i can do...

/* Private define ------------------------------------------------------------*/
#define AUTORELOAD 0x9FF //period of pulses definition
#define ALL_LEDs 0x0F //evaluation board LEDs mask

// ***Internal Clock Set Up bits***
#define CLK_ICKR_LSIEN 0x10 // Enable Low Speed Oscillator

// ***Timer interrupt bits***
#define TIM1_IER_CC1IE 0x02 //Enable CC1 interrupt
#define TIM1_SR1_CC1IF 0x02 //Set CC1 interrupt flag
#define TIM1_EGR_CC1G 0x02 //Enable CC1 Generation

// ***INIT bits***
#define TIM1_CCMR_OCM_OCxPE 0x68 //PWM mode 1 - In up-counting, OC1PE enable
#define TIM1_CCER1_CC1E 0x01 //Output enable
#define TIM1_AOE 0x40 //set Auto Output enable
#define TIM1_CR1_APRE 0 //Enable Auto preload reload
#define TIM1_CR1_CEN 0x01 //timer1 enable
/* Private macro -------------------------------------------------------------*/
#define switch_all_LEDs_off { PD_ODR|= ALL_LEDs; }
#define switch_all_LEDs_on { PD_ODR&=~ALL_LEDs; }

void TIM1_UPD_OVF_TRG_BRK_IRQHandler (void) interrupt 12
{
switch_all_LEDs_off; // NO - switch LEDs off
TIM1_SR1 =~TIM1_SR1_CC1IF; // disable Capture/compare interrupt flag
return;
}

void main(void)
{

//unsigned char i;
// *** GIO INIT ***
switch_all_LEDs_on; // LEDs - as push-pull outputs, all on
PD_DDR|= ALL_LEDs;
PD_CR1|= ALL_LEDs;

// *** Internal Clock Set up ***

CLK_ICKR = CLK_ICKR_LSIEN; // Enable Low speed internal oscillator, fMaster = 128kHz

// *** TIMER 1 INITIALIZATION ***
TIM1_ARRH= (AUTORELOAD >> 8); // init pulse period - auto reload register
TIM1_ARRL= (AUTORELOAD);
TIM1_CCR1H= ((AUTORELOAD/2) >> 8); // init pulse wide (50% duty cycle) - compare register
TIM1_CCR1L= (AUTORELOAD/2);

TIM1_CR1 = TIM1_CR1_APRE; //Enable Auto preload reload
TIM1_CCMR1= TIM1_CCMR_OCM_OCxPE; // OC1 PWM output compare mode 1
TIM1_CCER1= TIM1_CCER1_CC1E; // OC1 enable output pin
TIM1_BKR|= TIM1_AOE; // automatic output control modes enable

TIM1_EGR = TIM1_EGR_CC1G; //Enable CC1 generation

ITC_SPR4 = 0xFC; //Interrupt Vector 12 level 00
TIM1_SR1&=~TIM1_SR1_CC1IF; //Clear CC1 interrupt flag
TIM1_IER = TIM1_IER_CC1IE; // Enable Capture/compare interrupt

TIM1_CR1|= TIM1_CR1_CEN; // timer 1 enable

while(1){
}
}

+1
0
-1
September 13, 2010 - 12:03pm
Raisonance Support Team

Hi,

The message about the "DTC" indicates that you lost the connection with your debugger.

I suggest that you add some blinking LED in you main loop, just to check whether your processor keep running.

However, we have limited knowledge about the internals of STMicroelectronics devices, and even less about their peripherals.

We suggest that you contact the ST support team for more help on this issue.

Regards,

+1
0
-1
September 14, 2010 - 2:37am
Guest

ok...thanks for your advice

+1
0
-1
September 14, 2010 - 3:18am
Guest

Hi Bruno,

now i had this doubt, can you help clear it for me? ;)

i'm using Ride7, and from the library examples, mostly are in cosmic IDE context (it given by the ST FAE). so I always change the context to Ride IDE to run it.

so other than the context difference what other difference is there between cosmic and ride?

+1
0
-1
September 14, 2010 - 8:54am
Raisonance Support Team

Hi,

You can download the application note "AN55-Porting Cosmic applications to Raisonance" from our Web site. It is clear, helpful and quick-reading.

Regards,