'( * * * * * * * * Xantusnix5.bas * * * * * * * Nard Awater , January 7 , 2007 Very simple program to let the Tiny do what the PIC didn't : a running clock Version 5 : Using Pulseout For Shift -action ') $crystal = 8000000 'fuses set to internal RC-oscill, 8 Mc $regfile = Attiny2313.dat Const Ocie0a = 0 'shame on you, Bascom ! Dim Seconds_f As Byte At $0060 Dim I As Byte Dim Hours As Byte Dim Bcd_hours As Byte Dim Minutes As Byte Dim Bcd_minutes As Byte Dim Seconds As Byte Dim Bcd_seconds As Byte Dim Sw_mask As Byte Dim Temp_byte As Byte Dim Pwr_on_f As Bit Ddra.0 = 1 Ddra.1 = 1 Ddrb = &HFF Ddrd.0 = 1 Ddrd.1 = 1 Ddrd.6 = 1 Scope Alias Portb.4 Shift_clk Alias Portb.3 D_h Alias Portb.0 D_m Alias Portb.1 D_s Alias Portb.2 Nixier Alias Portd.0 Nixiel Alias Portd.1 Button_set Alias Pind.2 Button_h Alias Pind.3 Button_m Alias Pind.5 Buzz Alias Portd.6 In3_aft Alias Porta.1 In3_front Alias Porta.0 'Timer0: T0 is input, CTC, ocr0a=max Ocr0a = 4 Tccr0a = &B00000010 Tccr0b = &B00000111 'clock on rising edge of T0 (5 Hz signal) On Oc0a Do_seconds Nosave Set Timsk.ocie0a 'Enable Ocie0a Enable Interrupts ' ##########################################################################3 Do 'do here all the things that need to be done .... plenty of time While Seconds_f = 0 'flash all digits after poweron .... If Pwr_on_f = 0 Then If Tcnt0 < 3 Then Nixier = 1 Nixiel = 1 Else Nixier = 0 Nixiel = 0 End If Else Nixier = 1 Nixiel = 1 End If '..... until any of the buttons is pressed Sw_mask = &B00101100 Temp_byte = Pind And Sw_mask If Temp_byte <> Sw_mask Then Pwr_on_f = 1 End If If Button_h = 0 Then 'set hours Incr Hours Sound Buzz , 40 , 2500 End If If Button_m = 0 Then 'set minutes Incr Minutes Sound Buzz , 50 , 2000 End If If Button_h = 0 And Button_m = 0 Then 'reset seconds when Button_h AND Button_m are pressed Seconds = 0 End If Wend 'Seconds_f is now 1 so make it 0 again Seconds_f = 0 Incr Seconds If Seconds > 59 Then Seconds = 0 Incr Minutes End If If Minutes > 59 Then Minutes = 0 Incr Hours End If If Hours > 23 Then Hours = 0 End If 'Make BCD Bcd_seconds = Makebcd(seconds) Bcd_minutes = Makebcd(minutes) Bcd_hours = Makebcd(hours) 'Shift it out For I = 7 To 0 Step -1 D_s = Bcd_seconds.i D_m = Bcd_minutes.i D_h = Bcd_hours.i Pulseout Portb , 3 , 10 Next I Loop End ' ############## INTERRUPTS ################################################ Do_seconds: 'save only the register that will be used push xl ser xl sts $0060,xl 'set seconds-flag @ $0060 pop xl Return