欢迎来到天天文库
浏览记录
ID:52699717
大小:70.00 KB
页数:22页
时间:2020-03-29
《ARM精讲演示代码.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、个人资料整理仅限学习使用ARM精讲演示代码串口程序设计/*************************************************Functionname:这是基础实验的一个模版Parameter:无Description:做基础实验,直接调用该模板即可Return:无Argument:无Autor&date:Daniel**************************************************/b5E2RGbCAP#defineGLOBAL_CLK1#include2、b.h>#include#include"def.h"#include"option.h"#include"2440addr.h"#include"2440lib.h"#include"2440slib.h"#include"mmu.h"#include"profile.h"#include"memtest.h"staticvoidcal_cpu_bus_clk(void>。voidSet_Clk(void>。voidbeep_init(void>。voidbeep_run(void>。/**********3、***************************************Functionname:delayParameter:timesDescription:延时函数Return:voidArgument:voidAutor&date:Daniel**************************************************/p1EanqFDPwvoiddelay(inttimes>{inti,j。for(i=0。ifor(j=0。j<400。j++>。}/*********4、****************************************Functionname:MainParameter:void22/22个人资料整理仅限学习使用Description:主功能函数,实现了串口的收发功能首先想串口发送十次“helloworld”,然后从键盘输入R,则蜂鸣器连续响5次。Return:voidArgument:voidAutor&date:Daniel**************************************************/DXDiTa9E3dvoidMain5、(void>{inti。intScom=0。Set_Clk(>。beep_init(>。/*设置波特率、数据位、停止位、校验位*/Uart_Init(0,115200>。Uart_Select(Scom>。for(i=0。i<10。i++>Uart_Printf("HelloWorld!">。}/*************************************************Functionname:Set_Clk(>Parameter:voidDescription:设置CPU的时钟频率Return:6、voidArgument:voidAutor&date:Daniel**************************************************/RTCrpUDGiTvoidSet_Clk(void>{inti。U8key。U32mpll_val=0。i=2。//don'tuse100M!//boot_params.cpu_clk.val=3。switch(i>{case0://200key=12。mpll_val=(92<<12>7、(4<<4>8、(1>。break。case1://300key=13。m9、pll_val=(67<<12>10、(1<<4>11、(1>。break。22/22个人资料整理仅限学习使用case2://400key=14。mpll_val=(92<<12>12、(1<<4>13、(1>。break。case3://440!!!key=14。mpll_val=(102<<12>14、(1<<4>15、(1>。break。default:key=14。mpll_val=(92<<12>16、(1<<4>17、(1>。break。}//initFCLK=400M,sochangeMPLLfirstChangeMPllValue((mpll_18、val>>12>&0xff,(mpll_val>>4>&0x3f,mpll_val&3>。//settheregister--rMPLLCON5PCzVD7HxAChangeClockDivider(key,12>。//theresultofrCLKDIVN[0
2、b.h>#include#include"def.h"#include"option.h"#include"2440addr.h"#include"2440lib.h"#include"2440slib.h"#include"mmu.h"#include"profile.h"#include"memtest.h"staticvoidcal_cpu_bus_clk(void>。voidSet_Clk(void>。voidbeep_init(void>。voidbeep_run(void>。/**********
3、***************************************Functionname:delayParameter:timesDescription:延时函数Return:voidArgument:voidAutor&date:Daniel**************************************************/p1EanqFDPwvoiddelay(inttimes>{inti,j。for(i=0。ifor(j=0。j<400。j++>。}/*********
4、****************************************Functionname:MainParameter:void22/22个人资料整理仅限学习使用Description:主功能函数,实现了串口的收发功能首先想串口发送十次“helloworld”,然后从键盘输入R,则蜂鸣器连续响5次。Return:voidArgument:voidAutor&date:Daniel**************************************************/DXDiTa9E3dvoidMain
5、(void>{inti。intScom=0。Set_Clk(>。beep_init(>。/*设置波特率、数据位、停止位、校验位*/Uart_Init(0,115200>。Uart_Select(Scom>。for(i=0。i<10。i++>Uart_Printf("HelloWorld!">。}/*************************************************Functionname:Set_Clk(>Parameter:voidDescription:设置CPU的时钟频率Return:
6、voidArgument:voidAutor&date:Daniel**************************************************/RTCrpUDGiTvoidSet_Clk(void>{inti。U8key。U32mpll_val=0。i=2。//don'tuse100M!//boot_params.cpu_clk.val=3。switch(i>{case0://200key=12。mpll_val=(92<<12>
7、(4<<4>
8、(1>。break。case1://300key=13。m
9、pll_val=(67<<12>
10、(1<<4>
11、(1>。break。22/22个人资料整理仅限学习使用case2://400key=14。mpll_val=(92<<12>
12、(1<<4>
13、(1>。break。case3://440!!!key=14。mpll_val=(102<<12>
14、(1<<4>
15、(1>。break。default:key=14。mpll_val=(92<<12>
16、(1<<4>
17、(1>。break。}//initFCLK=400M,sochangeMPLLfirstChangeMPllValue((mpll_
18、val>>12>&0xff,(mpll_val>>4>&0x3f,mpll_val&3>。//settheregister--rMPLLCON5PCzVD7HxAChangeClockDivider(key,12>。//theresultofrCLKDIVN[0
此文档下载收益归作者所有