1 /* procesor H8S/2638 board EDK2638 ver 1.1 */
5 #include <system_def.h>
9 #ifdef XRAM_SUPPORT_ENABLED
10 #define FULL_XRAM_ADRBUS
11 #endif /*XRAM_SUPPORT_ENABLED*/
12 #define SMALL_ADRBUS 8
14 static void deb_led_out(char val)
18 *DIO_P1DR |= ~val & 0xf;
22 *DIO_P3DR |= ~(val<<5) & 0xc0;
26 SHADOW_REG_SET(DIO_P1DDR,(P1DDR_P15DDRm|P1DDR_P14DDRm)); /* set P1.5 and P1.4 as output */
29 *DIO_P1DR |=P1DR_P14DRm;
31 *DIO_P1DR &=~P1DR_P14DRm;
34 *DIO_P1DR |=P1DR_P15DRm;
36 *DIO_P1DR &=~P1DR_P15DRm;
49 #if 1 /* registers setup */
50 /* Internal RAM enabled, advanced interrupt mode */
51 /* *SYS_SYSCR = 1*SYSCR_RAMEm | 1*SYSCR_INTM1m ; */
53 /* Remap 4kB of RAM from 0xffd000-0xffdfff to 0x0-0xfff */
54 /* *FLM_RAMER= 1*RAMER_RAMSm | 0&RAMER_RAMxm */
55 /* Sideefect - sets Flash software protection */
57 /* Enables access to flash control registers */
58 *IIC_SCRX |= SCRX_FLSHEm;
60 /* set shadow registers */
64 /* show something on debug leds */
69 //SHADOW_REG_SET(DIO_P3DDR,0xc4);
70 //SHADOW_REG_SET(DIO_P1DDR,0x03); /*A20 and A21 are outputs*/
71 *DIO_P3DR=0x09; /* Inactive value of TxD0 and TxD1 has to be log 1 */
72 SHADOW_REG_SET(DIO_P3DDR,0x09); /* TxD0 and TxD1 to outputs */
74 /* Setup system clock oscilator */
76 /* *SYS_LPWRCR=2&LPWRCR_STCxm; */
78 /* *SYS_LPWRCR=1&LPWRCR_STCxm; */
79 { const char clkrat2stc[]={0,0/*1*/,1/*2*/,1,2/*4*/,2,2,2,3/*8*/};
80 *SYS_LPWRCR=LPWRCR_STCxm&(LPWRCR_STC0m*
81 clkrat2stc[(CPU_SYS_HZ+CPU_REF_HZ/2)/CPU_REF_HZ]);
86 /* No clock disable, immediate change, busmaster high-speed */
87 *SYS_SCKCR=(0*SCKCR_PSTOPm)|(1*SCKCR_STCSm)|(0&SCKCR_SCKxm);
90 /* Setup chipselect outputs CS4 CS5 CS6 */
92 SHADOW_REG_SET(DIO_P7DDR,1|2|4);
94 // SHADOW_REG_SET(DIO_P7DDR,0); not on 2638
97 /* Setup chipselect outputs CS3 CS2 CS1 CS0 */
98 // *DIO_PGDR |=2|4|8|0x10; no on 2638
100 SHADOW_REG_SET(DIO_PGDDR,2|4|8|0x10);
102 // SHADOW_REG_SET(DIO_PGDDR,2|4); no on 2638
106 /* setup chipselect 0 - FLASH */
107 *BUS_ABWCR&=~ABWCR_ABW0m; /* 16 bit width */
108 *BUS_ASTCR&=~ASTCR_AST0m; /* 2 states access */
109 *BUS_WCRL&=~(WCRL_W01m|WCRL_W00m);/* 0 additional wait states */
111 /* setup chipselect 1 - XRAM */
112 *BUS_ABWCR&=~ABWCR_ABW1m; /* 16 bit width */
113 *BUS_ASTCR&=~ASTCR_AST1m; /* 2 states access */
114 *BUS_WCRL&=~(WCRL_W11m|WCRL_W10m);/* 0 additional wait states */
116 /* setup chipselect 2 - SGM_LCD */
117 *BUS_ABWCR|=ABWCR_ABW2m; /* 8 bit width */
118 *BUS_ASTCR|=ASTCR_AST2m; /* 3 states access */
119 *BUS_WCRL&=~(WCRL_W21m|WCRL_W20m);/* 0 additional wait states */
120 *BUS_WCRL|=0*WCRL_W21m; /* 0/1 additional wait state */
123 /* setup chipselect 3 - SRAM */
124 //*BUS_ABWCR|=ABWCR_ABW3m; /* 8 bit width */
125 *BUS_ABWCR&=~ABWCR_ABW0m; /* 16 bit width EDK 2638 */
126 //*BUS_ASTCR|=ASTCR_AST3m; /* 3 states access */
127 *BUS_ASTCR|=ASTCR_AST0m; /* 3 states access EDK 2638 */
128 //*BUS_WCRL&=~(WCRL_W31m|WCRL_W30m); /* 0 additional wait states */
129 *BUS_WCRL&=~(WCRL_W01m|WCRL_W00m); /* 0 additional wait states EDK 2638*/
132 FlWait(2*1000000); */
135 /* setup chipselect 4 - IDE */
136 *BUS_ABWCR&=~ABWCR_ABW4m; /* 16 bit width */
137 *BUS_ASTCR|=ASTCR_AST4m; /* 3 states access */
138 *BUS_WCRH&=~(WCRH_W41m|WCRH_W40m);/* 0 additional wait states */
140 /* setup chipselect 5 - IDE */
141 *BUS_ABWCR&=~ABWCR_ABW5m; /* 16 bit width */
142 *BUS_ASTCR|=ASTCR_AST5m; /* 3 states access */
143 *BUS_WCRH&=~(WCRH_W51m|WCRH_W50m);/* 0 additional wait states */
145 /* setup chipselect 6 - KL41 */
146 *BUS_ABWCR|=ABWCR_ABW6m; /* 8 bit width */
147 *BUS_ASTCR|=ASTCR_AST6m; /* 3 states access */
148 *BUS_WCRH=WCRH_W61m|WCRH_W60m; /* 3 additional wait states */
152 /* cross cs wait| rd/wr wait | no burst and DRAM */
153 *BUS_BCRH=0*BCRH_ICIS1m | 0*BCRH_ICIS0m;
154 /* release | no DMAC buffer | no external wait */
155 *BUS_BCRL=0*BCRL_WDBEm; // 0*BCRL_BRLEm | 0*BCRL_WDBEm | 0*BCRL_WAITEm; BRLE and WAITE not build in 2638
156 *DIO_PCDDR=0xff; /* A0-A7 are outputs */
158 *DIO_PBDDR=0xff; /* A8-A15 are outputs */
159 #endif /*SMALL_ADRBUS*/
160 #ifndef FULL_XRAM_ADRBUS
162 /* *SYS_PFCR=__val2mfld(PFCR_AExm,16-8); only 16 address lines */
163 *SYS_PFCR=__val2mfld(PFCR_AExm,18-8); /* only 18 address lines fer EDK238 Extend*/
164 #else /*SMALL_ADRBUS*/
165 *SYS_PFCR=__val2mfld(PFCR_AExm,SMALL_ADRBUS-8); /* only SMALL_ADRBUS address lines */
166 #endif /*SMALL_ADRBUS*/
167 #endif /* FULL_XRAM_ADRBUS */
169 #endif /* registers setup */
173 #ifdef FULL_XRAM_ADRBUS
174 /* Setup full 20 address lines */
176 *DIO_PADDR=0x0f; /* A16-A19 are outputs */
177 /* number of address output signals */
178 /* *SYS_PFCR=__val2mfld(PFCR_AExm,20-8); */
179 *SYS_PFCR=__val2mfld(PFCR_AExm,18-8); /* only 18 address lines fer EDK238 Extend*/
180 #endif /*FULL_XRAM_ADRBUS*/