cancel
Showing results for 
Search instead for 
Did you mean: 

Stm8s003k3 temperature measurement

KRiaz.1
Associate II

Hi  Everyone,

I am using Stm8s003k3 to measure the temperature of three different places. Then displaying each temperature on 3 digits 7-segment display (3 of them to show each temperature separately). Now to display the temperature on all 3 seven segments I need to put them in the main loop and then the code should be executed without delay otherwise it will Dim the displays. My problem is I need to perform calculations and some other tasks if do those there is a delay and so my display got Dim any solution recommended how do I display temperature on all three displays while performing other tasks as well?

 

1 ACCEPTED SOLUTION

Accepted Solutions

I suppose that you have multiplexed display ( https://en.wikipedia.org/wiki/Multiplexed_display ). Setup timer to generate periodic interrupt (for example 1ms). Handle multiplexing in interrupt service routie. Then you can do anything in main loop without disturbing the display managment.

View solution in original post

4 REPLIES 4

I suppose that you have multiplexed display ( https://en.wikipedia.org/wiki/Multiplexed_display ). Setup timer to generate periodic interrupt (for example 1ms). Handle multiplexing in interrupt service routie. Then you can do anything in main loop without disturbing the display managment.

Hi Michal 
First of all, thank you for the reply. I can do the basic coding right. is there any example or any exemplary code so that i can just lear how to create interrupts? 

 

Hi Michal, I am using cosmic c with stvp. I have read all the vlogs that Mr.Junaid posted and I was able to compile all of them but when I try to compile interrupt code It does not recognize the

void timer_isr() __interrupt(TIM2_OVF_ISR)
{
PB_ODR ^= 1 << PB5;
TIM2_SR1 &= ~(1 << TIM2_SR1_UIF);
}

this method I have defined the addresses of registers and added 

#include "stm8s.h"
#include "stm8s_gpio.h"
#include "stm8s_tim2.h"
#include "stm8s_exti.h"

this library but still the same. Can you please guide me what i am missing here 

 

 

 

 

#include <stdint.h>
#include <stm8s.h>


void timer_isr() __interrupt(TIM2_OVF_ISR)
{
PB_ODR ^= 1 << PB5;
TIM2_SR1 &= ~(1 << TIM2_SR1_UIF);
}

void main() {
enable_interrupts();

PB_DDR |= 1 << PB5; /
PB_CR1 |= 1 << PB5;
TIM2_PSCR = 0b00000111;
TIM2_ARRH = reload_value >> 8;
TIM2_ARRL = reload_value & 0x00FF;

TIM2_IER |= (1 << TIM2_IER_UIE);
TIM2_CR1 |= (1 << TIM2_CR1_CEN);

while (1) {
// do nothing
}
}