北斗星君 发表于 2007-12-13 21:30:10

关于模拟USART的问题

我现在用的是skyeye 1.23。

最近在调试 USART的读写程序(个人按照手册的提示写的)
但是我这边因为用的是笔记本,所以没有 串行口 因此,我想问一下如何使用键盘作为USART的输入,终端作为USART的输出。或者以普通文件作为USART的输入和输出。

谢谢赐教。

另外,想问一下,如何在skyeye中人为模拟产生硬件中断信号,比如CPU进入休眠状态,那么人为的在skyeye中模拟一个外部中断信号来将CPU唤醒,请问这个唤醒的外部中断如何在skyeye中模拟?

ksh 发表于 2007-12-14 16:54:42

1. 当前skyeye默认用键盘和终端来作为usart的模拟输入和输出。具体代码在device/uart/skyeye_uart_stdio.c
2. 在每一个开发板模拟代码中的io_do_cycle函数,如skyeye_mach_ep7312.c的io_do_cycle函数。设置中断标志,并且跳转PC到中断处理函数

北斗星君 发表于 2007-12-15 17:29:15

可是我这边的代码无法被正常执行。

我的C代码如下


void app(void){
long* USART_THR=(long*)0xfffd001c;
long* USART_RHR=(long*)0xfffd0018;
long* USART_CSR=(long*)0xfffd0014;
long stat;
while(1){
    stat=*USART_CSR;
    if(stat&0x001){
      *USART_THR='M';
    }
}
while(1);
return;
}


我的skyeye的配置文件

#skyeye config file sample
cpu: arm7tdmi

mach: at91

mem_bank: map=M,type=RW,addr=0x01000000,size=0x00400000,file=app.bin,boot=yes
mem_bank: map=I,type=RW,addr=0xf0000000,size=0x10000000
log: logon=0,logfile=./sk1.log,start=0,end=200000


当我向用键盘输入时,什么也没反应。可是按照代码,我每次输入都应该输出一个M的。

ksh 发表于 2007-12-17 10:27:55

Please read helloworld example in this board.
http://www.linuxfans.org/bbs/thread-82187-1-1.html
You will get some idea from it.

北斗星君 发表于 2007-12-20 20:55:23

那个我看过了,我的代码是按照手册上来的。应该没有问题的。

而且,我可以在屏幕上输出数据,但是,不能从键盘读数据

ksh 发表于 2007-12-21 10:32:46

Try to debug it. I also think that should not be the mistake of SkyEye. At least uCos and uClinux for at91 can run correctly on SkyEye.

北斗星君 发表于 2007-12-22 22:33:17

调试过了,代码没有问题。那如果既不是我的问题,按照KSH的说法,也不是skyeye的问题~,那这个是谁的问题呢?
我觉得推卸责任不是解决之道,不知道KSH接下来是不是又要说,It maybe the matter of your computer,.....???

ksh 发表于 2007-12-23 23:24:52

I read the source code of skyeye and datasheet. There is two issues:
1. Perhaps RCR register need to be initialized before read data to RHR. Is it necessary? I am not familiar with the usart of AT91. There is a description related to it:
RXCTR must be loaded with the size of the receive buffer.

2. The implementation of SkyEye also is not incompletely. CSR is not set correctly.

Thanks your report.

[ 本帖最后由 ksh 于 2007-12-24 00:01 编辑 ]

ksh 发表于 2007-12-23 23:59:08

回复 #5 北斗星君 的帖子

I read the source code of skyeye and datasheet. There is two issues:
1. Perhaps RCR register need to be initialized before read data to RHR. Is it necessary? I am not familiar with the usart of AT91. There is a description related to it:
RXCTR must be loaded with the size of the receive buffer.

2. The implementation of SkyEye also is not incompletely. CSR is not set correctly.

Thanks your report.
页: [1]
查看完整版本: 关于模拟USART的问题