start sei
movb #intram>>8 INITRM
lds #stack
movw #start 0,SP
ldy #regtbl
1$ ldx 2,Y+ ;init cpu registers
bmi 2$
movb 1,Y+ 0,X
bra 1$
***************************************
; cpu register inits after reset
***************************************
regtbl dc.w MODE
dc $80 ;normal single chip mode
dc.w IRQCR
dc 0 ;IRQ disabled
dc.w REFDV
dc 7 ;pll ref div = 8
dc.w SYNR
dc 11 ;pll mult = 12
dc.w PLLCTL
dc $E1 ;pll & cme on
dc.w CLKSEL
dc 5 ;pll not sel, CWAI on, COPWAI on
dc.w COPCTL
dc $46 ;RSBCK on, COP = osc / 2^23 (16MHz/8388608 = 524 mS)
dc.w RTICTL
dc $71 ;rtc = osc / 2^17 (16MHz/131072 = 8.192 mS)
dc.w HPRIO
dc $EE ;timer 0 highest priority
dc.w DDRA
dc $FF ;port A all outputs (lcd data)
dc.w PORTB
dc LCD_RST+W2_SDA+W2_SCL ;lcd reset off, rtc/EE bus idle
dc.w DDRB
dc $FF ;port B all outputs (lcd, com, rtc/EE, alm control)
dc.w PUCR
dc $12 ;pullups on PORTB, PORTE inputs (need PORTB for W2_SDA)
dc.w PPAGE
dc $3E
;;;;;;; lines skipped here
dc.w $FFFF ;end of list