UPDATE: Updated the code and the xxd output.
I asked this question before, but I don't believe I explained it well enough to get an answer. I am attempting to generate a file to load on to an EPROM like in the photo.
I need to create a binary file which will output 16-bit data on the data pins. Such that, for example, when I go to address 0xFF (e.g. 5 volts on the first 8 address pins) it would output 0xAD12 (on the data pins) for example. In binary this would mean: 1111000100010010 and the EPROM would output a 1 (5 volts) on pin 2, 5, 9, 13, 14, 15, 16.
However, when I load it on the EPROM it seems to have only put the lower 8-bit values into the file and all the MSB are high (which they are when the EPROM is blank) so it doesn't seem to be writing those bits. I don't seem to be able to see the 8 MSB using hexdump or xxd?
I've written a quick example. I tried to make it as near to my actual program as possible. I realise the datasize is huge, but it is the size of file I need to fill the EPROM.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define scRom1024 16384
uint16_t firstEpromFile[scRom1024] = { 0xFFFF, 0xFFDD, 0xFDDD, 0xF000, 0x0F0F, 0x0001, 0x1010 };
int main ()
{
const char *path = "text.bin";
FILE *fp = fopen(path, "wb");
const void *data = firstEpromFile;
if (!fp)
{
fprintf(stderr, "fopen() failed for '%s'\n", path);
}
else
{
fwrite(firstEpromFile, sizeof firstEpromFile[0], sizeof firstEpromFile / sizeof firstEpromFile[0], fp);
fclose(fp);
}
return 0;
}
xxd shows only the 8 LSB.
00000000: 11111111 11111111 11011101 11111111 11011101 11111101 ......
00000006: 00000000 11110000 00001111 00001111 00000001 00000000 ......
== hex version ===
00000000: ffff ddff ddfd 00f0 0f0f 0100 1010 0000 ................
So my question is:
Is the program correctly writing out the 16 bit values and I can't see them with xxd (seems unlikely since the physical hardware is outputting 5volts on pins 9-16) or do I need to modify the code so that it will output 16-bit values?