共2条
1/1 1 跳转至页
nbsp,nbsp,MAX3100,nbsp,nbsp 求教求教 关于MAX3100的问题 急~~~高手帮忙
问
最近由于串口不够用 需要扩展一个 人家建议用MAX3100来扩展 以前没有接触过 资料上放出来的汇编看了看 貌似有点不通 请高手帮忙做一个C的初始化和传送协议。。。。
放出资料上的汇编
;IrDA CODE FOR MAX-3100 UART-8051 based
;************************************************
;CONSTANTS
;PORT PIN DEFINITIONS-BIN BANGING IF
DOUT BIT p1.0 ;data out (from uart)
DIN BIT p1.1 ;data in (from uart)
SCLK BIT p1.2 ; clock
CS BIT p1.3 ;chip select-act low
IRQ BIT p3.2 ;(irq)polled in this code
;RAM LOCATIONS
TX1 EQU 10H ;transmit regs
TX2 EQU 11H
RX1 EQU 12H ;RECEIVE REGS
RX2 EQU 13H
;***************************************************
ORG 0H
BEGIN:MOV SP,#70H ;initialize stack
CLR SCLK ;clear sclk-normally low
;initialize 8051 interal uart
MOV TMOD,#20H ;t1 baud
MOV TH1,#253 ;reload value baud 9600/xtal 5.5M
MOV SCON,#50H ;uart-m1.tx and rx
MOV PCON,#80H ;double baud rate bit
MOV TCON,40H ;start baud timer
;initialize max3100 uart-irda mode at 9600 baud
MOV TX1,#0E4H ;high byte of config-R ints
MOV TX2,#0CAH ;9600 baud irda mode and two stops
CALL UTLK ;send to uart - write config
;********************** MAIN ROUTINE LOOP *********************
LOOP:JNB IRQ,URCV ;data avail from 3100 uart? IRQ为0 输出
NRECV:JBC RI,RCV51 ;check for 8051 rcv- tx out irda
JMP LOOP ;hang here forever
;byte recieved from 3100 uart- get it and send out 8051 uart
URCV:MOV TX1,#0 ;read data
MOV TX2,#0 ;read data
CALL UTLK ;send to 8051 uart -get data to rx
MOV A,RX2 ;get data to acc
MOV SBUF,A ;send out rs-232 side 9600 baud
JMP LOOP ;BACK TO TOP
;byte recieved from 8051 uart- get it and sent 3100uart
RCV51:MOV A,SBUF ;data from 8-51 uart
MOV TX1,#80H ;tx data
MOV TX2,A ;data to irda
CALL UTLK ;send to uart-send data out IRDA
JMP LOOP ;back to top
;**********************************************************
;******SUBROUTINES
;*****UTLK -talk to uart-main routine
;******send 16bits from TX1 TX2 and rov 16 to RX1 RX2
UTLK:CLR CS ;activate cs
MOV A,TX1 ;get high byte
CALL BYT8 ;SEND OUT
MOV RX2,A ;get recevied 2
SETB CS ;set cs high
RET ;DONE
;*********************************
;**BYT8- SHIFT OUT &IN 8 BITS WITH SPI CLOCKING -FROM AND TO ACC
BYT8:MOV R4,#8 ;8 bits to send
SETB DIN ;make sure din is input
B8LP: RLC A ;get msb of acc to carry
MOV DOUT,C ;OUT OU T ON PIN
SETB SCLK ;CLOCK HIGH-CLOCK
MOV C,DIN ;get data after clk high
CLR SCLK ;clock low
MOV ACC.0,C ;put in lsbit of a
DJNZ R4,B8LP ;loop til 8bits
RET ;done
;*****end of
END
不知道他开串口干什么。。。貌似没有用到串口啊。。。希望有高手指点我
拜师~~~~ 答 1: 希望有用过的达人路过 顺便贴下程序短短的 没多少。。。希望帮忙啦
放出资料上的汇编
;IrDA CODE FOR MAX-3100 UART-8051 based
;************************************************
;CONSTANTS
;PORT PIN DEFINITIONS-BIN BANGING IF
DOUT BIT p1.0 ;data out (from uart)
DIN BIT p1.1 ;data in (from uart)
SCLK BIT p1.2 ; clock
CS BIT p1.3 ;chip select-act low
IRQ BIT p3.2 ;(irq)polled in this code
;RAM LOCATIONS
TX1 EQU 10H ;transmit regs
TX2 EQU 11H
RX1 EQU 12H ;RECEIVE REGS
RX2 EQU 13H
;***************************************************
ORG 0H
BEGIN:MOV SP,#70H ;initialize stack
CLR SCLK ;clear sclk-normally low
;initialize 8051 interal uart
MOV TMOD,#20H ;t1 baud
MOV TH1,#253 ;reload value baud 9600/xtal 5.5M
MOV SCON,#50H ;uart-m1.tx and rx
MOV PCON,#80H ;double baud rate bit
MOV TCON,40H ;start baud timer
;initialize max3100 uart-irda mode at 9600 baud
MOV TX1,#0E4H ;high byte of config-R ints
MOV TX2,#0CAH ;9600 baud irda mode and two stops
CALL UTLK ;send to uart - write config
;********************** MAIN ROUTINE LOOP *********************
LOOP:JNB IRQ,URCV ;data avail from 3100 uart? IRQ为0 输出
NRECV:JBC RI,RCV51 ;check for 8051 rcv- tx out irda
JMP LOOP ;hang here forever
;byte recieved from 3100 uart- get it and send out 8051 uart
URCV:MOV TX1,#0 ;read data
MOV TX2,#0 ;read data
CALL UTLK ;send to 8051 uart -get data to rx
MOV A,RX2 ;get data to acc
MOV SBUF,A ;send out rs-232 side 9600 baud
JMP LOOP ;BACK TO TOP
;byte recieved from 8051 uart- get it and sent 3100uart
RCV51:MOV A,SBUF ;data from 8-51 uart
MOV TX1,#80H ;tx data
MOV TX2,A ;data to irda
CALL UTLK ;send to uart-send data out IRDA
JMP LOOP ;back to top
;**********************************************************
;******SUBROUTINES
;*****UTLK -talk to uart-main routine
;******send 16bits from TX1 TX2 and rov 16 to RX1 RX2
UTLK:CLR CS ;activate cs
MOV A,TX1 ;get high byte
CALL BYT8 ;SEND OUT
MOV RX2,A ;get recevied 2
SETB CS ;set cs high
RET ;DONE
;*********************************
;**BYT8- SHIFT OUT &IN 8 BITS WITH SPI CLOCKING -FROM AND TO ACC
BYT8:MOV R4,#8 ;8 bits to send
SETB DIN ;make sure din is input
B8LP: RLC A ;get msb of acc to carry
MOV DOUT,C ;OUT OU T ON PIN
SETB SCLK ;CLOCK HIGH-CLOCK
MOV C,DIN ;get data after clk high
CLR SCLK ;clock low
MOV ACC.0,C ;put in lsbit of a
DJNZ R4,B8LP ;loop til 8bits
RET ;done
;*****end of
END
不知道他开串口干什么。。。貌似没有用到串口啊。。。希望有高手指点我
拜师~~~~ 答 1: 希望有用过的达人路过 顺便贴下程序短短的 没多少。。。希望帮忙啦
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |