Chinaunix首页 | 论坛 | 博客
  • 博客访问: 723058
  • 博文数量: 66
  • 博客积分: 2418
  • 博客等级: 大尉
  • 技术积分: 1659
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-28 10:04
个人简介

keep moving

文章分类

全部博文(66)

文章存档

2015年(2)

2014年(6)

2013年(7)

2011年(7)

2010年(42)

2009年(2)

分类: 嵌入式

2010-05-11 21:45:28

操作系统:Ubuntu9.04
内核版本:linux-2.6.24.7  
开发板:博创2410s及GPRS扩展模块(SIM100)    
交叉编译工具:arm-linux-gcc-4.1.1 
 
直接将博创2410s光盘资料里的GPRS实验源码编译后,下载到2.6内核的开发板上可以运行,但无法控制GPRS模块。下面我们来分析原因。
1、GPRS模块与s3c2410x芯片的连接电路
GPRS扩展模块(SIM100)与博创2410s开发板上的s3c2410x芯片的连接电路比较简单:GPRS扩展模块(SIM100)的GPRS-RXD和GPRS-TXD通过开发板上的168针扩展插槽,分别接到s3c2410x的引脚GPH6和GPH7,即s3c2410x串口2的TXD2和RXD2(3线连接法)。
2、s3c2410x的I/O端口简介
s3c2410x处理器芯片分为8个I/O端口Port A~Port H(GPA~GPH),117个多功能I/O端口引脚。串口2的TXD2和RXD2分别是Port H的第6个引脚(GPH6)和第7个引脚(GPH7)。
 
表1 I/O端口Port H各引脚可选的功能
      Port H                        Selectable Pin Functions
      GPH10    Input/output          CLKOUT1                    –           –
      GPH9     Input/output          CLKOUT0                    –           –
      GPH8     Input/output             UCLK                    –           –
      GPH7     Input/output             RXD2                 nCTS1          –
      GPH6     Input/output             TXD2                 nRTS1          –

      GPH5     Input/output             RXD1                    –           –
      GPH4     Input/output             TXD1                    –           –
      GPH3     Input/output             RXD0                    –           –
      GPH2     Input/output             TXD0                    –           –
      GPH1     Input/output            nRTS0                    –           –
      GPH0     Input/output            nCTS0                    –           –
 
由表1可知,引脚GPH6除了可做通用的I/O输入或输出外,还可作为TXD2、nRTS1(串口1的RTS);而引脚GPH7除了可做通用的I/O输入或输出外,还可作为RXD2、nCTS1(串口1的CTS)。I/O端口Port H各引脚的功能通过其控制寄存器GPHCON来设置,关于GPHCON控制寄存器各位的含义见表2
 
表2 I/O端口Port H的控制寄存器GPHCON
    GPHCON         Bit                   Description
     GPH10       [21:20]    00 = Input               01 = Output
                            10 = CLKOUT1             11 = Reserved
     GPH9        [19:18]    00 = Input               01 = Output
                            10 = CLKOUT0             11 = Reserved
     GPH8        [17:16]    00 = Input               01 = Output
                            10 = UCLK                11 = Reserved
     GPH7        [15:14]    00 = Input               01 = Output
                            10 = RXD2                11 = nCTS1
     GPH6        [13:12]    00 = Input               01 = Output
                            10 = TXD2                11 = nRTS1

     GPH5        [11:10]    00 = Input               01 = Output
                            10 = RXD1                11 = Reserved
     GPH4         [9:8]     00 = Input               01 = Output
                            10 = TXD1                11 = Reserved
     GPH3         [7:6]     00 = Input               01 = Output
                            10 = RXD0                11 = reserved
     GPH2         [5:4]     00 = Input               01 = Output
                            10 = TXD0                11 = Reserved
     GPH1         [3:2]     00 = Input               01 = Output
                            10 = nRTS0               11 = Reserved
     GPH0         [1:0]     00 = Input               01 = Output
                            10 = nCTS0               11 = Reserved
 
linux2.6.24.7内核将GPHCON寄存器的值置为0x16faaa(其它版本内核应该也是一样的,也可能不一样,你自己读取这个寄存器看看),就是说GPH6被设置为nRTS1,GPH7被设置为nCTS1,此时,串口2是无法收发数据的。而GPRS模块通过串口2与s3c2410通信,这就是我们为什么直接运行GPRS实验程序无法控制GPRS模块的原因!解决方法很简单将GPH6设为TXD2、GPH7设为RXD2,问题就解决了!
在运行GPRS实验程序前,先编译以下模块,然后将模块insmod加载到内核中,再运行GPRS实验程序就ok了
 

#include <asm/arch/regs-gpio.h>
#include <asm/io.h>
#include <linux/module.h>

static unsigned int old_gphcon = 0;

static int __init uart2_module_init(void)
{
    unsigned int gphcon;

    old_gphcon = ioread32(S3C2410_GPHCON);
    gphcon = old_gphcon & ~((0x5) << 12);
    iowrite32(gphcon, S3C2410_GPHCON);

    printk("%s : old GPHCON = %x, new GPHCON = %x\n",
        __FUNCTION__, old_gphcon, gphcon);
    printk("uart2 init complete!\n");

    return 0;
}

static void __exit uart2_module_exit(void)
{
    iowrite32(old_gphcon, S3C2410_GPHCON);
    printk("uart2 exit!\n");
}

module_init(uart2_module_init);
module_exit(uart2_module_exit);
MODULE_AUTHOR("lingd");
MODULE_LICENSE("GPL");

实验结果

root@lingd-arm2410s:/tmp/basic/pc_gprs# insmod uart2.ko
uart2_module_init : old GPHCON = 16faaa, new GPHCON = 16aaaa
uart2 init
root@lingd-arm2410s:/tmp/basic/pc_gprs# ./gprs
  Default baudrate is 9600 bps. If not, please enter the baudrate as a parameter

read modem
at


OK

ate1


OK

at+chfa=1


SWITCHED AUX AUDIO



OK

at+clvl=100


OK

at+cmic=1,10


OK


<gprs control shell>
 [1] give a call
 [2] respond a call
 [3] hold a call
 [4] send a msg
 [5] exit
 [*] help menu
keyshell> 5
5

exit gprs
root@lingd-arm2410s:/tmp/basic/pc_gprs# rmmod uart2.ko
uart2


阅读(2342) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

clever07252010-08-03 14:48:55

兄弟能不能上传下 应用程序的代码 谢谢了 或者邮箱11051410#qq.com #define # @