ARM7 Study Notes---ClimberWin

Publisher:咖啡狐狸Latest update time:2016-09-06 Source: eefocusKeywords:ARM7  ClimberWin Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Start learning ARM, starting from ARM7, starting from LPC2103. Use LPC2103 practice board and H-JTAG parallel port debugger for actual practice.

Today I made a running light program, and the compilation environment was KEIL for ARM.

At first, I installed ADS debugging software for ARM, which is a compilation environment specifically for debugging ARM, and then used H-JTAG software for downloading and debugging. But today, I used KEIL for ARM to compile, because I am familiar with the KEIL environment, so I used KEIL for debugging. I made the first demonstration program, the LED water light program.

Today I also learned that ARM debugging can choose RAM space for debugging or ROM debugging. Now I use the parallel port H-JTAG, and I can also use D-LINK and other debuggers.

I downloaded the data sheet and user manual of PLC2103, which can be downloaded from www.NXP.com . There are also application notes available for download, which are quite practical.

Today I learned how to use and configure the I/O port.

 

IODIR is used to configure the IO port input and output

IOSET sets the IO port to high

IOCLR sets the IO port to low

IOPIN read IO port data

 

H-JTAG installation and use

 ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

 

Can detect ARM7 chip (LPC2103)

How to connect with KEIL and ADS is introduced in the HELP document, so the details are not recorded here.

 The following introduces the installation, software cracking, and configuration of the keil for ARM compilation environment.

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

Install MDK350PRC.EXE, then run KEIL_Lic.exe to crack, first run KEIL

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

 

The first running light program: You need to create a new project file named led and select the chip as follows:

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

Here is a brief description of how to debug in KEIL:

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

 

Click to enter the debugging interface. First, you need to configure H-JTAG for use in KEIL.

View the data sheet in HELP in the H-JTAG software

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

 

Select chip type

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

 

Fill in the crystal

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

Select the download format Intel Hex format and select the file path

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

In KEIL, you also need to configure: ROM and RAM configuration

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

After configuration, click Debug

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

The H-Flasher interface appears, click Program to debug.

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

 

LED water light source program:

/**************ARM7(LPC2103) exercise program******************************/

/****************************************************** ************/

/*****File Function : LED Display *****/

/*****Program Author : ZhengWen(ClimberWin) *****/

/*****MCU: LPC2103F external 12M crystal oscillator*****/

/*****Compile Date : 2009/12/2 *****/

/*****Edition Info : V1.0 *****/

//Compilation environment KEIL for ARM

//LED interface P0.0-P0.7

//LED running light program OK, the first ARM practice program

#include

#include

#define uint unsigned int

#define uchar unsigned char

void delayms(unsigned int count);//delay program

void led_display(void); //Flowing light display program

/*************Delay program*******************/

void delayms(unsigned int count)

{

       unsigned int i,j;

       for(i=0;i

       for(j=0;j<5000;j++);

}

/**********Flowing light display program*********/

void led_display(void)

{

    uchar i;

    for(i=0;i<8;i++)

          {

          IO0SET=0xff;

          IO0CLR=(1<

       delayms(100);

          }

}

//////////////Main program////////////////////

void main(void)

{

       IO0DIR=0x000000ff; //Configure P0.0-P0.7 as output             

       while(1)

       {           

    led_display(); //Flowing light display program

       }

}

 

 

Notes for Thursday, December 3, 2009

 

Start learning LPC2103 UART serial port

UART0 Exercise

 U0LCR Configuration

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

 

Baud rate calculation formula:

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

DivAddVal/MulVal is used for frequency division, and the values ​​are as follows: This can reduce the baud rate error.

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

 

When DivAddVal/MulVal=0;

So the values ​​of the high and low bits of the latch can be calculated

U0DL = (PCLK/16)/baudrate;

U0DLM= U0DL/256;

U0DLL = U0DL%256;

When you start setting the serial port parameters, you need to set DLAB of U0LCR to 1

When you finish setting the serial port parameters, you need to set the DLAB of U0LCR to 0. Test results:

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

UART0 test source program:

/**************ARM7(LPC2103) exercise program******************************/

/****************************************************** ************/

/*****File Function : UART test *****/

/*****Program Author : ZhengWen(ClimberWin) *****/

/*****MCU: LPC2103F external 11.0592M crystal oscillator*****/

/*****Compile Date : 2009/12/3 *****/

/*****Edition Info : V1.0 *****/

/****************************************************** ************/

//Compilation environment KEIL for ARM

//Function description: Serial port exercise, use UART0 to send characters and strings to the serial port

                             

#include

#include

#define uint unsigned int

#define uchar unsigned char

 

#define PCLK 11059200 //Crystal oscillator frequency

#define baudrate 9600 //Set the baud rate

#define PE (U0LSR&0x40) //Define whether the serial port is busy or not, PE=1 busy; PE=0 not busy green

void delayms(unsigned int count); //delay program

void UART0_INT(void); //Serial port initialization

void UART0_SendByte(unsigned char data ); //Serial port sends bytes

void UART0_SendStr(unsigned char const *str);//Serial port sends string

/*************Delay program*******************/

void delayms(unsigned int count)

{

       unsigned int i,j;

       for(i=0;i

       for(j=0;j<5000;j++);

}

/***********Serial port 0 initialization**********************/

void UART0_INT(void)

{ unsigned short int U0DL;

  U0LCR = 0x83; // DLAB = 1, baud rate can be set; no parity check, 1 stop bit, 8-bit data length.

  U0DL = (PCLK/16)/baudrate;

  U0DLM= U0DL/256; //high 8 bits

  U0DLL = U0DL%256; //low 8 bits

  U0LCR = 0x03; // DLAB = 0, set the baud rate; no parity, 1 stop bit, 8 data bits.

}

 

/***********Serial port sends bytes**********************/

void UART0_SendByte(unsigned char da ta)

{

  U0THR = da ta; //Send data

  while( PE==0 ); //Wait for data to be sent PE=1 busy; PE=0; not busy green

}

/***********Serial port sends string**********************/

void UART0_SendStr(unsigned char const *str)

{ while(1)

  { if( *str == '\0' ) break;

     UART0_SendByte(*str++); //Send data

  }

}

//////////////Main program////////////////////

int main(void)

{

  PINSEL0 = 0x00000005; //Set I/O connection to UART0

  PINSEL1 = 0x00000000;

  UART0_INT(); //Serial port initialization

  while(1)   

  {

   UART0_SendStr("LPC2103 UART0 Test OK!"); //Send string to the serial port

   delayms(1000);  

  }

  return(0);}

 

 

Friday, December 4, 2009

Learn LCD12864 control, ported from AVR program

The debugging was successful, but some problems occurred in the middle and the cause was not found. It turned out to be a timing problem. It was normal on AVR, but there was a problem on LPC2103. It was due to timing.

IO0SET=LCD_SCLK;

DELAY(100); //This delay program was not originally added, so an error occurred. It will work normally after adding it.

IO0CLR=LCD_SCLK; LCD12864 transplantation is successful. 2009 12.4.16:00

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

ARM7 Study Notes --- ClimberWin - Xiaowen - Xiaowen Electronic Design

LCD12864 liquid crystal display source program:

/**************ARM7(LPC2103) exercise program******************************/

/****************************************************** ************/

/*****File Function: LCD12864 display *****/

/*****Program Author : ZhengWen(ClimberWin) *****/

/*****MCU: LPC2103F external 11.0592M crystal oscillator*****/

/*****Compile Date : 2009/12/4 *****/

/*****Edition Info : V1.0 *****/

/****************************************************** ************/

//Compilation environment KEIL for ARM

//Function description: LCD12864 display program

                             

#include

#include

#define uint unsigned int

#define uchar unsigned char

#define LCD_CS (1<<0) //Chip select high level is valid. When using a single-chip LCD, the high level can be fixed.

#define LCD_SID (1<<1) //data r/w

#define LCD_SCLK (1<<2) //clock e

 

uchar const HEX_[]={"0123456789ABCDEF"};

uchar BUFFER[6] = {0};

uchar K_NUM;

void DELAY(uchar t);

void LCD_SEND(uchar date);

void LCD_SCOM(uchar st,uchar date);

void LCD_DELAY(void);

void LCD_INIT(void);

void LCD_write(uchar *p);

void LCD_LOCAL(uchar x,uchar y,uchar *p);

void LCD_cblank(uchar x,uchar y);

void LCD_count(long s,uchar x1,uchar y1,uchar x,uchar y,uchar *p);

void LCD_bai();

void Delay1ms(unsigned int count);

/*************Delay program*******************/

void delayms(unsigned int count)

{

       unsigned int i,j;

       for(i=0;i

       for(j=0;j<5000;j++);

}

void Delay1ms(unsigned int count)

{

       unsigned int i,j;

       for(i=0;i

       for(j=0;j<120;j++);

}

void DELAY(uchar t)

 {

   while(--t);

  }

void LCD_SEND(uchar date)

 {

      uchar i;

      //LCD_SCLK=0;

         IO0CLR=LCD_SCLK;

      for(i=0;i<8;i++)

         {

           //LCD_SID=date&0x80;

                   if((date&0x80)==0)

                       {IO0CLR=LCD_SID;}

                       else

                       { IO0SET = LCD_SID;}

           //LCD_SCLK=1;

           //LCD_SCLK=0;

                 IO0SET=LCD_SCLK;

                 DELAY(100);

                 IO0CLR=LCD_SCLK;

           date<<=1;

         }

  }

 

void LCD_SCOM(uchar st,uchar date)

 {

         uchar st_temp,hdate,ldate;

         if(st)

              st_temp=0xfa;

         else st_temp=0xf8;

         hdate=date&0xf0;

         ldate=date&0x0f;

         ldate <<= 4;

        // LCD_CS = 1;

             IO0SET=LCD_CS;

         LCD_SEND(st_temp);

         LCD_SEND(hdate);

         LCD_SEND(ldate);

         //LCD_CS = 0;

               IO0CLR=LCD_CS;

         DELAY(38);

 }

 void LCD_DELAY(void)

  { uchar s;

    s=10;

    while(--s)

    DELAY(250);

   }

 void LCD_INIT(void)

  {

    LCD_SCOM(0,0x30);

    LCD_DELAY();

    LCD_SCOM(0,0x0c);

    LCD_DELAY();

    LCD_SCOM(0,0x01); //Clear the screen and reset the DDRAM address counter to zero

    LCD_DELAY();

  }

  void LCD_write(uchar *p)

  {

    while(*p)

     {

      LCD_SCOM(1,*p);

      p++;

     }

  }

  void LCD_LOCAL(uchar x,uchar y,uchar *p) //lcd string (x,y) write!

  {

   switch (x)

   {

    case 1:LCD_SCOM(0,0x7f+y); LCD_write(p);break;

    case 2:LCD_SCOM(0,0x8f+y); LCD_write(p);break;

    case 3:LCD_SCOM(0,0x87+y); LCD_write(p);break;

    case 4:LCD_SCOM(0,0x97+y); LCD_write(p);break;

    default :LCD_SCOM(0,0x7f+y); LCD_write(p);

   }

  }

  void LCD_cblank(uchar x,uchar y)

  {

     switch (x)

      {

       case 1:LCD_SCOM(0,0x7f+y); LCD_SCOM(0,0x0d);break;

       case 2:LCD_SCOM(0,0x8f+y); LCD_SCOM(0,0x0d);break;

       case 3: LCD_SCOM(0,0x87+y); LCD_SCOM(0,0x0d);break;

       case 4:LCD_SCOM(0,0x97+y); LCD_SCOM(0,0x0d);break;

       default :LCD_SCOM(0,0x7f+y); LCD_SCOM(0,0x0d);

      }

  }

 

/************************************************/

main()

 { //main start

   Delay1ms(1000);

  IO0DIR=0x000000ff; //Configure P0.0-P0.7 as output      

  Delay1ms(1000);

  LCD_INIT();

  Delay1ms(1000);

  LCD_LOCAL(1,1,"LPC2103 exercise program");

  LCD_LOCAL(2,1,"LCD12864 display program");

  LCD_LOCAL(3,1,"Welcome to Huoxin Electronics");

  LCD_LOCAL(4,1,"www.huo-xin.com ");

  while(1); }

Keywords:ARM7  ClimberWin Reference address:ARM7 Study Notes---ClimberWin

Previous article:ARM9 learning---data communication between LINUX in virtual machine and main XP system
Next article:STM8S103 watchdog application

Recommended ReadingLatest update time:2024-11-23 16:35

Design of ECG Collection and Remote Transmission System Based on ARM7
1 Introduction Heart disease is one of the major diseases that seriously threatens human health and life. Statistics show that about 60% of heart patients die at home. If these patients can receive timely rescue and care, it is entirely possible to avoid death. Since heart attacks are very accidental and su
[Medical Electronics]
Design of ECG Collection and Remote Transmission System Based on ARM7
Design of LCD voltage display oscilloscope system based on ARM7
This design uses the ARM7 microprocessor as the core and uses the high-speed A/D in ARM7 as the pressure measurement unit to improve the reliability of data transmission; the data results are displayed in real time through the LCD, and the display method is friendly and intuitive; RAM and UART are used to store and
[Microcontroller]
Implementation of startup program in ARM7 embedded system
In the process of developing an embedded system based on ARM7, we found that the main technical difficulty lies in the writing of the system startup program. For this reason, this article discusses in detail the implementation of the startup program when developing an embedded system based on ARM7. 1. Startup program
[Microcontroller]
Design of Speech Processing System Based on ARM7 SoC
introduction With the rapid development of microelectronics and computer technology, many embedded application systems have emerged. Among them, various speech processing systems have been continuously developed and widely used in various industries, such as voice station announcers, automatic interpretation devices
[Microcontroller]
Design of Speech Processing System Based on ARM7 SoC
arm7 Litian Electronics lpc2148 PLL Experiment (II) PLL Resetting Experiment Reference Program
This program is modified by me according to the program in Zhou Ligong's textbook. The program sets KEY1 to connect to external interrupt 0, and sets the external interrupt to wake up the power-off CPU. Before powering off, LED1 flashes 10 times (note the flashing frequency), and then enters power-off mode. Once wok
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号