1 ; Various functions: init, (RAM) disk, mmc, timer
2 ; This file needs to get split up.
4 ; Copyright (C) 2010 Sprite_tm
5 ; Copyright (C) 2010 Leo C.
7 ; This file is part of avrcpm.
9 ; avrcpm is free software: you can redistribute it and/or modify it
10 ; under the terms of the GNU General Public License as published by
11 ; the Free Software Foundation, either version 3 of the License, or
12 ; (at your option) any later version.
14 ; avrcpm is distributed in the hope that it will be useful,
15 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ; GNU General Public License for more details.
19 ; You should have received a copy of the GNU General Public License
20 ; along with avrcpm. If not, see <http://www.gnu.org/licenses/>.
26 ; ------------------- DRAM Refresh Interrupt --------------------
29 ; refresh interupt; exec 2 cbr cycles
32 rjmp refrint ; tim2cmpa
38 cbi P_CAS,ram_cas ;2 1| 1|
40 cbi P_RAS,ram_ras ;2 |0 1|
44 sbi P_RAS,ram_ras ;2 |0 |0
46 dram_wait DRAM_WAITSTATES-1 ; | |
48 cbi P_RAS,ram_ras ;2 |0 1|
50 sbi P_CAS,ram_cas ;2 |0 |0
52 sbi P_RAS,ram_ras ;2 1| |0
59 ;Print a unsigned lonng value to the uart
60 ; temp4:temp3:temp2:temp = value
71 clr yl ;yl = stack level
73 ultoa1: ldi z_flags, 32 ;yh = temp4:temp % 10
74 clr yh ;temp4:temp /= 10
86 cpi yh, 10 ;yh is a numeral digit '0'-'9'
90 cp temp,_0 ;Repeat until temp4:temp gets zero
97 ultoa5: cpi yl,3 ; at least 3 digits (ms)
103 ultoa6: pop temp ;Flush stacked digits
118 ;Prints temp2:temp in hex to the uart
126 ;Prints temp in hex to the uart
133 ;Prints the lower nibble
146 ;Prints the zero-terminated string following the call statement.
196 ; ****************************************************************************
198 ; ------------- system timer 1ms ---------------
211 ; don't change order here, clock put/get depends on it.
212 cntms_out: ; register for ms
214 utime_io: ; register for uptime.
221 .equ timer_size = timer_top - timer_base
223 .equ clkofs = cnt_1ms-cntms_out
224 .equ timerofs = cnt_1ms-timer_ms
229 .org OC1Baddr ; Timer/Counter1 Compare Match B
230 rjmp sysclockint ; 1ms system timer
243 #if DRAM_8BIT /* Implies software uart */
269 ldi zl,high(1000) ;doesn't change flags
302 sts delay_timer1,temp
304 lds temp,delay_timer1
313 subi temp2,TIMER_MSECS
314 brcs clkget_end ;Port number in range?
316 breq clkget_copy ;lowest byte requestet, latch clock
318 brsh clkget_end ;Port number to high?
344 brcs clkput_end ;Port number in range?
349 cpi temp,starttimercmd
351 cpi temp,quitTimerCmd
353 cpi temp,printTimerCmd
368 breq clkput_copy ;lowest byte requestet, latch clock
370 brsh clkput_end ;Port number to high?
415 ; put ms on stack (16 bit)
450 printstring "Timer running. Elapsed: "
482 printstring "Uptime: "
498 ; --------------- Debugging stuff ---------------
499 ; Print a line with the Z80 main registers
511 ldiw z,zflags_to_ch*2
517 cpi temp,' ' ; Test if no flag
520 ldi temp,' ' ; Flag not set