Chinaunix首页 | 论坛 | 博客
  • 博客访问: 621878
  • 博文数量: 837
  • 博客积分: 425
  • 博客等级: 下士
  • 技术积分: 1439
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-20 19:57
个人简介

对技术执着

文章分类

全部博文(837)

文章存档

2018年(2)

2015年(735)

2013年(85)

2012年(15)

我的朋友

分类: LINUX

2015-03-14 16:55:37

作者:赵孝强,华清远见嵌入式培训中心讲师。

以下是s5pc100的不带系统串口的程序,需要map.lds,Makefile,s5pc100,文件,用v7交叉工具链,以上文件可在www.farsight.com.cn下载到。

#include "s5pc100.h"
        unsigned char *p = "farsight test uart program !";
        void uart_sendbyte(unsigned char data)
        {
                UART0.UTXH0 = data;
                while(!(UART0.UTRSTAT0 & 0X2));
        }
        void uart_sendstring(const unsigned char *pstr)
        {
                while(*pstr != '\0')
                uart_sendbyte(*pstr++);
        }
        int main()
        {
                unsigned int temp = 0;
                GPA0.GPA0CON = 0X22;        // set gpa0 uart mode
                UART0.UFCON0 = 0X00;        //UART channel 0 FIFO control register, FIFO disable
                UART0.UMCON0 = 0X00;        //UART chaneel 0 MODEM control register, AFC disable
                UART0.ULCON0 = 0X03;        //per frame 8 bin
                UART0.UCON0 = 0X305;        //
                UART0.UBRDIV0 = 0X23;        // Baud rate divisior register 0
        //      UART0.UDIVSLOT0 = 0X3;
                GPG3.GPG3DAT = 0X00;
                uart_sendstring(p);
                while(1)
                {
                        while(!(UART0.UTRSTAT0 & 0X1));
                        uart_sendstring("your enter char is");
                        uart_sendbyte('\n');
                        GPG3.GPG3DAT = 0XF;
                        temp = UART0.URXH0;
                        UART0.UTXH0 = temp;
                        while(!(UART0.UTRSTAT0 & 0X2));
                        uart_sendbyte('\n');
                        GPG3.GPG3DAT = 0X0;
                        for(temp = 1000000; temp !=0; temp--);
                }
                return 0;
        }

阅读(211) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册