s3c2440默认使用自带12M晶振频率:要改变系统时钟频率需要设置LOCKTIME MPLLCON CLKDIVN寄存器在这里主要设置MPLLCON,CLKTIME寄存器LOCKTIME默认就行。
本实验主要设置MPLLCON的MDIV,PDIV,SDIV位。系统的时钟体系锁相环PLL电路有如下关系:
在这里改变的是FCLK系统时钟。以下是程序部分:
1,led.c
#define GPBCON (*(volatile unsigned long *)0x56000010)
#define GPBDAT (*(volatile unsigned long *)0x56000014)
#define s3c2440_mpll_200mhz ((0x5c<<12)|(0x01<<4)|(0x02))
#define CLKDIVN (*(volatile unsigned long *)0x4c000014)
#define MPLLCON (*(volatile unsigned long *)0x4c000004)
void clock_init()
{
CLKDIVN = 0X03;
__asm__(
"mrc p15, 0, r1, c1, c0, 0\n"
"orr r1, r1, #0xc0000000\n"
"mcr p15, 0, r1, c1, c0, 0\n"
);
MPLLCON = s3c2440_mpll_200mhz;
}
void delay()
{
int i;
for(i=0;i<0x20000;i++);
}
int main()
{
// clock_init(); //本条语句完成配置工作。这里假如汇编里面没有配置MPLLCON,CLKTIME寄存器则加上。
GPBCON = 0x00015400;
while(1)
{
GPBDAT = 0X00000000;
delay();
delay();
GPBDAT = 0X0000FFFF;
delay();
delay();
}
}
2,启动文件led_p.s
@*********************************
@File:led_p.s
@fuction:turn led
@********************************
.text
.global _start
_start:
ldr r0, =0x53000000
mov r1,#0x0
str r1,[r0]
ldr sp, =1024*4
ldr r0, =0x4c000014 //----------------------------------
mov r1,#0x03
str r1,[r0]
mrc p15,0,r1,c1,c0,0
ORR r1,r1,#0xc0000000 汇编配置寄存器
mcr p15,0,r1,c1,c0,0
ldr r0,=0x4c000004
ldr r1,=((0x5c<<12)|(0x01<<4)|(0x02))
str r1,[r0] -----------------------------------//
bl main
halt_loop:
b halt_loop
3,makefile
led_p.bin:led_p.s led.c
arm-linux-gcc -g -c -o led_p.o led_p.s
arm-linux-gcc -g -c -o led.o led.c
arm-linux-ld -Ttext 0x0000000 -g led_p.o led.o -o led_p_elf
arm-linux-objcopy -O binary -S led_p_elf led_p.bin
clean:
rm -f led_p.bin led_p_elf *.o
led_on_systime.zip
阅读(1229) | 评论(0) | 转发(2) |