I'm trying to read a MaskROM that has been removed from a cart using a Teensy++ 2.0 microcontroller board. The Teensy++ 2.0 has a ton of I/O pins, enough for a 1:1 connection to the MaskROM. However, I'm having issues doing the reading. I couldn't find a timing diagram for the MaskROM I/O, so I used the diagrams from the AM29F032B datasheet, since I know they work in repros. Here's the diagram for a read operation:
And here's my code
Basically, my main is just calling Init(), then calling ReadByte in a loop with incrementing addresses starting at 0, then printing the result to the serial line. All of the *_PORT and *_BIT names are #define'd in my header, and I've double-checked that the #define's match my connections. I've even added busy waits between each command, but it doesn't help. All I get back are 0x00 over and over. I have a feeling I'm just doing something really stupid, but I don't know what it might be... any ideas?
And here's my code
Code:
void Init()
{
// Address lines as outputs
A7_0_DDR = 0xFF;
A15_8_DDR = 0xFF;
A22_16_DDR = 0x7F;
// Data line defaults to input (read mode)
DATA_DDR = 0x00;
// Control lines as outputs, pulled high
CONTROL_PORT |= (CS_BIT | OE_BIT | WE_BIT | RST_BIT);
CONTROL_DDR |= (CS_BIT | OE_BIT | WE_BIT | RST_BIT);
}
uint8_t ReadByte(uint32_t address){
CONTROL_PORT |= WE_BIT;
A7_0_PORT = address & 0xFF;
A15_8_PORT = (address >> 8) & 0xFF;
A22_16_PORT = (address >> 16) & 0x7F;
CONTROL_PORT &= ~CS_BIT;
CONTROL_PORT &= ~OE_BIT;
uint8_t data = DATA_PORT;
CONTROL_PORT |= OE_BIT;
CONTROL_PORT |= CS_BIT;
CONTROL_PORT &= ~WE_BIT;
return data;
}
{
// Address lines as outputs
A7_0_DDR = 0xFF;
A15_8_DDR = 0xFF;
A22_16_DDR = 0x7F;
// Data line defaults to input (read mode)
DATA_DDR = 0x00;
// Control lines as outputs, pulled high
CONTROL_PORT |= (CS_BIT | OE_BIT | WE_BIT | RST_BIT);
CONTROL_DDR |= (CS_BIT | OE_BIT | WE_BIT | RST_BIT);
}
uint8_t ReadByte(uint32_t address){
CONTROL_PORT |= WE_BIT;
A7_0_PORT = address & 0xFF;
A15_8_PORT = (address >> 8) & 0xFF;
A22_16_PORT = (address >> 16) & 0x7F;
CONTROL_PORT &= ~CS_BIT;
CONTROL_PORT &= ~OE_BIT;
uint8_t data = DATA_PORT;
CONTROL_PORT |= OE_BIT;
CONTROL_PORT |= CS_BIT;
CONTROL_PORT &= ~WE_BIT;
return data;
}
Basically, my main is just calling Init(), then calling ReadByte in a loop with incrementing addresses starting at 0, then printing the result to the serial line. All of the *_PORT and *_BIT names are #define'd in my header, and I've double-checked that the #define's match my connections. I've even added busy waits between each command, but it doesn't help. All I get back are 0x00 over and over. I have a feeling I'm just doing something really stupid, but I don't know what it might be... any ideas?