SN76489: Success and Failure
Trying to get the SN76489 working has been an interesting exercise and a good example of why it is important to read datasheet with great care.
Initially I thought this would be a simple task to get working as I already have a VGM music player that works the YM2151 so it would be easy to update to add the SN76489 as well. That part all worked well but when trying to play some music there was nothing but silence.
Checking the hardware, it appeared to be accessing the chip correctly so assumed it was my code somehow. After no luck trying various code to get any sounds out of the chip I looked online to see if there was any example code that may help. There are several Arduino projects that use the SN76489, so I looked at how it was implemented in the code. One thing I noticed from there was that the write times to the SN76489 were long, greater than 10us.
Going back to the datasheet to see what the timing should be I found something that I must have missed the first time around!
The SN76489AN requires approximately 32 clock cycles to load the data into the control register
With a clock speed of 3.579Mhz one clock period is 279.4ns so 32 clocks are 8.94us. While it is fairly easy to change the CPLD code to wait long enough before generating the DTACK signal for the SN76489 there is a Bus error generator on the board that will trigger a bus error long before the DTACK is asserted. As a temporary measure I removed the IC and just tied the BERR line high.
Trying my VGM player again with the longer access times and success, music is playing. Unfortunately, the volume level is much lower than that of the YM2151 so I am not sure how useful it would be.
Even though i did get the SN76489 sound working I would call this a failure. The volume level would need boosting to be useful and the 9us access time would be an issue. It could be possible to modify the bus error logic or even implement it in the CPLD, but it is not going to work as it currently stands.
For now, I am going to leave the SN76489 unused as it was only added as i was doing a new board anyway so it’s not going to make much difference if it’s unused. I may revisit it later but for now I will restore the bus error generator and move on.