2020-01-26 08:34 AM
HI All,
I am facing issue with STM8S103F2 controller Timer1. I am configuring timer1 for 5 sec, but it is giving me interrupt in 10 mili second only. It is not taking my prescaler value. can anyone help me on this, i am putting my code:
stm8/
#include "mapping.inc"
#include "stm8s103f.inc"
segment 'rom'
.main:
rim
;ld a,#$
;ld TIM1_SMCR,A
ld a,#$1
ld TIM1_EGR,a
ld a,#$9
ld TIM1_PSCRL,a
LD a,#$1
ld TIM1_RCR,A
ld a,#$4c
ld TIM1_ARRH,a
ld a,#$4a
ld TIM1_ARRL,a
ld a,#$1
ld TIM1_IER,a
ld a,#$1
ld TIM1_CR1,a
infinite_loop.l
jra infinite_loop
interrupt NonHandledInterrupt
NonHandledInterrupt.l
iret
.NonHandledInterrupt1
bres TIM1_SR1,#0
iret
segment 'vectit'
dc.l {$82000000+main} ; reset
dc.l {$82000000+NonHandledInterrupt} ; trap
dc.l {$82000000+NonHandledInterrupt} ; irq0
dc.l {$82000000+NonHandledInterrupt} ; irq1
dc.l {$82000000+NonHandledInterrupt} ; irq2
dc.l {$82000000+NonHandledInterrupt} ; irq3
dc.l {$82000000+NonHandledInterrupt} ; irq4
dc.l {$82000000+NonHandledInterrupt} ; irq5
dc.l {$82000000+NonHandledInterrupt} ; irq6
dc.l {$82000000+NonHandledInterrupt} ; irq7
dc.l {$82000000+NonHandledInterrupt} ; irq8
dc.l {$82000000+NonHandledInterrupt} ; irq9
dc.l {$82000000+NonHandledInterrupt} ; irq10
dc.l {$82000000+NonHandledInterrupt1} ; irq11
dc.l {$82000000+NonHandledInterrupt} ; irq12
dc.l {$82000000+NonHandledInterrupt} ; irq13
dc.l {$82000000+NonHandledInterrupt} ; irq14
dc.l {$82000000+NonHandledInterrupt} ; irq15
dc.l {$82000000+NonHandledInterrupt} ; irq16
dc.l {$82000000+NonHandledInterrupt} ; irq17
dc.l {$82000000+NonHandledInterrupt} ; irq18
dc.l {$82000000+NonHandledInterrupt} ; irq19
dc.l {$82000000+NonHandledInterrupt} ; irq20
dc.l {$82000000+NonHandledInterrupt} ; irq21
dc.l {$82000000+NonHandledInterrupt} ; irq22
dc.l {$82000000+NonHandledInterrupt} ; irq23
dc.l {$82000000+NonHandledInterrupt} ; irq24
dc.l {$82000000+NonHandledInterrupt} ; irq25
dc.l {$82000000+NonHandledInterrupt} ; irq26
dc.l {$82000000+NonHandledInterrupt} ; irq27
dc.l {$82000000+NonHandledInterrupt} ; irq28
dc.l {$82000000+NonHandledInterrupt} ; irq29
end
2020-01-26 08:45 AM
Descriptions of prescaler registers in reference manual answer this very clearly!
2020-01-26 09:28 AM
Thanks for reply but Descriptions of prescaler registers in reference manual not answering clearly. I tried my possible combinations. Please, if you know which register i have to configure for enabling the prescaler, please tell me clearly.
2020-01-26 10:40 AM
No, it does. RM0016 sections 17.7.17 and 17.7.18 have 4 sentences each, but you are reading only the first 2 of those and ignoring the rest...
2020-01-30 07:26 AM
I got, I have previously given value in my prescaler as "9", but prescaler value in Timer1 not in the power of 2. If that time only, if you have given me clear answer then it will save my time.