My beginning in embeded system--ARM7

Since I first touched the book named Structure of  ARM7, I clued into the fact 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<<KeyValue);   //make the Nth lamp on
 Delay(1000000);
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值