#include "s5pc100.h"
void putc(char c)
{
while (!(UART0.UTRSTAT0 & 0x2));
UART0.UTXH0 = c;
if (c == ‘\n‘) {
while (!(UART0.UTRSTAT0 & 0x2));
UART0.UTXH0 = ‘\r‘;
}
if (c == ‘\r‘) {
while (!(UART0.UTRSTAT0 & 0x2));
UART0.UTXH0 = ‘\n‘;
}
}
char getc(void)
{
while (!(UART0.UTRSTAT0 & 0x1));
return UART0.URXH0;
}
void puts(char *s)
{
while (*s != ‘\0‘)
putc(*s++);
}
int main()
{
char c;
GPA0.GPA0CON = 0x22;
UART0.ULCON0 = 0x03;
UART0.UCON0 = 0x05;
UART0.UFCON0 = 0;
UART0.UMCON0 = 0;
UART0.UBRDIV0 = 35;
UART0.UDIVSLOT0 = 0x888;
UART0.UINTM0 = 0xF;
GPD.GPDCON = (0x2 << 4);//使能为pwm输出
TIMER.TCFG0 = 0xFF;//256分频
TIMER.TCFG1 = 0x4 << 4;//16分频
TIMER.TCNTB1 = 31;//计数周期
TIMER.TCMPB1 = 15;//脉冲宽度
TIMER.TCON = 0xE << 8;//装载初值
TIMER.TCON = 0xD << 8;//开始计数
while (1) {
puts("MYTTY: ");
while (1) {
c = getc();
putc(c);
if (c == ‘\r‘)
break;
}
}
}工程源码: http://download.csdn.net/detail/a987860319/7126497Cortex A8,PWM裸机程序,布布扣,bubuko.com
原文:http://blog.csdn.net/it_liuwei/article/details/22689995