GNU ARM汇编--(七)s3c2440的串口控制
时间:11-26
来源:互联网
点击:
- ,=GPBDAT
- blclock_setup
- bluart_init
- bldelay
- ldrlr,=loop
- @bluart_testdd
- ldrpc,_uart_test
- _uart_test:.worduart_test
- loop:
- bloop@死循环
- ledloop:
- ldrr1,=0x1c0
- strr1,[r2]
- bldelay
- ldrr1,=0x1a0
- strr1,[r2]
- bldelay
- ldrr1,=0x160
- strr1,[r2]
- bldelay
- ldrr1,=0x0e0
- strr1,[r2]
- bldelay
- bledloop
- clock_setup:
- ldrr0,=LOCKTIME
- ldrr1,=0xffffffff
- strr1,[r0]
- ldrr0,=CLKdivN
- ldrr1,=(divN_UPLL<3)|(HdivN<1)|(PdivN<0)
- strr1,[r0]
- ldrr0,=UPLLCON
- ldrr1,=(U_Mdiv<12)|(U_Pdiv<4)|(U_Sdiv<0)@Fin=12MUPLL=48M
- strr1,[r0]
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- ldrr0,=MPLLCON
- ldrr1,=(M_Mdiv<12)|(M_Pdiv<4)|(M_Sdiv<0)@Fin=12MFCLK=400M
- strr1,[r0]
- movpc,lr
- uart_init:
- ldrr0,=GPHCON
- ldrr1,=0x2aaaa@配置GPIO复用规则为串口
- strr1,[r0]
- ldrr0,=ULCON0
- ldrr1,=(IR_MODE<6)|(Parity_Mode<3)|(Num_of_stop_bit<2)|(Word_length<0)@
- strr1,[r0]
- ldrr0,=UCON0
- ldrr1,=(FCLK_Div<12)|(Clk_select<10)|(Tx_Int_Type<9)|(Rx_Int_Type<8)|(Rx_Timeout<7)|(Rx_Error_Stat_Int<6)|(Loopback_Mode<5)|(Break_Sig<4)|(Tx_Mode<2)|(Rx_Mode<0)
- strr1,[r0]
- ldrr0,=UFCON0
- ldrr1,=(Tx_FIFO_Trig_Level<6)|(Rx_FIFO_Trig_Level<4)|(Tx_FIFO_Reset<2)|(Rx_FIFO_Reset<1)|(FIFO_Enable<0)@
- strr1,[r0]
- ldrr0,=UBRdiv0
- ldrr1,=(UBRdiv<0)
- strr1,[r0]
- movpc,lr
- delay:
- @ldrr3,=0x4ffffff
- ldrr3,=0xfffff
- delay1:
- subr3,r3,#1
- cmpr3,#0x0
- bnedelay1
- movpc,lr
UART的测试代码用C写的:
uart_test.c:
[cpp]view plaincopy
- #include"uart_test.h"
- charuart_GetByte(void)
- {
- while(!(rUTRSTAT0&0x1));//WaituntilTHRisempty.
- returnRdURXH0();
- }
- voiduart_GetString(char*pt)
- {
- while(*pt)
- uart_GetByte();
- }
- voiduart_SendByte(intdata)
- {
- if(data==)
- {
- while(!(rUTRSTAT0&0x2));
- WrUTXH0();
- }
- while(!(rUTRSTAT0&0x2));//WaituntilTHRisempty.
- WrUTXH0(data);
- }
- //====================================================================
- voiduart_SendString(char*pt)
- {
- while(*pt)
- uart_SendByte(*pt++);
- }
- voiduart_test(void)
- {
- charstr[20]="helloworld";
- inta=97;
- //while(1)
- //uart_SendByte(a);
- uart_SendString(str);
- chars=uart_GetByte();
- //if(s==a)
- if(s==97)
- rGPBDAT=0x1c0;
- //uart_SendByte(a);
- //uart_SendByte(97);
- //uart_SendByte(a);
- uart_SendByte((int)s);
- uart_SendByte((int)s);
- }
[cpp]view plaincopy
- //#defineWrUTXH0(ch)(*(volatileunsignedchar*)0x50000023)=(unsignedchar)(ch)
- #defineWrUTXH0(ch)(*(volatileunsignedchar*)0x50000020)=(unsignedchar)(ch)
- #defineRdURXH0()(*(volatileunsignedchar*)0x50000024)
- #definerUTRSTAT0(*(volatileunsigned*)0x50000010)//UART0Tx/Rxstatus
- #definerGPBDAT(*(volatileunsigned*)0x56000014)
到此,使用串口的轮循模式,可以实现串口的正常收发功能了~~
中断模式还没写,这个等到后面全面研究uboot的时候再回头看,uboot用哪种模式,应该就说明那种方式好,到时侯再实现吧
ARM汇编s3c2440串口控 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)