阅读:2118回复:9
关于串口和IrDA通信
Hello, everyone:
Does any one use the assabet1110? i made a assamble program to control the IrDA port(COM3=serial 2) of it. but something strange happend. when i sent 0x36, i received 0xb7. when i sent 0xb7, i received still 0xb7; when i sent 0x00, i received 0xff. when i sent 0xff, i received still 0xff!!!God!!! please help me on this problem. the following is my code: AREA Port3, CODE, READONLY ; name this block of code COM3_UTCR0 EQU 0x80030000 ;base address in the physical map COM3_UTCR1 EQU 0x80030004 ; COM3_UTCR2 EQU 0x80030008 ; COM3_UTCR3 EQU 0x8003000C ; COM3_UTCR4 EQU 0x80030010 ; COM3_UTDR EQU 0x80030014 ; COM3_UTSR1 EQU 0x80030020 ; BCR EQU 0x12000000 ; ENTRY ; mark the first instruction to call start ; get the BCR register address ldr r3, =BCR mov r0, #0x00031000 str r0, [r3] ; SET BCR ldr r3, =COM3_UTCR0 mov r0, #0x08 str r0, [r3] ; SET COM3_UTCR0 ldr r3, =COM3_UTCR1 mov r0, #0x00 str r0, [r3] ; SET COM3_UTCR1 ldr r3, =COM3_UTCR2 mov r0, #23 ; SET BAUD= 9600 str r0, [r3] ; SET COM3_UTCR2 ldr r3, =COM3_UTCR3 mov r0, #0x03 str r0, [r3] ; SET COM3_UTCR3 ldr r3, =COM3_UTCR4 mov r0, #0x01 str r0, [r3] ; SET COM3_UTCR4 mov r1, #0x36 01 ldr r3, =COM3_UTDR str r1, [r3] ; Write Data to COM3 ldr r3, =COM3_UTSR1 03 ldr r0, [r3] and r0, r0, #0x01 cmp r0, #0 BNE %B03 ; loop until finish sending data ldr r5, =0x4000000 04 subs r5, r5, #1 bne %B04 ; Delay a while B %B01 stop MOV r0, #0x18 ; angel_SWIreason_ReportException LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit SWI 0x123456 ; ARM semihosting SWI END ; mark the end of this file |
|
沙发#
发布于:2002-11-08 10:45
红外模块的模式选择设置了吗?
我用linux下的汇编调过,但是时间长了看你的程序有点晕。 选择低速模式时uart波特率的设置于串口方式是一样的,但对红外通道还要对红外的寄存器操作(具体是什么忘了)。 |
|
板凳#
发布于:2002-11-08 14:25
多谢你的回复,我是新手,能否麻烦你再说得详细些呢? 多谢了!!!
|
|
地板#
发布于:2002-11-08 16:43
多谢你的回复,我是新手,能否麻烦你再说得详细些呢? 多谢了!!! 其实我也是新手,只是在几个月之前被逼用汇编调试过一个sa1110上的程序。 以下我的程序: /*ICP-HSSP Registers (Serial Port 2), based on 0x80040060*/ /* high speed use */ HSSP_BASE: .word 0x80040060 /* ICP-UART Registers (Serial Port 2), based on 0x80030000 */ SP2_BASE: .word 0x80030000 BCR_BASE: .long 0x12000000 BCR_BUFFER: .long 0xc1000000 /*----------------------------------------*/ /* Function begin */ /*----------------------------------------*/ .globl irda_low_init /* irda low speed, 1/3 Distance */ .globl irda_low_write .globl irda_low_read /* init irda into low speed mode , 1/3 Distance Power (uart mode)*/ irda_low_init: ldr r0, SP2_BASE mov r2, #0x8 /* 8 bit, no parity, 1 stop, internal clock */ str r2, [r0, #SP2_UTCR0 ] mov r2, #0x0 /* 9.6K baud */ str r2, [r0, #SP2_UTCR1 ] mov r2, #0x17 str r2, [r0, #SP2_UTCR2 ] mov r2, #0x00 str r2, [r0, #SP2_UTCR3 ] mov r2, #0x1 str r2, [r0, #SP2_UTCR4 ] ldr r0, HSSP_BASE /* enable low speed mode */ ldr r2, [r0, #HSCR0] and r2, r2, #0xfe str r2, [r0, #HSCR0] ldr r0, BCR_BASE /* mode select */ ldr r1, BCR_BUFFER ldr r2, [r1 ] orr r2, r2, #0x30 /* md0,1=1, fesl=0 */ and r2, r2, #0xfffffff7 str r2, [r1 ] str r2, [r0 ] ldr r0, SP2_BASE ldr r2, [r0, #SP2_UTCR3 ] /* enable Txd Rxd last */ orr r2, r2, #0x03 str r2, [r0, #SP2_UTCR3 ] mov pc, lr /* write a byte out form irda, using low speed mode, use r2 */ irda_low_write: ldr r0, SP2_BASE /* wait_trfifo: ldr r2, [r0, #SP2_UTSR1] tst r2, #0x04 beq wait_trfifo */ str r2, [r0, #SP2_UTDR] mov pc, lr /* read a byte from irda , when low sped mode, data transfer use r2 */ irda_low_read: ldr r0, SP2_BASE wait_refifo: ldr r2, [r0, #SP2_UTSR1] tst r2, #0x02 beq wait_refifo ldr r2, [r0, #SP2_UTDR] mov pc, lr |
|
地下室#
发布于:2002-11-09 16:08
问题解决,多谢!不过我发现红外口的速率只能在9600,无法改变成别的速率,是否如此呢?
|
|
5楼#
发布于:2002-11-11 14:02
应该不会,9600应该是最低速率
|
|
6楼#
发布于:2002-11-11 14:04
应该不会,最高应该能达到115200,
|
|
7楼#
发布于:2002-11-15 11:32
请问楼上的兄弟,在ASSABET1110中,在WINCE系统下怎样操作串口3?也就是SA1110的UART3
|
|
8楼#
发布于:2002-11-15 20:49
惭愧呀!没用过操作系统,俺是搞硬件的。
|
|
9楼#
发布于:2002-11-19 08:19
请问对于红外端口,他的接收端是否一直都处于判断是否有数据发送来的状态,因为当我把SA1110上的SERIAL PORT 2打开后,用示波器查看,不接任何信号,它的接收端都有信号?
|
|