📄 main.s
字号:
.module main.c
.area data(ram, con, rel)
_PaTabel::
.blkb 2
.area idata
.byte 192,192
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 192,192
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 192,192
.area data(ram, con, rel)
.blkb 2
.area idata
.byte 192,192
.area data(ram, con, rel)
.dbfile E:\学习基地\IMPORT~1\CC1100-RF-Design\M8_RF_CC1100开发系统光盘\驱动程序\M8_cc1100_receive\main.c
.dbsym e PaTabel _PaTabel A[8:8]c
.area text(rom, con, rel)
.dbfile E:\学习基地\IMPORT~1\CC1100-RF-Design\M8_RF_CC1100开发系统光盘\驱动程序\M8_cc1100_receive\main.c
.dbfunc e main _main fV
.even
_main::
sbiw R28,1
.dbline -1
.dbline 50
; /*C**************************************************************************
; * NAME: main.c
; *----------------------------------------------------------------------------
; * Copyright (c) 2006 endylu
; *----------------------------------------------------------------------------
; * RELEASE: M8-cc1100
; * REVISION: 1.0
; *----------------------------------------------------------------------------
; * PURPOSE:
; * This is the demonstration software for MAGE8L
; *****************************************************************************/
;
; /*_____ I N C L U D E S ____________________________________________________*/
;
; #include <iom8v.h>
; #include <macros.h>
; #include "main.h"
;
;
; /*_____ M A C R O S ________________________________________________________*/
;
;
; /*_____ D E F I N I T I O N ________________________________________________*/
;
; INT8U PaTabel[8] = {0xC0 ,0xC0 ,0xC0 ,0xC0 ,0xC0 ,0xC0 ,0xC0 ,0xC0};
; INT8U arrRx[50];
;
; INT8U length;
; INT8U flag_receive;
; /*_____ D E C L A R A T I O N ______________________________________________*/
;
;
; /*F**************************************************************************
; * NAME: main
; *----------------------------------------------------------------------------
; * PARAMS:
; *
; * return:
; *----------------------------------------------------------------------------
; * PURPOSE:
; * Main user routine
; *----------------------------------------------------------------------------
; * EXAMPLE:
; *----------------------------------------------------------------------------
; * NOTE:
; *----------------------------------------------------------------------------
; * REQUIREMENTS:
; *****************************************************************************/
; void main (void)
; {
.dbline 51
; PORTD|=0X04; //GDO0上拉
sbi 0x12,2
.dbline 53
;
; DDRB|=1<<LED2;
sbi 0x17,1
.dbline 54
; PORTB|=1<<LED2;
sbi 0x18,1
.dbline 56
;
; CpuInit();
rcall _CpuInit
.dbline 57
; POWER_UP_RESET_CC1100();
rcall _POWER_UP_RESET_CC1100
.dbline 58
; halRfWriteRfSettings();
rcall _halRfWriteRfSettings
.dbline 59
; halSpiWriteBurstReg(CCxxx0_PATABLE, PaTabel, 8);
ldi R24,8
std y+0,R24
ldi R18,<_PaTabel
ldi R19,>_PaTabel
ldi R16,62
rcall _halSpiWriteBurstReg
.dbline 60
; PORTB&=~(1<<LED2);
cbi 0x18,1
.dbline 62
;
; INT0_Init();
rcall _INT0_Init
.dbline 63
; asm("sei"); //开全局中断
sei
.dbline 65
;
; halSpiStrobe(CCxxx0_SRX);
ldi R16,52
rcall _halSpiStrobe
L2:
.dbline 66
L3:
.dbline 66
rjmp L2
X0:
.dbline -2
L1:
adiw R28,1
.dbline 0 ; func end
ret
.dbend
.dbfunc e INT0_Init _INT0_Init fV
.even
_INT0_Init::
.dbline -1
.dbline 76
; while(1);
; }
;
; /*****************************************************************************************
; //函数名:void INT0_Init(void)
; //输入:无
; //输出:无
; //功能描述:外部中断0 初始化程序
; /*****************************************************************************************/
; void INT0_Init(void)
; {
.dbline 77
; MCUCR|=0x02; //falling_adge
in R24,0x35
ori R24,2
out 0x35,R24
.dbline 78
; GIFR=0X40;
ldi R24,64
out 0x3a,R24
.dbline 79
; INT0_enable();
.dbline 79
in R24,0x3b
ori R24,64
out 0x3b,R24
.dbline 79
.dbline 79
.dbline -2
L5:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 2
rjmp _int0
.area text(rom, con, rel)
.dbfile E:\学习基地\IMPORT~1\CC1100-RF-Design\M8_RF_CC1100开发系统光盘\驱动程序\M8_cc1100_receive\main.c
.dbfunc e int0 _int0 fV
; status -> y+1
; i -> R20
.even
_int0::
rcall push_lset
rcall push_gset1
sbiw R28,3
.dbline -1
.dbline 91
; }
;
;
; //*****************************************************************************************
; //函数名:
; //输入:
; //输出:
; //功能描述:中断接收
; //*****************************************************************************************
; #pragma interrupt_handler int0:2
; void int0(void)
; {
.dbline 95
; uint8 i;
; uint8 status[2];
;
; flag_receive=RECEIVE_error;
ldi R24,2
sts _flag_receive,R24
.dbline 96
; if(halSpiReadStatus(CCxxx0_RXBYTES) & BYTES_IN_RXFIFO)//如果接的字节数不为0
ldi R16,59
rcall _halSpiReadStatus
mov R24,R16
andi R24,127
breq L7
.dbline 97
; {
.dbline 98
; length = halSpiReadReg(CCxxx0_RXFIFO);//读出第一个字节,此字节为该帧数据长度
ldi R16,63
rcall _halSpiReadReg
sts _length,R16
.dbline 99
; halSpiReadBurstReg(CCxxx0_RXFIFO, arrRx, length); //读出所有接收到的数据
mov R2,R16
std y+0,R2
ldi R18,<_arrRx
ldi R19,>_arrRx
ldi R16,63
rcall _halSpiReadBurstReg
.dbline 100
; halSpiReadBurstReg(CCxxx0_RXFIFO, status, 2); //读出CRC校验位
ldi R24,2
std y+0,R24
movw R18,R28
subi R18,255 ; offset = 1
sbci R19,255
ldi R16,63
rcall _halSpiReadBurstReg
.dbline 102
;
; if(status[1] & CRC_OK)
ldd R2,y+2
sbrs R2,7
rjmp L9
.dbline 103
; {
.dbline 104
; flag_receive=RECEIVE_OK;
ldi R24,1
sts _flag_receive,R24
.dbline 106
;
; PORTB|=1<<LED2;
sbi 0x18,1
.dbline 107
; for(i=2;i<length;i++)
ldi R20,2
rjmp L15
L12:
.dbline 108
.dbline 109
ldi R24,<_arrRx
ldi R25,>_arrRx
mov R30,R20
clr R31
add R30,R24
adc R31,R25
ldd R16,z+0
clr R17
rcall _putchar
.dbline 110
L13:
.dbline 107
inc R20
L15:
.dbline 107
lds R2,_length
cp R20,R2
brlo L12
.dbline 111
; {
; putchar(arrRx[i]);
; }
; Delay_ms(100);
ldi R16,100
ldi R17,0
rcall _Delay_ms
.dbline 112
; PORTB&=~(1<<LED2);
cbi 0x18,1
.dbline 113
; }
L9:
.dbline 114
; }
L7:
.dbline 115
; halSpiStrobe(CCxxx0_SFRX); //清洗接收缓冲区
ldi R16,58
rcall _halSpiStrobe
.dbline 116
; halSpiStrobe(CCxxx0_SRX);
ldi R16,52
rcall _halSpiStrobe
.dbline -2
L6:
adiw R28,3
rcall pop_gset1
rcall pop_lset
.dbline 0 ; func end
reti
.dbsym l status 1 A[2:2]c
.dbsym r i 20 c
.dbend
.dbfunc e Delay_us _Delay_us fV
; time -> R16,R17
.even
_Delay_us::
.dbline -1
.dbline 120
L17:
.dbline 120
L18:
.dbline 120
; }
;
; void Delay_us(uint16 time) //set time 120 to 100us,set 1 to 3.5us;
; {while (time--);
movw R2,R16
subi R16,1
sbci R17,0
tst R2
brne L17
tst R3
brne L17
X1:
.dbline 121
; _WDR();
wdr
.dbline -2
L16:
.dbline 0 ; func end
ret
.dbsym r time 16 i
.dbend
.dbfunc e Delay_ms _Delay_ms fV
; time -> R20,R21
.even
_Delay_ms::
rcall push_gset1
movw R20,R16
.dbline -1
.dbline 124
; }
; void Delay_ms(uint16 time)
; {while (time--)
rjmp L22
L21:
.dbline 125
ldi R16,1200
ldi R17,4
rcall _Delay_us
L22:
.dbline 124
movw R2,R20
subi R20,1
sbci R21,0
tst R2
brne L21
tst R3
brne L21
X2:
.dbline -2
L20:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r time 20 i
.dbend
.area bss(ram, con, rel)
.dbfile E:\学习基地\IMPORT~1\CC1100-RF-Design\M8_RF_CC1100开发系统光盘\驱动程序\M8_cc1100_receive\main.c
_flag_receive::
.blkb 1
.dbsym e flag_receive _flag_receive c
_length::
.blkb 1
.dbsym e length _length c
_arrRx::
.blkb 50
.dbsym e arrRx _arrRx A[50:50]c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -