共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网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
vscode+cmake搭建雅特力AT32L021开发环境被打赏30分 | |
【换取逻辑分析仪】自制底板并驱动ArduinoNanoRP2040ConnectLCD扩展板被打赏47分 | |
【分享评测,赢取加热台】RISC-V GCC 内嵌汇编使用被打赏38分 | |
【换取逻辑分析仪】-基于ADI单片机MAX78000的简易MP3音乐播放器被打赏48分 | |
我想要一部加热台+树莓派PICO驱动AHT10被打赏38分 | |
【换取逻辑分析仪】-硬件SPI驱动OLED屏幕被打赏36分 | |
换逻辑分析仪+上下拉与多路选择器被打赏29分 | |
Let'sdo第3期任务合集被打赏50分 | |
换逻辑分析仪+Verilog三态门被打赏27分 | |
换逻辑分析仪+Verilog多输出门被打赏24分 |