Changes

Jump to: navigation, search

How to access the PSG via PPI

117 bytes removed, 23:48, 10 February 2021
/* Reading to the selected PSG register */ section title was missing (format)
PSG Stands for '''Programmable Sound Generator''' The [[Amstrad CPC]], CPC+ and [[KC Compact]] use a AY-3-8912 Programmable sound generator (referred to as [[PSG ]] in this document), operating at 1Mhz. This document will describe it's role in these systems. To understand the full functions please read the [[Datasheet AY-8913|datasheet]].
== Role of the AY-3-8912 ==
The PSG function, defined by the BC1,BC2 and BDIR signals, is controlled by bit 7 and bit 6 of PPI Port C.
 
=== PSG signals ===
 
{|{{Prettytable|width: 700px; font-size: 2em;}}
|''PPI Port C Bit''||''PSG Signal''
|-
|7||BDIR
|-
|6||BC1
|-
|}
=== PSG function selection ===
{|{{Prettytable|width: 700px; font-size: 2em;}}
|colspan=2|''PPI Port C BitBits''||rowspan=2|''PSG Function''
|-
|7Bit7 BDIR||6Bit6 BC1
|-
|0||0||Inactive
The data will then be written into the register.
=== Reading from the selected PSG register===
To read data from the PSG, PPI Port A must be operating as input. (See the document on the 8255 to see how to do this)
set bit 7 to "0" and bit 6 to "1" of PPI Port C
read data from PPI Port A,
The register data is available at PPI Port A.
=== Notes ===
If the tone period is in the range 0-4 I can not hear any tone output.
 == Programming Examples== === Reading a value from a PSG register. === 
This routine can be used to read data from a PSG register.
.read_from_psg
ld b,&f4 ;} Setup register index on PPI port Aout (c),c ;}
ld bc,&f6c0 ;} Tell PSG to select register using data on PPI port Aout (c),c ;}
ld bc,&f600 ;} Put PSG into inactive stateout (c),c ;
;** Set PPI port A to input mode. **
ld b,&f7 ; 8255 PPI Control
ld c,%10010010 ; mode and port configurationout (c),c ; Port A input, Port B input, Port C output ; All operating in mode 0. (see Programming ; 8255 PPI)
ld bc,&f640 ;} Tell PSG to put the data of the selected register to PPI port A toout (c),c ;}
ld b,&f4 ;} Read data from PPI port Ain a,(c) ;}
;** Set PPI port A to output mode. *ld b,&f7 ;8255 PPI control
ld c,%10000010
out (c),c ;Port A output, Port B input, Port C output
ld bc,&f600 ;} Return PSG to inactive mode.out (c),c ;}
ret
</pre>
.write_to_psg
ld b,&f4 ;} setup PSG register number on PPI port Aout (c),c ;}
ld bc,&f6c0 ;} Tell PSG to select register from data on PPI port Aout (c),c ;}
ld bc,&f600 ;} Put PSG into inactive state.out (c),c ;}
ld b,&f4 ;} setup register data on PPI port Aout (c),a ;}
ld bc,&f680 ;} Tell PSG to write data on PPI port A into selected registerout (c),c ;}
ld bc,&f600 ;} Put PSG into inactive stateout (c),c ;}
ret
</pre>
 
== Resources ==
* [[Media:Ay3-891x.pdf|AY-3-891x datasheet]]
== Links ==
[[Category:Stub]]
[[Category:HardwareProgramming]][[Category:Music and sound| ]][[Category:Video contents]][[Category:CPC Internal Components]]
1
edit