Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
memory_map [2021/08/25 18:42] – [SPI] pulkomandy | memory_map [2021/09/05 16:12] – [Misc. peripherals] simer | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{: | ||
+ | |||
^ Start | ^ Start | ||
| 0x000000 | | 0x000000 | ||
Line 4: | Line 6: | ||
| 0x003000 | | 0x003000 | ||
| 0x003D00 | | 0x003D00 | ||
- | | 0x003e00 | + | | 0x003E00 |
External memory starts at 0x4000. It can be mapped to the internal ROM and the two possible chips in the cartridges. | External memory starts at 0x4000. It can be mapped to the internal ROM and the two possible chips in the cartridges. | ||
Line 11: | Line 13: | ||
====== IO registers ====== | ====== IO registers ====== | ||
+ | |||
+ | {{: | ||
^ Address | ^ Address | ||
Line 23: | Line 27: | ||
| 5/A/F | IOx mask | | | 5/A/F | IOx mask | | ||
- | IO special functions and usage: | + | Each IO port is configured by 4 registers. |
+ | |||
+ | The direction register is 0 for input pins, 1 for output pins. | ||
+ | |||
+ | ===== Input pins configuration ===== | ||
+ | |||
+ | If the attribute bit for a pin is 0, the data bit can be used to set a pull up or pull down resistor on the pin. | ||
+ | |||
+ | If the attribute bit is 1, the pin is floating without pull up or pull down. | ||
+ | |||
+ | It is possible to read both the internal buffer and the actual state of the pin. | ||
+ | |||
+ | ===== Output pins configuration ===== | ||
+ | |||
+ | If the attribute bit for a pin is 0, the output is inverted. Writing 1 to the data bit results in a logic 0 output. If the data bit is set to 0, the result is a logic 1 output. | ||
+ | |||
+ | If the attribute bit is 1, there is no inversion, and the data bit is output as is. | ||
+ | |||
+ | ===== IO special functions and usage ===== | ||
+ | |||
+ | FIXME this does not match the info from the V.Smile motion schematics (see [[IO]] page). Where does this info come from (except from bmx spreadsheet) and which is correct? | ||
* IOA15: act | * IOA15: act | ||
Line 48: | Line 72: | ||
* IOC0: TBPWM / external clock 2 input | * IOC0: TBPWM / external clock 2 input | ||
- | ===== Cartridge banks selection ===== | ||
- | |||
- | These IO pins allow to map either the internal ROM or the two different cartridge banks into memory. | ||
- | |||
- | * IOB2: CSB3 | ||
- | * IOB1: CSB2 | ||
- | * IOB0: CSB0 | ||
====== Timers ====== | ====== Timers ====== | ||
+ | |||
+ | {{: | ||
^ Address ^ Contents | ^ Address ^ Contents | ||
Line 71: | Line 90: | ||
| 3D1C | Scanline counter | | 3D1C | Scanline counter | ||
- | Timebase values: | + | Timebase |
+ | * Bits 3-2: TMB2 frequency | ||
+ | * 00 - 128 Hz | ||
+ | * 01 - 256 Hz | ||
+ | * 10 - 512 Hz | ||
+ | * 11 - 1024 Hz | ||
+ | * Bits 1-0: TMB1 frequency | ||
+ | * 00 - 8 Hz | ||
+ | * 01 - 16 Hz | ||
+ | * 10 - 32 Hz | ||
+ | * 11 - 64 Hz | ||
+ | |||
+ | ===== Timer A ===== | ||
+ | |||
+ | Timer A ticks on the rising edge of the AND of sources A and B (so one source can be used to mask the other). | ||
+ | |||
+ | The counter is incremented at each tick until it reaches FFFF and overflows. | ||
+ | |||
+ | Reading the data register allows to know the current timer value. | ||
+ | |||
+ | When the timer overflows, several things happen: | ||
+ | |||
+ | * An interrupt is triggered (if activated) | ||
+ | * The FTAOUT pin is toggled | ||
+ | * The counter is reloaded to the last value written to the data register | ||
+ | * The 4 bit counter for PWM generation is incremented | ||
+ | |||
+ | ==== Control register bits 2-0: Source A ==== | ||
+ | |||
+ | * 00x: Timer disabled | ||
+ | * 010: 32768Hz | ||
+ | * 011: 8192Hz | ||
+ | * 100: 4096Hz | ||
+ | * 101: 1 (use source B only) | ||
+ | * 110: Timer disabled | ||
+ | * 111: EXT1 | ||
+ | |||
+ | ==== Control register bits 5-3: Source B ==== | ||
+ | |||
+ | * 000: 2048Hz | ||
+ | * 001: 1024Hz | ||
+ | * 010: 256Hz | ||
+ | * 011: TMB1 | ||
+ | * 100: 4Hz | ||
+ | * 101: 2Hz | ||
+ | * 110: 1 (use source A only) | ||
+ | * 111: EXT2 | ||
+ | |||
+ | ==== Control register bits 9-6: output pulse control ==== | ||
- | - 00: TMB2 = 128Hz, TMB1 = 8Hz | + | {{:sunplus:sunplus_pwm.png? |
- | - 01: TMB2 = 256Hz, TMB1 = 16Hz | + | |
- | - 10: TMB2 = 512Hz, TMB1 = 32Hz | + | |
- | - 11: TMB2 = 1024Hz, TMB1 = 64Hz | + | |
+ | This configure the pulse width from 0 to 15 timer ticks. A new pulse starts every 16 ticks. | ||
====== Misc. peripherals ====== | ====== Misc. peripherals ====== | ||
Line 95: | Line 160: | ||
| 3D2D | Pseudo Random2 | | 3D2D | Pseudo Random2 | ||
| 3D2E | FIQ Sel | | 3D2E | FIQ Sel | ||
- | | 3D2F | DS register | + | | 3D2F | DS register |
===== System control ===== | ===== System control ===== | ||
Line 111: | Line 176: | ||
===== Interrupts ===== | ===== Interrupts ===== | ||
- | The three interrupt registers have the same layout | + | The three interrupt registers have the same layout: |
* Bit 13: ADC (interrupt vector is at FFFB) | * Bit 13: ADC (interrupt vector is at FFFB) | ||
Line 127: | Line 192: | ||
* Bit 0: TMB2 (FFFF) | * Bit 0: TMB2 (FFFF) | ||
+ | There are interrupts coming from devices, which have separate enable bits in each of the devices. | ||
+ | |||
+ | The complete list of interrupt vectors is: | ||
+ | |||
+ | ^ Vector address ^ Name ^Triggered by ^ | ||
+ | | FFF5 | BREAK |'' | ||
+ | | FFF6 | FIQ | ||
+ | | FFF7 | RESET |Console startup/ | ||
+ | | FFF8 | IRQ0 |PPU | | ||
+ | | FFF9 | IRQ1 |SPU | | ||
+ | | FFFA | IRQ2 |Timers A and B | | ||
+ | | FFFB | IRQ3 |UART, SPI, SIO, I2C | | ||
+ | | FFFC | IRQ4 |SPU beat and envelope | ||
+ | | FFFD | IRQ5 |External interrupts | ||
+ | | FFFE | IRQ6 |1024, 2048 or 4096Hz ticker | | ||
+ | | FFFF | IRQ7 |4Hz ticker, Timebase 1, Timebase 2, Low voltage detect, Key change | | ||
+ | |||
+ | As the vector addresses are only 16-bit, they can only point to the first segment (0x0000 - 0xFFFF). | ||
===== External bus configuration ===== | ===== External bus configuration ===== | ||
- | * Bits 11-8: Ram decode control | + | * Bits 11-8: External RAM decode control |
- | * Bits 7-6: Address | + | * 0xxx - No mapping |
- | * Bits 5-3: Bus arbitration control | + | * 1000 - Map '' |
+ | * 1001 - Map '' | ||
+ | * 1010 - Map '' | ||
+ | * 1011 - Map '' | ||
+ | * 1100 - Map '' | ||
+ | * 1101 - Map '' | ||
+ | * 1110 - Map '' | ||
+ | * 1111 - Map '' | ||
+ | * Bits 7-6: ROM address | ||
+ | * 00 - Map entire range to ROMCSB | ||
+ | * 01 - Map '' | ||
+ | * 1x - Map '' | ||
+ | * Bits 5-3: Bus arbitration | ||
+ | * 101 - 1. Audio, 2. PPU, 3. CPU | ||
+ | * 111 - 1. PPU, 2. Audio, 3. CPU | ||
* Bits 2-1: Number of wait states | * Bits 2-1: Number of wait states | ||
* Bit 0: CKOEN | * Bit 0: CKOEN | ||
+ | |||
+ | External RAM mapping overrides any ROM mapping. | ||
==== ADC ==== | ==== ADC ==== | ||
Line 183: | Line 282: | ||
This allows direct read and write access to the DS (Data Segment) register. Normally in the uN'SP architecture, | This allows direct read and write access to the DS (Data Segment) register. Normally in the uN'SP architecture, | ||
====== UART ====== | ====== UART ====== | ||
+ | |||
+ | {{: | ||
All UART registers are 8bit only. | All UART registers are 8bit only. | ||
Line 214: | Line 315: | ||
====== General DMA ====== | ====== General DMA ====== | ||
- | 3E00 DMA | + | ^ Address ^ Contents ^ |
- | 3E01 DMA | + | | 3E00 |
- | 3E02 DMA | + | | 3E01 |
- | 3E03 DMA Target Address target address | + | | 3E02 | DMA word count | |
+ | | 3E03 | ||
+ | |||
+ | This is a DMA for generic purposes. Note that there is another DMA channel in the [[PPU]] registers. | ||
+ | |||
+ | Both DMA units operate in the same way. First, set the source and destination addresses. The source can be anywhere in memory, but the destination register is only 14 bits wide, which allows to target only the internal RAM and IO registers (you wouldn' | ||
+ | The transfer is started when you write the word count register, and you can read that register to know when the transfer is done (the register is 0 when there are no more words to transfer). |