2019-12-18 11:20 AM
Hello,
I stated using the STM8f003 uC.
For simple start I want to implement a flashing LED using the TIMER1 overflow interrupt
of the core. The code does compile and can be flash without problems.
Sadly the LED never lights up -> the interrupt is not even triggered once.
Does somebody have an idea?
Thanks :)
#include "stm8.h"
#define F_CPU 1000000
#define PRE_SCALE 0xF42400
void timer_isr() __interrupt(11){
PD_ODR = 0xff;
TIM1_SR1 &= ~(1 << TIM_SR1_UIF); // Clear interrupt flag
}
void main(){
CLK_PCKENR1 = (1<<7);
TIM1_PSCRH = 0;
TIM1_PSCRL = 15;
TIM1_IER = TIM_IER_UIE;
TIM1_CR1 = TIM_CR1_CEN;
__asm__("rim");
PD_DDR = 0xff;
PD_CR1 = 0xff;
PD_ODR = 0x00;
while(1);
}
2019-12-21 12:10 AM
How is your LED connected? Anode on MCU pin or the cathode? Usually we tie the LEDs with the anode on Vdd and the cathode on the port pin (with a resistor somewhere inbetween), because of the higher sink port capabilities. If your LED is connected like this, than it would be switched off after the first interrupt, so you'll always see it turned off, and don't actually have the time to see it on at the begining after you configure the port as output.
Try to toggle the port pin in the interrupt.