这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » DIY与开源设计 » 电子DIY » haibin108 ARM DIY进程帖

共21条 1/3 1 2 3 跳转至

haibin108 ARM DIY进程帖

菜鸟
2012-03-16 11:05:41     打赏
哈哈  盼到啦

 审批通过者名单(截止至3月15日10点)

有我的名字  , 

but  居然,

还有和我名字一模一样的人一起呀 

还好公司不一样

不然,奖品会发错的哦 , 呵呵



预祝, ARM开发板DIY  活动圆满成功 



关键词: haibin108     进程    

院士
2012-03-16 11:13:25     打赏
2楼
说明你们有缘分

菜鸟
2012-03-16 11:25:03     打赏
3楼
呵呵, 他是男的吧  哈哈哈  我可是纯爷们

专家
2012-03-16 14:49:16     打赏
4楼
缘分啊!!

菜鸟
2012-03-19 09:00:19     打赏
5楼
上周五在论坛里看到那热卖的电烙铁,
由于手头上没有,
在公司做的话有些不方便,
为了这次比赛能够做出点成绩,
我很犀利的把它拍了下来 ,
呵呵 ,
今天应该能收到了吧 ,
hold啦

继续看手册
    先从主控芯片开始····

菜鸟
2012-03-19 09:03:18     打赏
6楼

菜鸟
2012-03-21 08:53:24     打赏
7楼
像朋友借了个TQ2440板子,
先编写模块程序
做些小测试
我想arm芯片应该也是大差不差吧
希望对后面的进程有所帮助



* 文件名称:UART.c
* 实现功能:最基本的UART发送与接收

#include"2440addr.h"  //包含2440相关寄存器的设置

#include"def.h"

//四个LED对应GPB5.6.7.8。
#define LED1 5
#define LED2 6
#define LED3 7
#define LED4 8

#define BAUD 115200 //波特率
#define Bit(x) (1<<x) //将某位置位
#define Output(x) (1<<2*x) //将对应IO置为输出
#define LED_On(x) rGPBDAT=~Bit(x) //点亮相应LED


* 名称:Clk_Set
* 功能:关于系统时钟的初始化


void Clk_Set(void)
{
int count;
rUPLLCON=(56<<12)|(2<<4)|2; //UCLK为48MHZ
for(count=0;count<10;count++)
{
;
}
rMPLLCON=(92<<12)|(1<<4)|1; //FCLK为400MHZ
rCLKDIVN=(0<<3)|(2<<1)|1;//HCLK位100MHZ,PCLK为50MHZ
rCAMDIVN=(0<<9); //PCLK=HCLK/4
}

* 名称:IO_init
* 功能:关于LED的端口初始化


void IO_init(void)
{
rGPBCON=Output(LED1)|Output(LED2)|Output(LED3)|Output(LED4); //LED的IO口置为输出
rGPBDAT=0xffff; //LED全部熄灭
}


* 名称:UART0_init
* 功能:UART0相关的初始化工作


void UART0_init(void)
{
rGPHCON=0xa0; //IO口使能UART0功能
rGPHUP=0xff; //上拉禁止
rULCON0=0x03; // 8位数据,无校验,1位停止位
rUCON0=0x05; //pclk时钟,中断请求方式为Tx-电平,Rx-脉冲
rUBRDIV0=26; //设置波特率
rUFCON0=0x00; //不使用FIFO
rUMCON0=0x00; //不使用流控
}


* 名称:Send_Byte
* 功能:发送一个字符


void Send_Byte(char data)
{
while(!(rUTRSTAT0&0x2)); //等待发送缓冲器空
rUTXH0=data;
}


* 名称:Send_String
* 功能:发送字符串


void Send_String(char* pt)
{
while(*pt)
{
Send_Byte(*pt++);
}
}


* 名称:Uart_Getch
* 功能:接收一个字符


char Uart_Getch(void)
{
while(!(rUTRSTAT0&0x1)); //等待接收缓冲器有数据
return (rURXH0); //读出数据
}


* 名称:Main
* 功能:测试UART发送和接收函数


void Main(void)
{
char temp;
IO_init();
UART0_init();
Clk_Set();
Send_String("HelloWorld"); //发送字符串
while(1)
{
temp=Uart_Getch(); //接收到字符
if(temp==0x01)
{
LED_On(LED1);
}
}

}        

菜鸟
2012-03-22 09:45:31     打赏
8楼
今天上班不久,就收到短信,说今天开始将收到基础包

不到10分钟,

快递小伙就过来了

没想到 就到了

鸡动呀

收到的器件清单如下:
STM32F103ZE 主控MCU 2 LQPF14414X14mm
MAX3232CSE 串口通信 1 SOP16
DB9串口接头 串口通信 2 DB9
ASM1117-3.3V 系统电源 1 TO-223
VP230 CAN收发器 2 SOIC-8
24C02 I2C接口EEPROM 1 SO-8
PRTR5V0U2X USB ESD保护 1 SOT143B

和我之前的理解不对
之前以为,基础包还包含可扩展的器件
看来以后得认真的读读论坛公告呀

还好板子没那么快到,
这两天可以去下电子市场,把需要的东西在不上

不容错过呀·····

菜鸟
2012-03-23 11:13:01     打赏
9楼
已收到基础包,确认并好评

菜鸟
2012-03-28 10:06:35     打赏
10楼
一led闪烁的实验
#include <stdint.h>
#include "LPC17xx.h"   
#include <system_LPC17xx.h >

#define CLOCK_SETUP           1
#define SCS_Val               0x00000020
#define CLKSRCSEL_Val         0x00000001
#define PLL0_SETUP            1
#define PLL0CFG_Val           0x0000000F
#define PLL1_SETUP            0
#define PLL1CFG_Val           0x00000023
#define CCLKCFG_Val           0x00000003
#define USBCLKCFG_Val         0x00000000
#define PCLKSEL0_Val          0x00000000
#define PCLKSEL1_Val          0x00000000
#define PCONP_Val             0x042887DE
#define CLKOUTCFG_Val         0x00000000


/*--------------------- Flash Accelerator Configuration --------------------------------------------------
//
// <e> Flash Accelerator Configuration
//   <o1.12..15> FLASHTIM: Flash Access Time
//               <0=> 1 CPU clock (for CPU clock up to 20 MHz)
//               <1=> 2 CPU clocks (for CPU clock up to 40 MHz)
//               <2=> 3 CPU clocks (for CPU clock up to 60 MHz)
//               <3=> 4 CPU clocks (for CPU clock up to 80 MHz)
//               <4=> 5 CPU clocks (for CPU clock up to 100 MHz)
//               <5=> 6 CPU clocks (for any CPU clock)
// </e>
//--------------------------------------------------------------------------------------------------------
*/
#define FLASH_SETUP           1
#define FLASHCFG_Val          0x00004000

/*
//-------- <<< end of configuration section >>> ----------------------------------------------------------
*/

/*********************************************************************************************************
 ** Check the register settings
 **********************************************************************************************************/
#define CHECK_RANGE(val, min, max)                ((val < min) || (val > max))
#define CHECK_RSVD(val, mask)                     (val & mask)

/***************************** Clock Configuration ******************************************************/
#if (CHECK_RSVD((SCS_Val),       ~0x00000030))
   #error "SCS: Invalid values of reserved bits!"
#endif

#if (CHECK_RANGE((CLKSRCSEL_Val), 0, 2))
   #error "CLKSRCSEL: Value out of range!"
#endif

#if (CHECK_RSVD((PLL0CFG_Val),   ~0x00FF7FFF))
   #error "PLL0CFG: Invalid values of reserved bits!"
#endif

#if (CHECK_RSVD((PLL1CFG_Val),   ~0x0000007F))
   #error "PLL1CFG: Invalid values of reserved bits!"
#endif

#if (PLL0_SETUP)                                                       /* if PLL0 is used               */
  #if (CCLKCFG_Val < 2)                                                /* CCLKSEL must be greater then1 */
    #error "CCLKCFG: CCLKSEL must be greater then 1 if PLL0 is used!"
  #endif
#endif

#if (CHECK_RANGE((CCLKCFG_Val), 2, 255))
   #error "CCLKCFG: Value out of range!"
#endif

#if (CHECK_RSVD((USBCLKCFG_Val), ~0x0000000F))
   #error "USBCLKCFG: Invalid values of reserved bits!"
#endif

#if (CHECK_RSVD((PCLKSEL0_Val),   0x000C0C00))
   #error "PCLKSEL0: Invalid values of reserved bits!"
#endif

#if (CHECK_RSVD((PCLKSEL1_Val),   0x03000300))
   #error "PCLKSEL1: Invalid values of reserved bits!"
#endif

#if (CHECK_RSVD((PCONP_Val),      0x10100821))
   #error "PCONP: Invalid values of reserved bits!"
#endif

#if (CHECK_RSVD((CLKOUTCFG_Val), ~0x000001FF))
   #error "CLKOUTCFG: Invalid values of reserved bits!"
#endif

/***************************** Flash Accelerator Configuration *******************************************/
#if (CHECK_RSVD((FLASHCFG_Val), ~0x0000F000))
   #error "FLASHCFG: Invalid values of reserved bits!"
#endif



#define XTAL        (12000000UL)                                /* Oscillator frequency                  */
#define OSC_CLK     (      XTAL)                                /* Main oscillator frequency             */
#define RTC_CLK     (   32000UL)                                /* RTC oscillator frequency              */
#define IRC_OSC     ( 4000000UL)                                /* Internal RC oscillator frequency      */


uint32_t SystemFrequency = IRC_OSC; 

void SystemInit (void)
{
#if (CLOCK_SETUP)                                                     /* Clock Setup                    */
  LPC_SC->SCS       = SCS_Val;
  if (SCS_Val & (1 << 5)) {                                           /* If Main Oscillator is enabled  */
    while ((LPC_SC->SCS & (1<<6)) == 0);                              /* Wait for Oscillator to be ready*/
  }

  LPC_SC->CCLKCFG   = CCLKCFG_Val;                                    /* Setup Clock Divider            */

  LPC_SC->PCLKSEL0  = PCLKSEL0_Val;                                   /* Peripheral Clock Selection     */
  LPC_SC->PCLKSEL1  = PCLKSEL1_Val;

  LPC_SC->CLKSRCSEL = CLKSRCSEL_Val;                                  /* Select Clock Source for PLL0   */

#if (PLL0_SETUP)
  LPC_SC->PLL0CFG   = PLL0CFG_Val;
  LPC_SC->PLL0CON   = 0x01;                                           /* PLL0 Enable                    */
  LPC_SC->PLL0FEED  = 0xAA;
  LPC_SC->PLL0FEED  = 0x55;
  while (!(LPC_SC->PLL0STAT & (1<<26)));                              /* Wait for PLOCK0                */

  LPC_SC->PLL0CON   = 0x03;                                           /* PLL0 Enable & Connect          */
  LPC_SC->PLL0FEED  = 0xAA;
  LPC_SC->PLL0FEED  = 0x55;
#endif

#if (PLL1_SETUP)
  LPC_SC->PLL1CFG   = PLL1CFG_Val;
  LPC_SC->PLL1CON   = 0x01;                                           /* PLL1 Enable                    */
  LPC_SC->PLL1FEED  = 0xAA;
  LPC_SC->PLL1FEED  = 0x55;
  while (!(LPC_SC->PLL1STAT & (1<<10)));                              /* Wait for PLOCK1                */

  LPC_SC->PLL1CON   = 0x03;                                           /* PLL1 Enable & Connect          */
  LPC_SC->PLL1FEED  = 0xAA;
  LPC_SC->PLL1FEED  = 0x55;
#else
  LPC_SC->USBCLKCFG = USBCLKCFG_Val;                                  /* Setup USB Clock Divider        */
#endif

  LPC_SC->PCONP     = PCONP_Val;                                      /* Power Control for Peripherals  */

  LPC_SC->CLKOUTCFG = CLKOUTCFG_Val;                                  /* Clock Output Configuration     */
#endif

  /*
   * Determine clock frequency according to clock register values
   */
  if (((LPC_SC->PLL0STAT >> 24)&3)==3) {                              /* If PLL0 enabled and connected  */
    switch (LPC_SC->CLKSRCSEL & 0x03) {
      case 0:                                                         /* Internal RC oscillator => PLL0 */
      case 3:                                                         /* Reserved, default to Internal R*/
        SystemFrequency = (IRC_OSC *
                          ((2 * ((LPC_SC->PLL0STAT & 0x7FFF) + 1)))  /
                          (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1)    /
                          ((LPC_SC->CCLKCFG & 0xFF)+ 1));
        break;
      case 1:                                                         /* Main oscillator => PLL0        */
        SystemFrequency = (OSC_CLK *
                          ((2 * ((LPC_SC->PLL0STAT & 0x7FFF) + 1)))  /
                          (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1)    /
                          ((LPC_SC->CCLKCFG & 0xFF)+ 1));
        break;
      case 2:                                                         /* RTC oscillator => PLL0         */
        SystemFrequency = (RTC_CLK *
                          ((2 * ((LPC_SC->PLL0STAT & 0x7FFF) + 1)))  /
                          (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1)    /
                          ((LPC_SC->CCLKCFG & 0xFF)+ 1));
        break;
    }
  } else {
    switch (LPC_SC->CLKSRCSEL & 0x03) {
      case 0:                                                         /* Internal RC oscillator => PLL0 */
      case 3:                                                         /* Reserved,default to Internal RC*/
        SystemFrequency = IRC_OSC / ((LPC_SC->CCLKCFG & 0xFF)+ 1);
        break;
      case 1:                                                         /* Main oscillator => PLL0        */
        SystemFrequency = OSC_CLK / ((LPC_SC->CCLKCFG & 0xFF)+ 1);
        break;
      case 2:                                                         /* RTC oscillator => PLL0         */
        SystemFrequency = RTC_CLK / ((LPC_SC->CCLKCFG & 0xFF)+ 1);
        break;
    }
  }

#if (FLASH_SETUP == 1)                                                /* Flash Accelerator Setup        */
  LPC_SC->FLASHCFG  = (LPC_SC->FLASHCFG & ~0x0000F000) | FLASHCFG_Val;
#endif
}

void myDelay (uint32_t ulTime)
    {
        uint32_t i;
   
        i = 0;
        while (ulTime--)
        {
            for (i = 0; i < 5000; i++);
        }
    }

    void GPIOInit( void )
    {
       
        LPC_GPIO2->FIODIR = 0xff;          // 方向设置为输出
        LPC_GPIO2->FIOSET = 0xff;
          
    }

    int main(void)
    {
        SystemInit();
        GPIOInit( );

        while(1)
        {
            LPC_GPIO2->FIOCLR = 0xff ;
            myDelay(1000);
            LPC_GPIO2->FIOSET = 0xff;        
            myDelay(1000);

            LPC_GPIO2->FIOCLR = 0xff;
            myDelay(1000);
            LPC_GPIO2->FIOSET = 0xff;   
            myDelay(1000);
        }
}

共21条 1/3 1 2 3 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]