Hi lemonhorse,
I spent all day trying to figure out the problem but with no luck.
I found a couple of errors in the code that supposedly were the problem, but it didn’t solve the issue.
Both are in the function ‘LABEL_AY_SR_Write’:
1- The bus control signals, BDIR and BC1, must change within 50 ns maximum.
Setting both pins using the instruction ‘bsf’ (line 175 & 176) results in 100 ns which is the double of the maximum allowed.
Solution:
;bsf AY_SR_LAT_BDIR, AY_SR_PIN_BDIR ;; SET BDIR (AY Chip)
;bsf AY_SR_LAT_BC1, AY_SR_PIN_BC1 ;; SET BC1 (AY Chip)
movlw 0x30
iorwf LATC, F
The same applies when resetting both control signals at the same time:
;bcf AY_SR_LAT_BDIR, AY_SR_PIN_BDIR ;; CLEAR BDIR (AY Chip Control)
;bcf AY_SR_LAT_BC1, AY_SR_PIN_BC1 ;; CLEAR BC1 (AY Chip Control)
movlw 0xCF
andwf LATC, F
Note: This solution doesn’t use the pin definitions!
2- The minimum time in ‘Inactive State’ between writing the address and the data is not specified in the data sheet. The Timex computer uses a delay of 5.5 us and this program only a 100 ns delay (1 instruction cycle). This may lead to problems.
One solution is to add some nop’s or simply set the control signals after updating the 74HC595 latch (don’t forget to keep the control signals stable for at least 500 ns).
This last solution is not strictly necessary because the ‘Write Data Pulse Width’ is around 5us and it is inside the limits of 500 ns up to 10 us.
According to the data sheets, the Microchip version chip have different timings. I believe this is the reason why your code works with some chips and not with others.
As a last resort I ran the following basic program in the Timex:
10 Sound 6,8;7,246;8,15
15 Pause 1
20 Sound 6,8;7,254;8,15
25 Pause 1
30 Go To 10
I can hear the noise being generated. So, the chip is OK.
I have measured all the signals (control and data BUS) with an oscilloscope and did a small program to replicate this commands. I put the new routine at the end of the function ‘USER_Init’. It was an infinite loop. I checked again with the scope and the signals were the same in terms of values and timings. But no noise generated…. :sad: