Chinaunix首页 | 论坛 | 博客
  • 博客访问: 346402
  • 博文数量: 92
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 960
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-21 19:38
文章分类

全部博文(92)

文章存档

2010年(71)

2009年(21)

我的朋友

分类: 嵌入式

2009-08-21 19:48:32

Since I first touched the book named Structure of  ARM7, I conclude that any innovation and creation in the embeded system will change the face of this world. My major is biomedical engineering, and it is obvious that powerful chips have made portable medical machine possible and popular. So I am very sure that I will devote my rest life into the field of the system on chips.
Last semester I have taken a class about ARM7, and I focused  on studying the structure of ARM7, arm assembly language, and the working function of the bootloader. During the experiment class, I wrote some programs to improve my real ARM ability. Here I want to list one to help the followers, because the beginning is hard.
 
This project completes the work that if I put a number button on ARM7 chip(for example 5), then I will see 5 on the Hyperterminal in the PC, and the fifth small lamp on the chip will be on.
If you just want to run your programs on RAM, then boot.s is not needed. I wrote vector.s to create a interruption list, and init.s to initialize stack pointer registers, and then MSR CPSR_c, r0
                                                                                      IMPORT __main
                                                                                      B           __main
In the main.c, the main work I do is to initialize KPI, UART0,LED,and delay function. Here I just list the code of KPI
 /*******************************************************************************
* Function Name  : PutIn
* Description    :put the strings into sen_buf
* Input          : the address of the strings
* Output         : None
* Return         : None
*******************************************************************************/
void KPIInit(void)
{
    REG_GPIO_CFG2 |= 0x000aaaaa; //set GPIO as KPI mode
    REG_GPIO_CFG2 &= 0xfffaaaaa;
   
    REG_AIC_SCR29 = 0x00000045; //set KPI interruption mode as high voltage, priority level as 5
    REG_AIC_MECR = 0x20000000;
 
 REG_KPICONF = 0x00142fff;
}
void PutIn(U8 *string)
{
    U8 lenth;
    strlenth = strlen(string);      
    for(lenth = 0; lenth < strlenth; lenth++)
    {
        sen_buf[lenth] = *string++;
    }
   
    REG_UART0_TX = sen_buf[0];  // send the first data
    REG_UART0_IER = 0x03;       // enable sending and receiving interruption
}
In the HB_it.c, the main work I do is to complete the UART0 and KPI function, here I list KPI
 void KPI_Handler(void)
{
 U32 KeyValue, tmp;
 
 tmp = REG_KPISTATUS; //get the value of the button
 tmp &= 0x0000000f;
 if((tmp > 0x7) && (tmp < 0xC))
 {
  KeyValue = tmp - 4;
 }
 else if((tmp > 0x3) && (tmp < 0x8))
 {
  KeyValue = tmp + 4;
 }
 else
 {
  KeyValue = tmp;
 }
 
 printf("KPI interrupts. %x\n", KeyValue);
 sen_buf[0]=(KeyValue+0x30);  //send the value of the button into sen_buf
 REG_UART0_TX = sen_buf[0];  // send the first data
 REG_UART0_IER = 0x03;       // enable the receiving and sending interruption
 EBILED_ADDRESS=~(0x01< Delay(1000000);
}
 
 
阅读(874) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:Loadable Modules

给主人留下些什么吧!~~