;----------------------------------------------------------- ; titre : rti 500ms, buzzer, led r si alim faible ; version : 1.1 ; cible : at90s8515-8pi ; quartz : 8mhz ; auteur : yann leidwanger ; email : tech@jls-info.com ;----------------------------------------------------------- ;----------------------------------------------------------- ; equivalences ;----------------------------------------------------------- .include "8515def.inc" .def temp = r16 ;mcu .def cpt1 = r17 ;pour tempo .def cpt2 = r18 ;pour buzzer .equ sa = pc7 ;surveillance d'alim .equ ledv = pc6 ;led verte .equ ledr = pc5 ;led rouge .equ bz = pc4 ;buzzer ;----------------------------------------------------------- ; code segment ;----------------------------------------------------------- .cseg .org $0000 rjmp reset ;reset rjmp no_isr ;ext int 0 rjmp no_isr ;ext int 1 rjmp no_isr ;timer1 capture rjmp no_isr ;timer1 compare a rjmp no_isr ;timer1 compare b rjmp t1_isr ;timer1 ovf rjmp no_isr ;timer0 overflow rjmp no_isr ;spi transfert complete rjmp no_isr ;rx uart rjmp no_isr ;udre uart rjmp no_isr ;tx uart rjmp no_isr ;comparator no_isr: reti ;----------------------------------------------------------- ; interrupt service routines ;----------------------------------------------------------- t1_isr: ldi temp,$f0 out tcnt1h,temp ldi temp,$bd out tcnt1l,temp ;rti_time = 500ms test_alim: sbic pinc,sa rjmp defaut_alim ;saute si alim ok cbi portc,ledr ;led r off cont1: ldi cpt2,$ff sound: cbi portc,bz rcall tempo sbi portc,bz rcall tempo dec cpt2 brne sound reti tempo: ldi cpt1,$ff ;init compteur tempo tempo1: nop nop dec cpt1 brne tempo1 ;teste si fin ret defaut_alim: sbi portc,ledr ;led r on rjmp cont1 ;----------------------------------------------------------- ; routines ;----------------------------------------------------------- init_syst: ldi temp,$70 out ddrc,temp ;pc4, pc5 et pc6 en sortie ldi temp,$10 out portc,temp ;buzzer, led v et led r off ldi temp,$f0 ;real time interrupt out tcnt1h,temp ;65535 - (rti_time * ck / 1024) ldi temp,$bd ;rti_time = 500ms out tcnt1l,temp ldi temp,$05 out tccr1b,temp ;init timer1 : ck / 1024 ldi temp,$80 out timsk,temp ;enable timer1 int sei ;enable general int ret ;----------------------------------------------------------- ; programme principal ;----------------------------------------------------------- reset: ldi temp,high(ramend) out sph,temp ldi temp,low(ramend) out spl,temp ;init sp rcall init_syst main: rjmp main ;----------------------------------------------------------- ; that's all folks !!! ;-----------------------------------------------------------