|
要把binary output result 通过max232传进comp port 要怎么做? |
|
|
|
|
|
|
|
发表于 27-11-2006 01:41 PM
|
显示全部楼层
原帖由 w0t3rf15h 于 26-11-2006 09:20 PM 发表
要把binary output result 通过max232传进comp port 要怎么做?
假设你的connection对。rx---->tx. tx--->rx.
for pic, 用usart.
这里是那些subroutine.希望可以帮到你。
serial init 是intialization.
serial receive是从serial port receive data
serial send就是send data给你的serial port.
我全部用polling.没有interrupt.就是说, 当你要send data or receive data的时候, 就要call那个function.
void serial_init (void)
{
TRISC = 0x80; //set data directiob for rx tx
SPBRG = 0x81; //set baudrate
TXSTA = 0x24;
RCSTA = 0x90;
}
void serial_receive (void)
{
while (PIR1.RCIF == 0);
RXBUF = RCREG;
}
void serial_send (char TXBUF)
{
while (TXSTA.TRMT == 0);
TXREG = TXBUF;
}
for 8051, 用uart.
void serial_init (void)
{
TMOD = 0x21; // set timer 1 to 8bit auto reload mode.
SCON = 0x52; //mode1. 8 bit uart. variable boudrate.
PCON = 0x80; //double the baudrate
TH1 = 0xFF; //baudrate = 57600
}
void SerialSend (unsigned char dataout)
{
while (!TI);
SBUF = dataout;
TI = 0;
}
void SerialReceive1 (void)
{
RI = 0;
while (RI == 0);
datain = SBUF;
} |
|
|
|
|
|
|
|
发表于 28-11-2006 03:44 PM
|
显示全部楼层
where can buy max232?
can i ask where can buy it?
u now about max7221/max7219 for LED display?
thank!!! |
|
|
|
|
|
|
|
发表于 28-11-2006 03:50 PM
|
显示全部楼层
原帖由 charlaspoh 于 28-11-2006 03:44 PM 发表
can i ask where can buy it?
u now about max7221/max7219 for LED display?
thank!!!
max232那里都有卖。。。。。。。。。。。。。。。 |
|
|
|
|
|
|
|
楼主 |
发表于 29-11-2006 01:37 PM
|
显示全部楼层
原帖由 w0t3rf15h 于 26-11-2006 09:20 PM 发表
要把binary output result 通过max232传进comp port 要怎么做?
data send when trmt=0 ,=tsr full (wat mean)?
not set txen=1 meh??
and i jz wan to send not need feedback
so the
void serial_receive (void)
{
while (PIR1.RCIF == 0);
RXBUF = RCREG;
}
is no need ad rite?
and wat i write is it rite>?
main
bcf STATUS,RP0
movlw b_tris
movwf TRISB
movlw c_tris
movwf TRISC
bcf STATUS,RP0
banksel TXSTA ;initialize UART
movlw B'00100100' ;select high speed baud rate BRGH=1
movwf TXSTA
banksel SPBRG ;initialize baud rate generator for
movlw D'25' ;9600 bps
movwf SPBRG
loop
call loop1
goto loop
LOOP1
MOVF PORTB,W
SUBLW B'0000"
BTFSC STATUS,Z
CALL send1
send1
movlw H'0'
movwf TXREG
goto wait
return
wait
btfsc txsta,txen
goto wait
return
end |
|
|
|
|
|
|
|
发表于 29-11-2006 01:48 PM
|
显示全部楼层
原帖由 w0t3rf15h 于 29-11-2006 01:37 PM 发表
data send when trmt=0 ,=tsr full (wat mean)?
not set txen=1 meh??
and i jz wan to send not need feedback
so the
void serial_receive (void)
{
while (PIR1.RCIF == 0);
RXBUF = ...
对, 那个不用。 哪个是拿来receive from serial port的。
asm忘到七七八八了。。。。。。。回家找找看,我以前有写过。 |
|
|
|
|
|
|
|
楼主 |
发表于 30-11-2006 04:49 PM
|
显示全部楼层
原帖由 fritlizt 于 29-11-2006 01:48 PM 发表
对, 那个不用。 哪个是拿来receive from serial port的。
asm忘到七七八八了。。。。。。。回家找找看,我以前有写过。
好,等你好消系 |
|
|
|
|
|
|
|
发表于 1-12-2006 12:56 AM
|
显示全部楼层
原帖由 w0t3rf15h 于 30-11-2006 04:49 PM 发表
好,等你好消系
哈哈。给不到你。
我看回asm code我也不懂自己在写什么了。paiseh,.
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|