-
1Software: Understanding the interface between the uPD7220 and the CPU
I am writing this expecting the reader to have a strong knowledge of computer hardware. You have been warned.
The uPD7220 occupies two addresses in IO space and has an 8-bit data bus. There are also the WE and RD enables, but there is no chip select (WE and RD should be generated with that in mind).
uPD7220 write ports:
0: Parameters
1 : Commands
uPD7220 read ports:
0: Status register
1 : Data to CPU
Internal FIFO, and properly writing to it
The two write ports both go to the same FIFO inside the uPD7220. This FIFO can fill up, but there are bits in the status register which indicate if the FIFO is empty or full. When writing to the uPD7220, the program must ALWAYS first check if that FIFO is full - if it is, then the program has to wait for there to be space.
Sending commands
The command byte is always sent first, into port 1. After this, parameters are sent to port 0. Some commands have quirks and nuances, and need some extra attention. For instance, my uPD7220 can crash if my program does not wait for the FIFO to empty after sending a WDAT command. I have not had this issue with any other command. More on commands later, just introducing the proper way to send them.
Reading data
There is a flag in the status register to indicate that data is ready to be read. When a command is sent to read data, this flag will be set shortly after, and then it is safe to read from port 1 (Data to CPU). Always check the data ready flag before reading from port 1
A quick word on the DMA flag
If you are not using DMA or have not sent a DMA command and this flag is set, then something probably went wrong. A command was likely sent incorrectly, or setup skipped a step. If that is the case, the uPD7220 will probably crash in the next few commands (if it hasn't already). Basically this means your program is doing something wrong, as in not sending a command needed for initialization or sending a command incorrectly.
Status Register Flags
BIT NAME DESCRIPTION 0 Data Ready The CPU can now read at least a byte from uPD7220 port 1 1 FIFO Full The command/parameter FIFO is full, do not write 2 FIFO Empty The command/parameter FIFO is empty 3 Drawing in progress The uPD7220 is currently executing a drawing operation 4 DMA Execute The uPD7220 thinks a DMA operation is in progress 5 Vertical Sync Indicates that vertical retrace is active 6 Horizontal Blank Indicates that horizontal blanking is active 7 Light Pen Detect Indicates that a valid Light Pen address can be read I'm not sure that anyone would use the light pen feature, and I myself am not really researching it.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.