2020-01-04 09:52 PM
//STM8 Discovery freezes if TIM4_IER is set or rim() is used
//please help, I'm using free mode Cosmic Compiler on STVD
#include "iostm8s105.h"
void init_port(void){
PD_ODR = 0x00;
PD_DDR = 0xff; //output
PD_CR1 = 0xff; //pushpull
}
@interrupt test(void) {
TIM4_SR &= 0xfe; // Status register
}
void ini_timer4(void){
TIM4_IER |= 0x01; // Interrupt Enable reg
TIM4_PSCR = 0x15; // Prescaler register
TIM4_ARR = 0xf0; // Auto-reload reg
TIM4_SR = 0x00; // Status register
TIM4_CNTR = 0xaa; // Counter reg High
TIM4_CR1 |= 0x01; // Control register
}
void delaytime(void){
for(del=0;del<50000;del++);
}
void main(void){
ini_port();
ini_timer4();
rim(); //enable interrupt
while (1){
PD_ODR |= 0x01;
delaytime();
PD_ODR &= 0xfe;
delaytime();
}}
2020-01-08 07:50 AM
Solved the problem already, it was caused by incorrect interrupt vector address.