⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1011.s

📁 AVR单片机ATMEGA64L开发的mp3程序
💻 S
字号:
	.module _1011.c
	.area text(rom, con, rel)
	.dbfile D:\论文资料\AVRPWM~1\阿莫MP3范例板\MP3范例板\u盘MP3代码\1011.c
	.dbfunc e spi_init _spi_init fV
	.even
_spi_init::
	.dbline -1
	.dbline 18
; #include <iom64v.h>
; #include <macros.h>
; #include "delay.h"
; #define uchar unsigned char
; #define uint unsigned int
; 
; #define MP3_DDR        DDRB
; #define MP3_PORT       PORTB
; #define MP3_PIN        PINB
; #define MP3_CMD_CS     BIT(4)
; #define MP3_DATA_REST  BIT(5) 
; #define MP3_DATA_REQ   BIT(6)  
; #define MP3_DATA_CS    BIT(7)
; 
; 
; //SPI initialize
; void spi_init(void)
; {
	.dbline 19
;  	DDRB = 0xBF;    //SI输入,SO,SCK,SS输出
	ldi R24,191
	out 0x17,R24
	.dbline 20
;  	SPCR = 0x50;  //setup SPI
	ldi R24,80
	out 0xd,R24
	.dbline 21
;  	SPSR = 0x01;  //setup SPI
	ldi R24,1
	out 0xe,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e mp3_port_init _mp3_port_init fV
	.even
_mp3_port_init::
	.dbline -1
	.dbline 25
; }
; 
; void mp3_port_init()
; {
	.dbline 26
; 	spi_init();
	xcall _spi_init
	.dbline 27
; 	MP3_DDR|=MP3_DATA_CS |MP3_CMD_CS|MP3_DATA_REST;
	in R24,0x17
	ori R24,176
	out 0x17,R24
	.dbline 28
; 	MP3_DDR&=~MP3_DATA_REQ;
	cbi 0x17,6
	.dbline 29
; 	MP3_PORT|=MP3_DATA_CS |MP3_CMD_CS|MP3_DATA_REST;
	in R24,0x18
	ori R24,176
	out 0x18,R24
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Write_Byte_MMC _Write_Byte_MMC fV
;           byte -> R16
	.even
_Write_Byte_MMC::
	.dbline -1
	.dbline 33
; }
; 
; void Write_Byte_MMC(unsigned char byte)
; {   
	.dbline 34
;     SPDR = byte;
	out 0xf,R16
L4:
	.dbline 36
	.dbline 37
	.dbline 38
L5:
	.dbline 35
;     while (!(SPSR & (1<<SPIF)))
	sbis 0xe,7
	rjmp L4
	.dbline -2
L3:
	.dbline 0 ; func end
	ret
	.dbsym r byte 16 c
	.dbend
	.dbfunc e Read_Byte_MMC _Read_Byte_MMC fc
	.even
_Read_Byte_MMC::
	.dbline -1
	.dbline 42
;     {
;     	;
; 	}        
; }
; 
; unsigned char Read_Byte_MMC(void)
; {   
	.dbline 43
;     SPDR = 0xFF;
	ldi R24,255
	out 0xf,R24
L8:
	.dbline 45
	.dbline 46
	.dbline 47
L9:
	.dbline 44
;     while (!(SPSR &(1<<SPIF)))
	sbis 0xe,7
	rjmp L8
	.dbline 49
;     {
;     	;
; 	}
;             
;     return SPDR;
	in R16,0xf
	.dbline -2
L7:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e vs1003_cmd_write _vs1003_cmd_write fV
;           data -> R20,R21
;        address -> R22
	.even
_vs1003_cmd_write::
	xcall push_gset2
	movw R20,R18
	mov R22,R16
	.dbline -1
	.dbline 53
; }
; 
; void vs1003_cmd_write(uchar address,uint data)
; { 
	.dbline 54
; 	SPCR = 0x53;  //
	ldi R24,83
	out 0xd,R24
	.dbline 55
; 	SPSR = 0x00;  //低速度spi
	clr R2
	out 0xe,R2
	.dbline 57
; 	//============== 
; 	MP3_PORT|=MP3_DATA_CS;       //MP3_DATA_CS=1;
	sbi 0x18,7
	.dbline 58
; 	MP3_PORT&=~MP3_CMD_CS;       //MP3_CMD_CS=0;
	cbi 0x18,4
	.dbline 59
; 	Write_Byte_MMC(0x02);      //VS1011的写命令
	ldi R16,2
	xcall _Write_Byte_MMC
	.dbline 60
; 	delay_nus(40);
	ldi R16,40
	ldi R17,0
	xcall _delay_nus
	.dbline 61
; 	Write_Byte_MMC(address);   //地址
	mov R16,R22
	xcall _Write_Byte_MMC
	.dbline 62
; 	Write_Byte_MMC(data>>8);
	movw R16,R20
	mov R16,R17
	clr R17
	xcall _Write_Byte_MMC
	.dbline 63
; 	Write_Byte_MMC(data);
	mov R16,R20
	xcall _Write_Byte_MMC
	.dbline 64
; 	delay_nus(200);
	ldi R16,200
	ldi R17,0
	xcall _delay_nus
	.dbline 65
; 	MP3_PORT|=MP3_CMD_CS;       //MP3_CMD_CS=1;
	sbi 0x18,4
	.dbline 67
; 
; 	SPCR = 0x50;  //
	ldi R24,80
	out 0xd,R24
	.dbline 68
; 	SPSR = 0x01;  //高速spi
	ldi R24,1
	out 0xe,R24
	.dbline -2
L11:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r data 20 i
	.dbsym r address 22 c
	.dbend
	.dbfunc e vs1003_data_write _vs1003_data_write fV
;           data -> R20
	.even
_vs1003_data_write::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 73
; 	//========================= 
; } 
; 
; void vs1003_data_write(uchar data)
; {
	.dbline 74
; 	MP3_PORT&=~MP3_DATA_CS;         //MP3_DATA_CS=0;
	cbi 0x18,7
	.dbline 75
; 	Write_Byte_MMC(data);
	mov R16,R20
	xcall _Write_Byte_MMC
	.dbline 76
; 	MP3_PORT|=MP3_DATA_CS;         //MP3_DATA_CS=1;
	sbi 0x18,7
	.dbline 77
; 	MP3_PORT|=MP3_CMD_CS;         //MP3_CMD_CS=1; 
	sbi 0x18,4
	.dbline -2
L12:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r data 20 c
	.dbend
	.dbfunc e vs1003_read _vs1003_read fi
;          temp1 -> R22
;           temp -> R20,R21
;        address -> R10
	.even
_vs1003_read::
	xcall push_gset3
	mov R10,R16
	.dbline -1
	.dbline 81
; }
; 
; uint vs1003_read(uchar address)
; {
	.dbline 82
; 	uchar temp1=0;
	clr R22
	.dbline 83
; 	uint temp=0; 
	clr R20
	clr R21
	.dbline 84
; 	MP3_PORT|=MP3_DATA_CS;        //MP3_DATA_CS=1;
	sbi 0x18,7
	.dbline 85
; 	MP3_PORT&=~MP3_CMD_CS;        //MP3_CMD_CS=0;
	cbi 0x18,4
	.dbline 86
; 	Write_Byte_MMC(0x03);      //VS1011的读命令
	ldi R16,3
	xcall _Write_Byte_MMC
	.dbline 87
; 	delay_nus(30);
	ldi R16,30
	ldi R17,0
	xcall _delay_nus
	.dbline 88
; 	Write_Byte_MMC(address);   //地址
	mov R16,R10
	xcall _Write_Byte_MMC
	.dbline 89
; 	temp=Read_Byte_MMC();
	xcall _Read_Byte_MMC
	mov R20,R16
	clr R21
	.dbline 90
; 	temp=temp<<8;
	mov R21,R20
	clr R20
	.dbline 91
; 	temp1=Read_Byte_MMC();
	xcall _Read_Byte_MMC
	mov R22,R16
	.dbline 92
; 	temp=temp|temp1; 
	mov R2,R22
	clr R3
	or R20,R2
	or R21,R3
	.dbline 93
; 	MP3_PORT|=MP3_CMD_CS;       //MP3_CMD_CS=1;
	sbi 0x18,4
	.dbline 95
; 	
;     return temp;
	movw R16,R20
	.dbline -2
L13:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r temp1 22 c
	.dbsym r temp 20 i
	.dbsym r address 10 c
	.dbend
	.dbfunc e vs1003_init _vs1003_init fV
	.even
_vs1003_init::
	.dbline -1
	.dbline 99
; }
; 
; void vs1003_init(void)
; {
	.dbline 100
; 	vs1003_cmd_write(0x00,0x0800);    	//NEW MODE
	ldi R18,2048
	ldi R19,8
	clr R16
	xcall _vs1003_cmd_write
	.dbline 101
; 	vs1003_cmd_write(0x0b,0X1010);    	//VOLUME
	ldi R18,4112
	ldi R19,16
	ldi R16,11
	xcall _vs1003_cmd_write
	.dbline 102
; 	vs1003_cmd_write(0x02,0X1fff);     	//BASS
	ldi R18,8191
	ldi R19,31
	ldi R16,2
	xcall _vs1003_cmd_write
	.dbline 103
; 	vs1003_cmd_write(0x03,0X4000);     	//CLOCK F
	ldi R18,16384
	ldi R19,64
	ldi R16,3
	xcall _vs1003_cmd_write
	.dbline -2
L14:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -