Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 1 1 ;*************************************************************************** 2 ;Pass_combo3.asm brings data in through CODEC, samples it at 1-16 bits, and 3 ; sends back out the CODEC 4 ;*************************************************************************** 1068 1069 ;****************************************************************************** 1070 1071 ;---Buffer for talking to the CS4215 1072 1073 X:000000 org x:0 1074 RX_BUFF_BASE 1075 000000 equ * 1076 RX_data_1_2 1077 X:000000 ds 1 ;data time slot 1/2 for RX ISR 1078 RX_data_3_4 1079 X:000001 ds 1 ;data time slot 3/4 for RX ISR 1080 RX_data_5_6 1081 X:000002 ds 1 ;data time slot 5/6 for RX ISR 1082 RX_data_7_8 1083 X:000003 ds 1 ;data time slot 7/8 for RX ISR 1084 1085 TX_BUFF_BASE 1086 000004 equ * 1087 TX_data_1_2 1088 X:000004 ds 1 ;data time slot 1/2 for TX ISR 1089 TX_data_3_4 1090 X:000005 ds 1 ;data time slot 3/4 for TX ISR 1091 TX_data_5_6 1092 X:000006 ds 1 ;data time slot 5/6 for TX ISR 1093 TX_data_7_8 1094 X:000007 ds 1 ;data time slot 7/8 for TX ISR 1095 1096 X:000008 RX_PTR ds 1 ; Pointer for rx buffer 1097 X:000009 TX_PTR ds 1 ; Pointer for tx buffer 1098 1099 ;TONE_OUTPUT EQU HEADPHONE_EN+LINEOUT_EN+(4*LEFT_ATTN)+(4*RIGHT_ATTN) 1100 ;TONE_INPUT EQU MIC_IN_SELECT+(15*MONITOR_ATTN) 1101 ;CTRL_WD_12 equ NO_PREAMP+HI_PASS_FILT+SAMP_RATE_48+STEREO+DATA_16 ;CLB=0 1102 ;CTRL_WD_34 equ IMMED_3STATE+XTAL1_SELECT+BITS_64+CODEC_MASTER 1103 ;CTRL_WD_56 equ $000000 1104 ;CTRL_WD_78 equ $000000 1105 1106 000300 CTRL_WD_12 equ MIN_LEFT_ATTN+MIN_RIGHT_ATTN+LIN2+RIN2 1107 000000 CTRL_WD_34 equ MIN_LEFT_GAIN+MIN_RIGHT_GAIN 1108 1109 1110 P:000050 org p:$50 ;SCI Recieve Data Interrupt 1111 P:000050 0BF080 jsr ISCIRD 0001EE 1112 1113 P:000100 org p:$100 1114 START 1115 main 1116 P:000100 08F4BD movep #$040003,x:M_PCTL ; set PLL for MPY of 4X 040003 1117 P:000102 08F4BB movep #$012421,x:M_BCR ; set up one ext. wait state for all AAR areas Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 2 012421 1118 P:000104 0003F8 ori #3,mr ;mask interrupts 1119 P:000105 0500BB movec #0,sp ;clear hardware stack pointer 1120 P:000106 0500BA move #0,omr ;operating mode 0 1121 P:000107 364000 move #$40,r6 ; initialise stack pointer 1122 P:000108 05F426 move #-1,m6 ; linear addressing FFFFFF 1123 P:00010A 0BF080 jsr ada_init ; initialize codec 0002E6 1124 1125 1126 ; initialize SCI 1127 ; 10-bit asynchronous mode 1128 ; enable reciever and transmitter 1129 P:00010C 07F41C movep #$000B02,x:M_SCR ; SCI control register 000B02 1130 ; set interrupt priority for SCI RECV to 1 1131 P:00010E 56F000 move x:M_IPRP,a ; grab register current value FFFFFE 1132 ; enable tx and rx pins 1133 P:000110 07F41F movep #$000003,x:M_PCRE ; Port E Control Register 000003 1134 P:000112 0140C2 or #000080,a ; set bits for interrupt priority 2 000050 1135 ; Reciever/Transmitter clocks use external clock from SCLK 1136 P:000114 07F41B movep #$00C000,x:M_SCCR ; SCI Clock Control Register 00C000 1137 P:000116 567000 move a,x:M_IPRP ; put value in interrupt priority peripheral register FFFFFE 1138 1139 ;print a greeting and instructions 1140 P:000118 65F400 move #greet,r5 000017 1141 P:00011A 0BF080 jsr print 0001CD 1142 1143 loop_1 1144 1145 P:00011C 01B7A2 jset #2,x:M_SSISR0,* ;wait for frame sync to pass 00011C 1146 P:00011E 01B782 jclr #2,x:M_SSISR0,* ;wait for frame sync 00011E 1147 1148 P:000120 568000 move x:RX_BUFF_BASE,a ;receive left 1149 P:000121 578100 move x:RX_BUFF_BASE+1,b ;receive right 1150 P:000122 0BF080 jsr process_stereo 00012D 1151 P:000124 560400 move a,x:TX_BUFF_BASE ;transmit left 1152 P:000125 570500 move b,x:TX_BUFF_BASE+1 ;transmit right 1153 1154 P:000126 46F400 move #CTRL_WD_12,y0 ;set up control words 000300 1155 P:000128 460600 move y0,x:TX_BUFF_BASE+2 1156 P:000129 46F400 move #CTRL_WD_12,y0 000300 1157 P:00012B 460700 move y0,x:TX_BUFF_BASE+3 Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 3 1158 1159 P:00012C 0C011C jmp loop_1 1160 1161 1162 process_stereo 1163 1164 P:00012D 5E7000 move a,y:newa ;store new right channel value 000013 1165 P:00012F 5F7000 move b,y:newb ;store new left channel value 000014 1166 1167 P:000131 5EF000 move y:count,a 000001 1168 P:000133 5FF000 move y:divider,b ;check divide counter 000000 1169 P:000135 0140C0 add #>$1,a 000001 1170 P:000137 200005 cmp b,a 1171 P:000138 0D1041 bge proc 000009 1172 P:00013A 5E7000 move a,y:count ;increment divide counter 000001 1173 P:00013C 5EF000 move y:olda,a 000011 1174 P:00013E 5FF000 move y:oldb,b 000012 1175 P:000140 00000C rts 1176 1177 P:000141 2E0000 proc move #0,a ;reset divide counter 1178 P:000142 000000 nop 1179 P:000143 5E7000 move a,y:count 000001 1180 P:000145 5EF000 move y:mode,a 000016 1181 P:000147 200003 tst a 1182 P:000148 0D1042 bne delta 000016 1183 1184 1185 1186 P:00014A 2F8000 move #$800000,b ;initial mask 1187 P:00014B 4CF000 move y:masksz,x0 00000F 1188 P:00014D 0C1E79 asr x0,b,b ; shift the mask 1189 P:00014E 000000 nop 1190 P:00014F 5F7000 move b,y:mask 000015 1191 1192 P:000151 5EF000 move y:newa,a 000013 1193 P:000153 5FF000 move y:newb,b 000014 1194 1195 P:000155 4EF000 move y:mask,y0 000015 1196 P:000157 200056 and y0,a Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 4 1197 P:000158 20005E and y0,b 1198 P:000159 5E7000 move a,y:olda 000011 1199 P:00015B 5F7000 move b,y:oldb 000012 1200 P:00015D 00000C rts 1201 1202 1203 1204 delta 1205 ; debug 1206 ; debug 1207 P:00015E 4EF000 move y:diff,y0 ;load max delta mask into y0 00000E 1208 P:000160 4CF000 move y:masksz,x0 00000F 1209 1210 P:000162 5EF000 move y:newa,a 000013 1211 P:000164 5FF000 move y:olda,b ;new in a, old in b 000011 1212 1213 P:000166 200014 sub b,a ; get difference 1214 P:000167 000000 nop 1215 P:000168 5E7000 move a,y:temp ; hold difference in temp 000010 1216 P:00016A 200026 abs a ; check to see if it is in range 1217 P:00016B 200055 cmp y0,a 1218 P:00016C 0D1049 blt smalla 000003 1219 P:00016E 20CE00 move y0,a 1220 1221 P:00016F 0C1E68 smalla asr x0,a,a 1222 P:000170 0C1C0C asr #6,a,a 1223 P:000171 014786 and #7,a ; I should be able to remove this 1224 P:000172 4CF000 move y:coefloc,x0 00012B 1225 P:000174 200040 add x0,a 1226 P:000175 4CF000 move y:masksz,x0 00000F 1227 P:000177 21D500 move a,r5 1228 P:000178 000000 nop 1229 P:000179 000000 nop 1230 P:00017A 000000 nop 1231 P:00017B 5EE500 move y:(r5),a 1232 P:00017C 000000 nop 1233 P:00017D 0C1E48 asl x0,a,a 1234 P:00017E 0C1D0C asl #6,a,a 1235 1236 P:00017F 5FF000 move y:temp,b 000010 1237 P:000181 20000B tst b 1238 P:000182 0D1047 bgt posa 000008 1239 1240 ; move y:diff,a Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 5 1241 P:000184 200036 neg a 1242 P:000185 000000 nop 1243 P:000186 5E7000 move a,y:temp 000010 1244 P:000188 0D10C0 bra gooda 000004 1245 posa 1246 ; move y:diff,a 1247 P:00018A 5E7000 move a,y:temp 000010 1248 P:00018C 5EF000 gooda move y:temp,a 000010 1249 P:00018E 5FF000 move y:olda,b 000011 1250 P:000190 200010 add b,a ;add delta back in 1251 P:000191 000000 nop 1252 P:000192 5E7000 move a,y:olda ; store new value 000011 1253 1254 1255 P:000194 4CF000 move y:masksz,x0 00000F 1256 P:000196 5EF000 move y:newb,a 000014 1257 P:000198 5FF000 move y:oldb,b ;new in a, old in b 000012 1258 1259 P:00019A 200014 sub b,a ; get difference 1260 P:00019B 000000 nop 1261 P:00019C 5E7000 move a,y:temp ; hold difference in temp 000010 1262 P:00019E 200026 abs a ; check to see if it is in range 1263 P:00019F 200055 cmp y0,a 1264 P:0001A0 0D1049 blt smallb 000003 1265 P:0001A2 20CE00 move y0,a 1266 1267 P:0001A3 0C1E68 smallb asr x0,a,a 1268 P:0001A4 0C1C0C asr #6,a,a 1269 P:0001A5 014786 and #7,a ; I should be able to remove this 1270 P:0001A6 4CF000 move y:coefloc,x0 00012B 1271 P:0001A8 200040 add x0,a 1272 P:0001A9 4CF000 move y:masksz,x0 00000F 1273 P:0001AB 21D500 move a,r5 1274 P:0001AC 000000 nop 1275 P:0001AD 000000 nop 1276 P:0001AE 000000 nop 1277 P:0001AF 5EE500 move y:(r5),a 1278 P:0001B0 000000 nop 1279 P:0001B1 0C1E48 asl x0,a,a 1280 P:0001B2 0C1D0C asl #6,a,a 1281 1282 P:0001B3 5FF000 move y:temp,b 000010 Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 6 1283 P:0001B5 20000B tst b 1284 P:0001B6 0D1047 bgt posb 000008 1285 1286 ; move y:diff,a 1287 P:0001B8 200036 neg a 1288 P:0001B9 000000 nop 1289 P:0001BA 5E7000 move a,y:temp 000010 1290 P:0001BC 0D10C0 bra goodb 000004 1291 posb 1292 ; move y:diff,a 1293 P:0001BE 5E7000 move a,y:temp 000010 1294 P:0001C0 5EF000 goodb move y:temp,a 000010 1295 P:0001C2 5FF000 move y:oldb,b 000012 1296 P:0001C4 200010 add b,a ;add delta back in 1297 P:0001C5 000000 nop 1298 P:0001C6 5E7000 move a,y:oldb ; store new value 000012 1299 1300 P:0001C8 5EF000 move y:olda,a 000011 1301 P:0001CA 5FF000 move y:oldb,b 000012 1302 1303 P:0001CC 00000C rts 1304 1305 1306 ;print subroutine takes address in register r5 1307 ;exits when most significant byte is zero 1308 ;ignores zeros in lower bytes 1309 ; clobbers accumulator A and B and register r5 1310 print 1311 P:0001CD 5EDD00 prbegin move y:(r5)+,a 1312 ; cmp #$00ffff,a ;check to see if done (char=$00) 1313 ; blt prend 1314 P:0001CE 014085 cmp #$000000,a ;check to see if done (char=$00) 1315 P:0001CF 0D104A beq prend 00001E 1316 P:0001D1 019381 jclr #1,x:M_SSR,* ;wait for tx to finish 0001D1 1317 P:0001D3 019380 jclr #0,x:M_SSR,* ;wait for tx to finish 0001D3 1318 P:0001D5 567000 move a,x:M_STXH ; send high byte FFFF97 1319 P:0001D7 0140C6 and #$00ffff,a 00FFFF 1320 P:0001D9 0140C5 cmp #$0000ff,a 0000FF 1321 P:0001DB 0597D2 blt prbegin 1322 P:0001DC 019381 jclr #1,x:M_SSR,* ;wait for tx to finish 0001DC Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 7 1323 P:0001DE 019380 jclr #0,x:M_SSR,* ;wait for tx to finish 0001DE 1324 P:0001E0 567000 move a,x:M_STXM ; send mid byte FFFF96 1325 P:0001E2 0140C6 and #$0000ff,a 0000FF 1326 P:0001E4 014085 cmp #$000000,a 1327 P:0001E5 0597C8 blt prbegin 1328 P:0001E6 019381 jclr #1,x:M_SSR,* ;wait for tx to finish 0001E6 1329 P:0001E8 019380 jclr #0,x:M_SSR,* ;wait for tx to finish 0001E8 1330 P:0001EA 567000 move a,x:M_STXL ; send low byte FFFF95 1331 P:0001EC 050FC1 bra prbegin 1332 P:0001ED 00000C prend rts 1333 1334 1335 ; the SCI interrupt is triggered when a character is received 1336 ; this function takes the character, checks to make sure it is 1337 ; in the correct range (1-9, A-G, a-g) prints a message and 1338 ; modifies the output mask for that number of bits 1339 P:0001EE 21C600 ISCIRD move a,y0 ;back up A 1340 P:0001EF 56F000 move x:M_SRXL,a FFFF98 1341 1342 P:0001F1 016185 cmp #'!',a 1343 P:0001F2 0D104A beq iscd1 0000BB 1344 P:0001F4 0140C5 cmp #'@',a 000040 1345 P:0001F6 0D104A beq iscd2 0000BF 1346 P:0001F8 016385 cmp #'#',a 1347 P:0001F9 0D104A beq iscd3 0000C4 1348 P:0001FB 016485 cmp #'$',a 1349 P:0001FC 0D104A beq iscd4 0000C9 1350 P:0001FE 016585 cmp #'%',a 1351 P:0001FF 0D104A beq iscd5 0000CE 1352 P:000201 0140C5 cmp #'^',a 00005E 1353 P:000203 0D104A beq iscd6 0000D2 1354 1355 P:000205 017185 cmp #$31,a ; >='1' 1356 P:000206 0D1049 blt iscend 0000DE 1357 P:000208 017A85 cmp #$3A,a ; <='9' 1358 P:000209 0D1049 blt iscnum 00001D 1359 1360 P:00020B 0140C5 cmp #'M',a ; =='M' ; change mode 00004D Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 8 1361 P:00020D 0D104A beq iscmode 000043 1362 P:00020F 0140C5 cmp #'m',a ; =='m' 00006D 1363 P:000211 0D104A beq iscmode 00003F 1364 1365 P:000213 0140C5 cmp #$40,a ; >='A' 000040 1366 P:000215 0D1049 blt iscend 0000CF 1367 P:000217 0140C5 cmp #$48,a ; <='G' 000048 1368 P:000219 0D1049 blt isclet 00000E 1369 P:00021B 0140C5 cmp #$60,a ; >='a' 000060 1370 P:00021D 0D1049 blt iscend 0000C7 1371 P:00021F 0140C5 cmp #$67,a ; <='g' 000067 1372 P:000221 0D1047 bgt iscend 0000C3 1373 P:000223 016084 sub #$20,a 1374 P:000224 0D10C0 bra isclet 000003 1375 1376 P:000226 014780 iscnum add #$07,a 1377 P:000227 014980 isclet add #$09,a 1378 1379 P:000228 019381 isciup jclr #1,x:M_SSR,* ;wait for tx to finish 000228 1380 P:00022A 019380 jclr #0,x:M_SSR,* ;wait for tx to finish 00022A 1381 P:00022C 07F415 movep #$0d,x:M_STXL ;print LF 00000D 1382 P:00022E 2F8000 move #$800000,b ;initial mask 1383 P:00022F 5E7000 move a,y:temp ;hold onto value temporarially 000010 1384 P:000231 0140C4 sub #$41,a ; ammount to shift mask 000041 1385 P:000233 5E7000 move a,y:masksz 00000F 1386 P:000235 21C400 move a,x0 1387 P:000236 0C1E79 asr x0,b,b ; shift the mask 1388 1389 P:000237 56F400 move #>$00000f,a ;calculate bit shift 00000F 1390 P:000239 200044 sub x0,a 1391 P:00023A 0C1E35 lsr a1,b 1392 P:00023B 2B0000 move #<$00,b2 1393 1394 P:00023C 5EF000 move y:temp,a 000010 1395 P:00023E 5F7000 move b,y:diff 00000E Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 9 1396 1397 P:000240 015084 sub #$10,a 1398 P:000241 017A85 cmp #$3A,a ; is a 10 digit? 1399 P:000242 0D1049 blt isci0 000005 1400 1401 P:000244 014A84 isci1 sub #$0a,a 1402 P:000245 0140C2 or #$001100,a ; add 10's digit if necessary 001100 1403 1404 P:000247 0140C0 isci0 add #$202000,a 202000 1405 P:000249 5E7000 move a,y:bits 000123 1406 P:00024B 65F400 move #modech,r5 000122 1407 P:00024D 0D01CD jsr print 1408 P:00024E 0D10C0 bra iscend 000096 1409 1410 1411 1412 1413 1414 1415 1416 P:000250 5EF000 iscmode move y:modech,a ;change modes 000122 1417 P:000252 0140C5 cmp #$44332d,a ;check if D3 mode 44332D 1418 P:000254 0D104A beq iscms 000044 1419 P:000256 0140C5 cmp #$44302d,a ;check if D0 mode 44302D 1420 P:000258 0D104A beq iscmd1 000019 1421 P:00025A 0140C5 cmp #$44312d,a ;check if D1 mode 44312D 1422 P:00025C 0D104A beq iscmd2 000022 1423 P:00025E 0140C5 cmp #$44322d,a ;check if D2 mode 44322D 1424 P:000260 0D104A beq iscmd3 00002B 1425 P:000262 0D10C0 bra iscmd0 ; must be S mode 000002 1426 1427 P:000264 56F400 iscmd0 move #$44302d,a ; change from S to D0 mode 44302D 1428 P:000266 5E7000 move a,y:modech 000122 1429 P:000268 2E0100 move #1,a 1430 P:000269 57F400 move #>coef0,b 00012C 1431 P:00026B 5E7000 move a,y:mode 000016 Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 10 1432 P:00026D 5F7000 move b,y:coefloc 00012B 1433 P:00026F 0D10C0 bra iscmend 000033 1434 1435 P:000271 56F400 iscmd1 move #$44312d,a ; change from S to D0 mode 44312D 1436 P:000273 5E7000 move a,y:modech 000122 1437 P:000275 2E0100 move #1,a 1438 P:000276 57F400 move #>coef1,b 000134 1439 P:000278 5E7000 move a,y:mode 000016 1440 P:00027A 5F7000 move b,y:coefloc 00012B 1441 P:00027C 0D10C0 bra iscmend 000026 1442 1443 P:00027E 56F400 iscmd2 move #$44322d,a ; change from S to D0 mode 44322D 1444 P:000280 5E7000 move a,y:modech 000122 1445 P:000282 2E0100 move #1,a 1446 P:000283 57F400 move #>coef2,b 00013C 1447 P:000285 5E7000 move a,y:mode 000016 1448 P:000287 5F7000 move b,y:coefloc 00012B 1449 P:000289 0D10C0 bra iscmend 000019 1450 1451 P:00028B 56F400 iscmd3 move #$44332d,a ; change from S to D0 mode 44332D 1452 P:00028D 5E7000 move a,y:modech 000122 1453 P:00028F 2E0100 move #1,a 1454 P:000290 57F400 move #>coef3,b 000144 1455 P:000292 5E7000 move a,y:mode 000016 1456 P:000294 5F7000 move b,y:coefloc 00012B 1457 P:000296 0D10C0 bra iscmend 00000C 1458 1459 1460 P:000298 56F400 iscms move #$53202d,a ;change from D3 to S mode 53202D 1461 P:00029A 5E7000 move a,y:modech 000122 1462 P:00029C 2E0000 move #0,a 1463 P:00029D 000000 nop 1464 P:00029E 5E7000 move a,y:mode 000016 Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 11 1465 P:0002A0 0D10C0 bra iscmend 000002 1466 P:0002A2 019381 iscmend jclr #1,x:M_SSR,* ;wait for tx to finish 0002A2 1467 P:0002A4 019380 jclr #0,x:M_SSR,* ;wait for tx to finish 0002A4 1468 P:0002A6 07F415 movep #$0d,x:M_STXL ;print LF 00000D 1469 P:0002A8 65F400 move #modech,r5 000122 1470 P:0002AA 0D01CD jsr print 1471 P:0002AB 0D10C0 bra iscend 000039 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 P:0002AD 5EF000 iscd1 move y:d1,a 000002 1484 P:0002AF 5E7000 move a,y:div 000126 1485 P:0002B1 56F400 move #>$1,a 000001 1486 ; move a,y:divider 1487 P:0002B3 0D10C0 bra isccend 00002A 1488 1489 P:0002B5 5EF000 iscd2 move y:d2,a 000004 1490 P:0002B7 5E7000 move a,y:div 000126 1491 P:0002B9 56F400 move #>$2,a 000002 1492 ; move a,y:divider 1493 P:0002BB 0D10C0 bra isccend 000022 1494 1495 P:0002BD 5EF000 iscd3 move y:d4,a 000006 1496 P:0002BF 5E7000 move a,y:div 000126 1497 P:0002C1 56F400 move #>$4,a 000004 1498 ; move a,y:divider 1499 P:0002C3 0D10C0 bra isccend 00001A 1500 1501 P:0002C5 5EF000 iscd4 move y:d8,a 000008 Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 12 1502 P:0002C7 5E7000 move a,y:div 000126 1503 P:0002C9 56F400 move #>$8,a 000008 1504 ; move a,y:divider 1505 P:0002CB 0D10C0 bra isccend 000012 1506 1507 P:0002CD 5EF000 iscd5 move y:d16,a 00000A 1508 P:0002CF 5E7000 move a,y:div 000126 1509 P:0002D1 56F400 move #>$10,a 000010 1510 ; move a,y:divider 1511 P:0002D3 0D10C0 bra isccend 00000A 1512 1513 P:0002D5 5EF000 iscd6 move y:d32,a 00000C 1514 P:0002D7 5E7000 move a,y:div 000126 1515 P:0002D9 56F400 move #>$20,a 000020 1516 ; move a,y:divider 1517 P:0002DB 0D10C0 bra isccend 000002 1518 1519 P:0002DD 5E7000 isccend move a,y:divider 000000 1520 P:0002DF 65F400 move #modech,r5 000122 1521 P:0002E1 0D01CD jsr print 1522 P:0002E2 0D10C0 bra iscend 000002 1523 1524 P:0002E4 20CE00 iscend move y0,a ;restore A 1525 P:0002E5 000004 rti 1526 1527 1528 1529 1530 include 'ada_init.asm' 1531 page 132,60 1532 ;************************************************************************** 1533 ; ADA_INIT.ASM Ver 1.2 1534 ; Example program to initialize the CS4218 1535 ; 1536 ; Copyright (c) MOTOROLA 1995, 1996, 1997, 1998 1537 ; Semiconductor Products Sector 1538 ; Wireless Signal Processing Division 1539 ; 1540 ; History: 1541 ; 14 June 1996: RLR/LJD - ver 1.0 1542 ; 21 July 1997: BEA - ver 1.1 1543 ; 23 Sept 1998: TTL - ver 1.2 Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 ada_init.asm Page 13 1544 ;************************************************************************** 1545 X:00000A org x: 1546 1547 ; Codec control constants 1548 X:00000A CTRL_WD_HI ds 1 1549 X:00000B CTRL_WD_LO ds 1 1550 1551 1552 ; GPIO pin constants 1553 1554 ; ESSI0 - audio data GPIO mode 1555 ; DSP CODEC 1556 ; --------------------------- 1557 CODEC_RESET 1558 000000 equ 0 ; bit0 SC00 ---> CODEC_RESET~ 1559 1560 ; ESSI1 - control data GPIO Mode 1561 ; DSP CODEC 1562 ;---------------------------- 1563 000000 CCS equ 0 ; bit0 SC10 ---> CCS~ 1564 000001 CCLK equ 1 ; bit1 SC11 ---> CCLK 1565 000002 CDIN equ 2 ; bit2 SC12 ---> CDIN 1566 1567 ;************************************************************************** 1568 ; Initialize the CS4218 codec 1569 ; --------------------------- 1570 ; Serial Mode 4 (SM4), DSP Slave/Codec Master, 32-bits per frame 1571 ; 1572 ; After a reset, the control port must be written once to initialize it 1573 ; if the port will be accessed to read or write control bits. The initial 1574 ; write is a "dummy" write since the data is ignored by the codec. A second 1575 ; write is needed to configure the codec as desired. Then, the control port 1576 ; only needs to be written to when a change is desired, or to obtain status 1577 ; information. 1578 ; 1579 ; Although only 23 bits contain useful data in CDIN, a minimum of 31 bits 1580 ; must be written. 1581 ; 1582 ; CDIN 1583 ;------------------------------------------------ 1584 ; bit 31 0 1585 ;------------------------------------------------ 1586 ; bit 30 mask interrupt 1587 ; 0=no mask on MF5:\INT pin 1588 ; 1=mask on MF5:\INT pin 1589 ;------------------------------------------------ 1590 ; bit 29 DO1 1591 ;------------------------------------------------ 1592 ; bits 28-24 left output D/A sttenuation (1.5dB steps) 1593 ; 00000=No attenuation 0dB 1594 ; 11111=Max attenuation -46.5dB 1595 ;------------------------------------------------ 1596 ; bits 23-19 right output D/A attenuation (1.5dB steps) 1597 ; 00000=No attenuation 0dB 1598 ; 11111=Max attenuation -46.5dB 1599 ;------------------------------------------------ Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 ada_init.asm Page 14 1600 ; bit 18 mute D/A outputs 1601 ; 0=outputs ON 1602 ; 1=outputs MUTED 1603 ;------------------------------------------------ 1604 ; bit 17 input mux, left select 1605 ; 0=RIN1 1606 ; 1=RIN2 (used on EVM) 1607 ;------------------------------------------------ 1608 ; bit 16 input mux, right select 1609 ; 0=LIN1 1610 ; 1=LIN2 (used on EVM) 1611 ;------------------------------------------------ 1612 ; bits 15-12 left input A/D gain (1.5dB steps) 1613 ; 0000=No gain 0dB 1614 ; 1111=Max gain +22.5dB 1615 ;------------------------------------------------ 1616 ; bits 11-8 right input A/D gain (1.5dB steps) 1617 ; 0000=No gain 0dB 1618 ; 1111=Max gain +22.5dB 1619 ;------------------------------------------------ 1620 ; bits 7-0 00000000 1621 ;------------------------------------------------ 1622 ;************************************************************************** 1623 1624 1625 P:0002E6 org p: 1626 ada_init 1627 1628 ; reset ESSI ports 1629 P:0002E6 07F43F movep #$0000,x:M_PCRC ; reset ESSI0 port 000000 1630 P:0002E8 07F42F movep #$0000,x:M_PCRD ; reset ESSI1 port 000000 1631 1632 ; Set Control Register A and B 1633 P:0002EA 07F435 movep #$101807,x:M_CRA0 ; 12.288MHz/16 = 768KHz SCLK 101807 1634 ; prescale modulus = 8 1635 ; frame rate divider = 2 1636 ; 16-bits per word 1637 ; 32-bits per frame 1638 ; 16-bit data aligned to bit 23 1639 1640 P:0002EC 07F436 movep #$ff330c,x:M_CRB0 ; Enable REIE,TEIE,RLIE,TLIE, FF330C 1641 ; RIE,TIE,RE,TE0 1642 ; network mode, synchronous, 1643 ; out on rising/in on falling 1644 ; shift MSB first 1645 ; external clock source drives SCK 1646 ; (codec is master) 1647 ; RX frame sync pulses active for 1648 ; 1 bit clock immediately before 1649 ; transfer period 1650 ; positive frame sync polarity 1651 ; frame sync length is 1-bit Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 ada_init.asm Page 15 1652 1653 ; Configure GPIO pins -- (functionality and direction ) 1654 P:0002EE 07F43F movep #$0000,x:M_PCRC ; Enable GPIO pin 0 SC00=CODEC_RESET 000000 1655 P:0002F0 07F42F movep #$0000,x:M_PCRD ; Enable GPIO CSS (pin 0),CCLK (pin 1), CDIN (pin 2) 000000 1656 1657 P:0002F2 07F43E movep #$0001,x:M_PRRC ; set PC0=CODEC_RESET~ as output 000001 1658 P:0002F4 07F42E movep #$0007,x:M_PRRD ; set PD0=CCS~ as output 000007 1659 ; set PD1=CCLK as output 1660 ; set PD2=CDIN as output 1661 1662 ; Codec Reset 1663 P:0002F6 013D00 bclr #CODEC_RESET,x:M_PDRC ; assert CODEC_RESET~ 1664 P:0002F7 012D00 bclr #CCS,x:M_PDRD ; assert CCS~ -- allows control register to be writte n to 1665 1666 ; Delay to allow Codec to reset 1667 P:0002F8 06E883 do #1000,_delay_loop 0002FB 1668 P:0002FA 06E8A3 rep #1000 ; minimum 50 ms delay 1669 P:0002FB 000000 nop 1670 _delay_loop 1671 1672 1673 ; Setting up to send Codec control information 1674 P:0002FC 013D20 bset #CODEC_RESET,x:M_PDRC ; deassert CODEC_RESET~ 1675 1676 1677 ; Sending control words 1678 set_control 1679 P:0002FD 44F400 move #CTRL_WD_12,x0 ; transfer control value to control variable 000300 1680 P:0002FF 440A00 move x0,x:CTRL_WD_HI 1681 P:000300 240000 move #CTRL_WD_34,x0 1682 P:000301 440B00 move x0,x:CTRL_WD_LO 1683 P:000302 0BF080 jsr codec_control ; send in dummy control information 00030C 1684 P:000304 0BF080 jsr codec_control ; send in correct control information 00030C 1685 1686 1687 ; Set and enable interrupts 1688 P:000306 08F4BE movep #$000c,x:M_IPRP ; set interrupt priority level for ESSI0 to 3 00000C 1689 P:000308 00FCB8 andi #$fc,mr ; enable interrupts 1690 1691 ; Set ESSI functionality 1692 P:000309 07F43F movep #$003e,x:M_PCRC ; enable ESSI0 except SC00=CODEC_RESET 00003E 1693 1694 P:00030B 00000C rts 1695 Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 ada_init.asm Page 16 1696 1697 ;------------------------------------------------------------- 1698 ; codec_control routine 1699 ; Input: CTRL_WD_LO and CTRL_WD_HI 1700 ; Output: CDIN 1701 ; Description: Used to send control information to CODEC 1702 ; NOTE: does not preserve the 'a' register. 1703 ;------------------------------------------------------------- 1704 codec_control 1705 P:00030C 200013 clr a 1706 P:00030D 012D00 bclr #CCS,x:M_PDRD ; assert CCS 1707 P:00030E 548A00 move x:CTRL_WD_HI,a1 ; upper 16 bits of control data 1708 P:00030F 0BF080 jsr send_codec ; shift out upper control word 000316 1709 P:000311 548B00 move x:CTRL_WD_LO,a1 ; lower 16 bits of control data 1710 P:000312 0BF080 jsr send_codec ; shift out lower control word 000316 1711 P:000314 012D20 bset #CCS,x:M_PDRD ; deassert CCS 1712 P:000315 00000C rts 1713 1714 1715 ;--------------------------------------------------------------- 1716 ; send_codec routine 1717 ; Input: a1 containing control information 1718 ; Output: sends bits to CDIN 1719 ; Description: Determines bits to send to CDIN 1720 ;--------------------------------------------------------------- 1721 1722 send_codec 1723 P:000316 061080 do #16,end_send_codec ; 16 bits per word 000322 1724 P:000318 012D21 bset #CCLK,x:M_PDRD ; toggle CCLK clock high 1725 P:000319 0ACC17 jclr #23,a1,bit_low ; test msb 00031E 1726 P:00031B 012D22 bset #CDIN,x:M_PDRD ; send high into CDIN 1727 P:00031C 0AF080 jmp continue 00031F 1728 bit_low 1729 P:00031E 012D02 bclr #CDIN,x:M_PDRD ; send low into CDIN 1730 continue 1731 P:00031F 0602A0 rep #2 ; delay 1732 P:000320 000000 nop 1733 P:000321 012D01 bclr #CCLK,x:M_PDRD ; restart cycle 1734 P:000322 200033 lsl a ; shift control word to 1 bit 1735 ; to left 1736 end_send_codec 1737 P:000323 00000C rts 1738 1739 1740 1741 1742 ;**************************************************************************** 1743 ; SSI0_ISR.ASM Ver.2.0 1744 ; Example program to handle interrupts through 1745 ; the 56307 SSI0 to move audio through the CS4218 1746 ; Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 ada_init.asm Page 17 1747 ; Copyright (c) MOTOROLA 1995, 1996, 1997, 1998 1748 ; Semiconductor Products Sector 1749 ; Digital Signal Processing Division 1750 ; 1751 ; 1752 ; History: 1753 ; 14 June 1996: RLR/LJD - ver 1.0 1754 ; 23 July 1997: BEA - ver 1.1 1755 ;****************************************************************************** 1756 1757 1758 ;----the actual interrupt service routines (ISRs) follow: 1759 1760 ;************************ SSI TRANSMIT ISR ********************************* 1761 ssi_txe_isr 1762 P:000324 013704 bclr #4,x:M_SSISR0 ; Read SSISR to clear exception flag 1763 ; explicitly clears underrun flag 1764 ssi_tx_isr 1765 P:000325 605F00 move r0,x:(r7)+ ; Save r0 to the stack. 1766 P:000326 055F20 move m0,x:(r7)+ ; Save m0 to the stack. 1767 P:000327 0501A0 move #1,m0 ; Modulus 2 buffer. 1768 P:000328 608900 move x:TX_PTR,r0 ; Load the pointer to the tx buffer. 1769 P:000329 000000 nop 1770 P:00032A 000000 nop 1771 P:00032B 000000 nop 1772 P:00032C 07D83C movep x:(r0)+,x:M_TX00 ; SSI transfer data register. 1773 P:00032D 600900 move r0,x:TX_PTR ; Update tx buffer pointer. 1774 P:00032E 05FF20 move x:-(r7),m0 ; Restore m0. 1775 P:00032F 60FF00 move x:-(r7),r0 ; Restore r0. 1776 P:000330 000004 rti 1777 1778 ;********************* SSI TRANSMIT LAST SLOT ISR ************************** 1779 ssi_txls_isr 1780 P:000331 605F00 move r0,x:(r7)+ ; Save r0 to the stack. 1781 P:000332 300400 move #TX_BUFF_BASE,r0 ; Reset pointer. 1782 P:000333 000000 nop 1783 P:000334 600900 move r0,x:TX_PTR ; Reset tx buffer pointer just in 1784 P:000335 000000 nop ; case it was corrupted. 1785 P:000336 60FF00 move x:-(r7),r0 ; Restore r0. 1786 P:000337 000004 rti 1787 1788 ;************************** SSI receive ISR ******************************** 1789 ssi_rxe_isr 1790 P:000338 013705 bclr #5,x:M_SSISR0 ; Read SSISR to clear exception flag 1791 ; explicitly clears overrun flag 1792 ssi_rx_isr 1793 P:000339 605F00 move r0,x:(r7)+ ; Save r0 to the stack. 1794 P:00033A 055F20 move m0,x:(r7)+ ; Save m0 to the stack. 1795 P:00033B 0501A0 move #1,m0 ; Modulus 2 buffer. 1796 P:00033C 608800 move x:RX_PTR,r0 ; Load the pointer to the rx buffer. 1797 P:00033D 000000 nop 1798 P:00033E 000000 nop 1799 P:00033F 000000 nop 1800 P:000340 075838 movep x:M_RX0,x:(r0)+ ; Read out received data to buffer. 1801 P:000341 600800 move r0,x:RX_PTR ; Update rx buffer pointer. 1802 P:000342 05FF20 move x:-(r7),m0 ; Restore m0. Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 ada_init.asm Page 18 1803 P:000343 60FF00 move x:-(r7),r0 ; Restore r0. 1804 P:000344 000004 rti 1805 1806 ;********************** SSI receive last slot ISR ************************** 1807 ssi_rxls_isr 1808 P:000345 605F00 move r0,x:(r7)+ ; Save r0 to the stack. 1809 P:000346 300000 move #RX_BUFF_BASE,r0 ; Reset rx buffer pointer just in 1810 ; case it was corrupted. 1811 P:000347 600800 move r0,x:RX_PTR ; Update rx buffer pointer. 1812 P:000348 60FF00 move x:-(r7),r0 ; Restore r0. 1813 P:000349 000004 rti 1814 1815 Y:000000 org y: 1816 Y:000000 divider dc $1 1817 Y:000001 count dc $0 1818 ;doffset dc $0 1819 1820 ;d dc d1,d2,d4,d8,d16,d32 1821 Y:000002 d1 dc "1 ",$0 ; 48 1822 Y:000004 d2 dc "2 ",$0 ; 24 1823 Y:000006 d4 dc "4 ",$0 ; 12 1824 Y:000008 d8 dc "8 ",$0 ; 6 1825 Y:00000A d16 dc "16 ",$0 ; 3 1826 Y:00000C d32 dc "32 ",$0 ; 1.5 1827 1828 Y:00000E diff dc $007f00 1829 Y:00000F masksz dc $07 1830 Y:000010 temp dc $0 1831 Y:000011 olda dc $0 1832 Y:000012 oldb dc $0 1833 Y:000013 newa dc $0 1834 Y:000014 newb dc $0 1835 Y:000015 mask dc $00ffff 1836 Y:000016 mode dc $0 ;0=sampling 1=delta 1837 Y:000017 greet dc $0a0d00 1838 Y:000018 dc "This program demonstrates 16-bit audio sampling on the Motorola" 1839 Y:00002D dc $0a0d00 1840 Y:00002E dc "DSP56303 with delta modulating and bit sampling using 1-16 bits." 1841 Y:000044 dc $0a0d00 1842 Y:000045 dc "Bit sampling takes the high order n bits of the input sample and" 1843 Y:00005B dc $0a0d00 1844 Y:00005C dc "constructs the output from only those bits to give varied resolutions" 1845 Y:000073 dc $0a0d00 1846 Y:000074 dc "Delta Modulation uses one of four different modulation techniques. The" 1847 Y:00008C dc $0a0d00 1848 Y:00008D dc "minimum stepsize is varied from 2^0 to 2^15 to give different resolutions." 1849 Y:0000A6 dc $0a0d00 1850 Y:0000A7 dc "Attach the audio input to the Line-In jack and speakers/headphones" 1851 Y:0000BD dc $0a0d00 1852 Y:0000BE dc "to the Headphone-Out jack. " 1853 Y:0000C8 dc $0a0d00 1854 Y:0000C9 dc $0a0d00 1855 Y:0000CA dc "Type 1-9 or A-G to get the different max delta/resolutions" 1856 Y:0000DE dc $0a0d00 1857 Y:0000DF dc "1=1 bit, G=16 bit. Type M to change between Sampled (S)" 1858 Y:0000F2 dc $0a0d00 Motorola DSP56300 Assembler Version 6.2.0 99-12-08 16:13:11 pass_c~7.asm Page 19 1859 Y:0000F3 dc "and Delta (D) modes. Type [Shift}+1 through 6 to change the" 1860 Y:000107 dc $0a0d00 1861 Y:000108 dc "sampling rate, 48/2^(n-1) kHz" 1862 Y:000112 dc $0a0d00,$0a0d00 1863 Y:000114 dc "Mode - Resolution (bits) - Freq (kHz):" 1864 Y:000121 dc $0a0d00 1865 Y:000122 modech dc $53202d ; ="S -" 1866 Y:000123 bits dc $202038 ; =" 8" 1867 Y:000124 hz dc " - 48/" 1868 Y:000126 div dc "1 " 1869 Y:000127 dc $0d0000,$0 1870 Y:000129 crlf dc $0a0d00,$0 1871 Y:00012B coefloc dc coef3 ; location of coeficients 1872 Y:00012C coef0 dc 7,7,7,7,7,7,7,7 ; used for delta modulation 1873 Y:000134 coef1 dc 0,0,0,0,7,7,7,7 ; used for delta modulation 1874 Y:00013C coef2 dc 0,0,2,2,2,7,7,7 1875 Y:000144 coef3 dc 0,0,2,2,4,4,7,7 1876 1877 end 0 Errors 0 Warnings