external_memory.c
1 | #include "lpc22xx.h"
| 2 |
| 3 | void external_memory_Config(void)
| 4 |
| 5 | {
| 6 | // set extended memory D0-D16 CS,CS1,CS2,CS3 A0-A19
| 7 | PINSEL2 &= ~(0x00000020);
| 8 | PINSEL2 |= 0x00000010;
| 9 |
| 10 | // enable /WE,/CS1
| 11 | PINSEL2 |= 0x00000900;
| 12 |
| 13 | // enable /CS2,/CS3
| 14 | PINSEL2 |= 0x00014000;
| 15 |
| 16 | // enable A0,A1, A2-A19
| 17 | PINSEL2 |= 0x0d800000;
| 18 |
| 19 | // set up the external sram on CS1
| 20 |
| 21 |
| 22 | // 1 idle cycle
| 23 | BCFG1 &= ~(0x0000000f);
| 24 |
| 25 | // 3 wait states, 16 bit wide bus
| 26 | BCFG1 &= ~(0x000003e0);
| 27 | BCFG1 |= 0x00000460;
| 28 |
| 29 | // 3 wait states
| 30 | BCFG1 &= ~(0x0000f800);
| 31 | BCFG1 |= 0x00001800;
| 32 |
| 33 | // 16 bit bus
| 34 | BCFG1 &= ~(0x30000000);
| 35 | BCFG1 |= 0x10000000;
| 36 |
| 37 |
| 38 | // set up the external non volatile sram on CS2
| 39 |
| 40 | // 1 idle cycle
| 41 | BCFG2 &= ~(0x0000000f);
| 42 |
| 43 | // 3 wait states, 16 bit wide bus
| 44 | BCFG2 &= ~(0x000003e0);
| 45 | BCFG2 |= 0x00000460; // 3 wait states
| 46 | BCFG2 &= ~(0x0000f800);
| 47 | BCFG2 |= 0x00001800;
| 48 |
| 49 | // 16 bit bus
| 50 | BCFG2 &= ~(0x30000000);
| 51 | BCFG2 |= 0x10000000;
| 52 |
| 53 |
| 54 | // set up the lcd on CS3
| 55 |
| 56 | // maximum idle cycles
| 57 | BCFG3 |= 0x0000000f;
| 58 | // maximum wait cycles
| 59 | BCFG3 |= 0x000003e0;
| 60 | // maximum wait cycles
| 61 | BCFG3 |= 0x0000f800;
| 62 | // 8 bit bus
| 63 | BCFG3 &= ~(0x30000000);
| 64 |
| 65 |
| 66 | }
|
|