s5pv210裸机串口无响应

程序代码如下,

#define GPC0CON        *((volatile unsigned int *)0xe0200060)

#define GPC0DAT*((volatile unsigned int *)0xe0200064)

 

#define GPA0CON*((volatile unsigned int *)0xe0200000)

#define GPA0DAT*((volatile unsigned int *)0xe0200004)

#define ULCON1          *((volatile unsigned int *)0xe2900400)

#define UCON1 *((volatile unsigned int *)0xe2900404)

#define UFCON1          *((volatile unsigned int *)0xe2900408)

#define UMCON1         *((volatile unsigned int *)0xe290040c)

#define UTRSTAT          *((volatile unsigned int *)0xe2900410)

#define UERSTAT          *((volatile unsigned int *)0xe2900414)

#define UFSTAT1          *((volatile unsigned int *)0xe2900418)

#define UMSTAT1         *((volatile unsigned int *)0xe290041c)

#define UTXH1 *((volatile unsigned int *)0xe2900420)

#define URXH1 *((volatile unsigned int *)0xe2900424)

#define UBRDIV1          *((volatile unsigned int *)0xe2900428)

#define UDIVSLOT        *((volatile unsigned int *)0xe290042c)

#define UINTP1 *((volatile unsigned int *)0xe2900430)

#define UINTSP1           *((volatile unsigned int*)0xe2900434)

#define UINTM1            *((volatile unsigned int*)0xe2900438)

 

void delay(volatileunsigned int t)

{

            volatile unsigned int base = 0xa000;

            while(t--)

            {

                        for(base=0xa000;base;--base);

            }

}

 

voidled_tip(unsigned int control)

{

            volatile unsigned int temp;

            if(control==0x03)/*灯1闪烁*/

            {

                        temp = ~GPC0DAT;

                        temp ^= ~(1<<3);

                        GPC0DAT = temp;

                        delay(4);

            }

            else if(control==0x0a)/*灯2闪烁*/

            {

                        temp = ~GPC0DAT;

                        temp ^= ~(1<<4);

                        GPC0DAT = temp;

                        delay(4);

            }

            else if(control==0x30)/*双灯交替闪烁*/

            {

                        GPC0DAT = 0x08;

                        delay(2);

                        GPC0DAT = 0x10;

                        delay(2);

            }

            else if(control==0xa0)/*双灯同闪*/

            {

                        GPC0DAT = 0x18;

                        delay(2);

                        GPC0DAT = 0;

                        delay(2);

            }

}

 

void led_init()

{

            GPC0CON |= 0x11<<12;

}

 

void uart_init()

{

            GPA0CON = 0x00220000;

            ULCON1 = 0x00000003;

            UCON1 = 0x00000005;

            UFCON1 = 0x00000001;

            UMCON1 = 0;

 

            UBRDIV1 = 34;

            UDIVSLOT = 0xdfdd;

}

 

static voidsend_byte(volatile unsigned char byte)

{

            while((UFSTAT1 &(1<<24)));

            UTXH1=byte;

}

 

static volatileunsigned char recv_byte()

{

            while(!(UFSTAT1 & 0xff))

            {

                        led_tip(0x03);

            }

            return URXH1;

}

 

voidputchar(volatile unsigned char c)

{

            send_byte(c);

            if(c=='\n') send_byte('\r');

}

 

volatile unsignedchar getchar()

{

            volatile unsigned char c;

            c = recv_byte();

            return c;

}

 

void puts(volatilechar *str)

{

            volatile char *p = str;

            while(*p) putchar(*p++);

            putchar('\n');

}

 

void uart()

{

            volatile unsigned char c;

            volatile unsigned int temp;

 

            led_init();

            uart_init();

 

            puts("puts your key and thelight will be changed");

            puts("1 led1");

            puts("2 led2");

 

            while(1)

            {

                        c = getchar();

                        putchar(c);

                        putchar('\r');

 

                        if(c=='1')

                        {

                                    //temp =GPC0DAT & (0x1<<3);

                                    //temp^=0;

                                    GPC0DAT =0x10;

                        }

                        else if(c=='2')

                        {

                                    //temp =GPC0DAT & (0x1<<4);

                                    //temp^=0;

                                    //GPC0DAT&= temp;

                                    GPC0DAT =0x08;

                        }

                        else

                        {

                                    GPC0DAT =0x18;

                        }

                        led_tip(0x0a);

            }

}

这里出现的问题就是,

串口可以输出提示信息,但是对于输入没有任何的反应,经过点灯的调试,知道在接收的函数里面一直循环等待,uart()函数里面的while循环里面的点灯测试程序是没有机会运行的。现在发现输入1、2和发送字符1、2板子上的灯是有反应的,但是,输入的字符并没有显示出来,这是为什么?

好吧,我现在发现这个错误了,尴尬并且表示非常的吃惊!问题代码如下,


不知道为什么,这个地方需要换成’\n’或者不用,在后面判断,最后的else是我现在才加的,不需要看。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值